How can I navigate the Vim command line?

If you enter a command in Vim (I mean that you started with : and you work in the panel at the bottom of the screen) is there a way to move the cursor other than pressing the arrow key? In particular, can you move it to the beginning, end, back n characters or back one word?

+63
vim
Jan 16 2018-10-10T00:
source share
7 answers

Type of

:h cmdline-editing

for details. I list a few interesting non-shooter teams that do something similar to what you want.

  • ctrl - B : cursor to the beginning of the command line
  • ctrl - E : cursor to end of command line
  • ctrl - W : delete word before cursor
  • ctrl - U : delete all characters between cursor position and beginning of line
+58
Jan 16 '10 at 0:14
source share

Press Ctrl + F in command line mode (immediately after : . There you will get a command line window that you can edit and navigate in the form of a regular vim window (hjkl, etc.).

See :h cmdline-window more details.

+88
Jan 16 '10 at 17:11
source share

To add to Maxim Kim Answer,

In Normal Mode ..

q: → cmdline window for commands

q/ → cmdline window for forward search

q? → cmdline window to search back

Ctrl-C or <CR> will bring you out of the cmdline window

+20
Jan 16 '10 at 18:39
source share
  • ctrl + left arrow : go back
  • ctrl + right arrow - move a word
  • ctrl + b - return to the beginning of the line
  • ctrl + e - go to the end of the line
  • ctrl + w - delete one word before the cursor
  • ctrl + u - delete line
  • ctrl + f - if you need more use of the editing energy ctrl + f , and you will edit your command normally. For example, if you want to move 5 characters to the left, use ctrl + f and then 5h .
+15
Mar 02 '13 at 9:49 on
source share

nnoremap q; q: nnoremap q; q: to facilitate typing. usr_20.txt and cmdline.txt contains all the useful information.

+3
Jun 17 '16 at 15:28
source share

In fact, you can add your own navigation keys. For example, I use the following in my .vimrc to make hovering in command mode in the hjkl way (abuse of the Ctrl key):

  " moving aroung in command mode cnoremap <ch> <left> cnoremap <cj> <down> cnoremap <ck> <up> cnoremap <cl> <right> cnoremap ^ <home> cnoremap $ <end> 

where ^ and $ are really <ctrl- ^> and <ctrl- $> respectivelly printed as <cv> c- → and <cv> c- $> in .vimrc (for some reason <c- ^> and < c- $> will not work, at least in my setup, but first do)

+1
Apr 6 '13 at 14:34
source share

On mac os

  • Shift + left arrow : retreat to the word
  • Shift + right arrow : move forward a word
0
Sep 23 '19 at 3:49
source share



All Articles