Reputation: 1480
is there a way to use vim/vi in the vim command line? Sometimes I write a long command in vim such as:
:!./script /home/user/pet --flag=1
and I want to change for instance "user" by "other". What I usually do is to navigate the command line with right arrow which is time consuming and even more when I want to go to the beginning of the line. I would like to have something like "0" to go there or w/b to move by words. Or use j/k to go to the next/previous command.
Thanks.
Upvotes: 4
Views: 555
Reputation: 3197
If you run set -o vi you will have vim capabilities in your command line. Just put 'set -o vi' in your .bashrc file or equivalent to have it by default.
Upvotes: 0
Reputation: 195029
:h cedit
ctrl-F
(default) to enter command window.q:
(for search, type q/
)
Upvotes: 6
Reputation: 116401
I'm not aware how you can use Vim commands to edit a command directly on the command line, but if you enter the command window q:
you get can use regular Vim editing to edit commands.
From there you can execute commands by hitting <CR>
or use Ctrl-C
to copy the command to the regular command line.
Upvotes: 2
Reputation: 239682
Vim has a feature called the "commandline window". You can enter it with Control-F by default when you're already on the commandline, or q:
from normal mode, edit the commandline using vim commands, and press enter to execute. It also contains your command history so that you can yank previous commands if you like. See :help cmdline-window
for more information.
Upvotes: 5