Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim command line editting

Tags:

vim

vi

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.

like image 737
armando Avatar asked Dec 16 '22 12:12

armando


2 Answers

:h cedit
  • in command line, type ctrl-F(default) to enter command window.
  • or in normal mode type q:

(for search, type q/)

like image 147
Kent Avatar answered Dec 21 '22 09:12

Kent


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.

like image 29
hobbs Avatar answered Dec 21 '22 10:12

hobbs