In vim command line mode: how to kill line from current cursor position to end

<c-k>: kill-line

bash function , which means "kill" the line from the current cursor position to the end of the line. how to do it in command line mode vim

when editing a command?

eg:
when entering :echo 'hell|o world'

this command in vim

command line mode and the cursor is in position |

, how to kill the line to become :echo 'hell

?

+3


source to share


2 answers


I found this key binding in Shougo vimrc which sets Ctrl+ kto delete to the end of the line:

" <C-k>, K: delete to end.
cnoremap <C-k> <C-\>e getcmdpos() == 1 ?
      \ '' : getcmdline()[:getcmdpos()-2]<CR>

      



Note that this does not preserve the rest of the string in case, as does the equivalent binding in bash or Emacs.

Check :h eval

for more information on what you can do on the command line.

+2


source


Command line editing should not happen on the command line itself, but in the editor.



So there you have it <C-x>e

in bash and <C-f>

in Vim.

0


source







All Articles