Lets say I am copying a file with the vim command mode and my cursor is at the end of the line.
:!cp path/to/original/file path/to/new/file
Is there a way I can jump back a word like I can in the shell by typing Esc b
?
You cannot use "Esc b" because, obviously, that would discard the command you where typing. However you can bind some keys to move around.
The question as already be answered here : Navigating in Vim's Command Mode
The easy way is just to add :
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <M-b> <S-Left>
cnoremap <M-f> <S-Right>
In your .vimrc
For entering and editing complex commands, you may like working directly in the command line window which is accessed with the normal mode command q:
. See :h 20.5
and :h q:
. Or if you are already in command mode, you can access the command line window with C-f
.
q:
to get into the command line window. (or type C-f
from command line mode.enter
in normal mode in
this command line window. The line your cursor is on will be executed as a command inAnother option to consider is to edit/yank the command from another buffer. You can do this by yanking the desired text and pasting it in command mode by typing C-R n
, where n
is the register you yanked to.
BTW: I like the mappings that @rks provided. But if you don't have these mappings, you can use the out of the box commands. Look up :h c_<S-Left>
and :h c_<S-Right>
and :h 20.1
.
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