Reputation: 22643
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
?
Upvotes: 7
Views: 2998
Reputation: 2820
In vim's command mode, I just use ctrl-left and ctrl-right arrows. The same works in bash - I wasn't aware of the esc-b method there.
No editing of the .vimrc file is required for this on my Ubuntu and Debian systems, but YMMV on others. It's presumably based on the standard configuration that's packaged for the OS
Upvotes: 0
Reputation: 212248
A nice vim feature is ctrl-f
. Typing ^f
(or whatever key is specified in the cedit
option, with ctrl-f
being the default) from command line mode has the same effect as typing q:
from normal mode; it pulls your entire command history into a window and lets you edit it as a buffer. Try :help cmdwin
for more details.
Upvotes: 3
Reputation: 1219
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
.
Upvotes: 3
Reputation: 920
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
Upvotes: 8