There isn't a default shortcut mapping to do what you asked for. A full documentation of command mode editing can be found through :help cmdline-editing
. You are welcomed to browse through it to find anything useful to you. But I don't think the function you asked for is in it.
I guess the default way of editing of command-line doesn't require such operation. Usually we remove the word before cursor by <Ctrl-W>
without moving cursor around. But of course, if you have your own way of editing it, you can always bend vim's behaviour to your favour.
You can have the shortcut you want by mapping <C-K>
to a function defined to suit your required behaviour. Here I write an example. You can just paste the following code to your ~/.vimrc
. Re-source the file. And you can have the short-cut working in your own way.
cnoremap <C-k> <C-\>estrpart(getcmdline(),0,getcmdpos()-1)<CR>
If you are interested, this invokes an default command mode shortcut(<C-\>e
) for evaluating {expr} and replacing the whole command line with the result. strpart()
is an string truncating function given by vim.
Upon your <C-k>
keystroke, vim will extract the content from the command mode as a string. And put back only the content from the start of the string to one position ahead of the cursor position. Rest of the content will be truncated and thus deleted.
FYI, "command mode" is synonymous with "normal mode". What you are talking about is "command-line mode". See
:help vim-modes
. – romainl – 2014-12-01T09:34:31.840