Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I move around in the Vim command line?

Tags:

vim

If you're typing a command in Vim (I mean you've started with : and you're working in the bar at the bottom of the screen) is there a way to move the cursor around other than tapping the arrow keys? In particular, can you move it to the beginning, end, back n characters, or back one word?

like image 635
Ethan Avatar asked Jan 16 '10 00:01

Ethan


People also ask

How do I move around in vim?

To move left, press h . To move right, press l . To move down, press j . To move up, press k .

What does CTRL d do in vim?

You will see list of commands that matches characters in front of the cursor by pressing CTRL-D in the command mode. For example, if you pressed :se in normal mode, then pressed CTRL-D , you will see list of commands that start with se .

How do you move to the beginning of a line in vim?

Press 0 to go to the beginning of a line, or ^ to go to the first non-blank character in a line.


2 Answers

Tap Ctrl+F while in command-line mode (just after :). There you'll get command-line window which could be edited&navigated as a regular vim window (hjkl etc.).

See :h cmdline-window for details.

like image 73
Maxim Kim Avatar answered Oct 01 '22 22:10

Maxim Kim


Type

:h cmdline-editing

for details. I am listing a few of the interesting non-arrow commands that do something similar to what you want.

  • ctrl-B: cursor to beginning of command-line
  • ctrl-E: cursor to end of command-line
  • ctrl-W: delete the word before the cursor
  • ctrl-U: remove all characters between the cursor position and the beginning of the line
like image 45
Alok Singhal Avatar answered Oct 01 '22 21:10

Alok Singhal