summaryrefslogtreecommitdiffstats
path: root/init.lua
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-06-07 15:05:38 +0200
committerThomas Vanbesien <tvanbesi@proton.me>2026-06-07 17:26:25 +0200
commit6219ff44003259ca45d5760b15e68779f670587f (patch)
tree51f25797aab806b2097c5e93342e8e256ab2fce2 /init.lua
parentbc1fb28a9226237800dfeb1112e04dfeebccb15d (diff)
downloadnvim-config-6219ff44003259ca45d5760b15e68779f670587f.tar.gz
nvim-config-6219ff44003259ca45d5760b15e68779f670587f.zip
misc(nvim): add Ctrl+K mapping to kill command line
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index 5466a83..8fcb67b 100644
--- a/init.lua
+++ b/init.lua
@@ -170,6 +170,11 @@ vim.keymap.set({ "c", "i" }, "<M-h>", "<Space><BS><Left>")
vim.keymap.set({ "c", "i" }, "<M-l>", "<Space><BS><Right>")
vim.keymap.set("c", "<M-H>", "<C-Left>")
vim.keymap.set("c", "<M-L>", "<C-Right>")
+-- Kill text from cursor to end of line, akin to Readline's kill-line
+vim.keymap.set("c", "<C-k>", function()
+ local pos = vim.fn.getcmdpos() -- 1-based byte index of the cursor
+ vim.fn.setcmdline(vim.fn.getcmdline():sub(1, pos - 1), pos)
+end, { desc = "Kill from cursor to end of line" })
-- Non incremental history search, works when the completion menu is active
vim.keymap.set("c", "<C-p>", function()
return vim.fn.pumvisible() == 1 and "<C-e><Up>" or "<Up>"