the <c-k>: kill-line
feature of bash, which means kill the line from the current cursor position to the end of the line. how to do this in vim
command-line mode when editing the command?
for example:
when typing :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
?
Ctrl+E or End – moves the cursor to the end of the line. Ctrl+B or Left Arrow – moves the cursor back one character at a time.
Move cursor to end of file in vim In short press the Esc key and then press Shift + G to move cursor to end of file in vi or vim text editor under Linux and Unix-like systems.
Use CTRL + o while in insert mode to temporarily enter normal mode for the next command, and then $ to go to the end of the line (after which you will be returned to insert mode) Use ESC to return to normal mode, and then A which both moves the cursor to the end of the line and enters insert mode.
I found this key binding in Shougo's vimrc that sets up Ctrl+k to delete until 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 doesn't preserve the rest of the line in a register, the way the equivalent binding in bash or Emacs does.
Check :h eval
for more help on what you can do on the command line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With