vim commands guide

An introduction of most used vim commands

Sun, 21 Sep 2014

One of the most important things to know when analyzing and editing text in a UNIX environment is to be able to navigate effectively inside the textual content.

unsplash.com

The sections listed below will show the most common ways of navigating:

Character / word-based navigation

 h  move one character to the left

 j  move down one line

 k  move up one line

 l  move one character to the right

 w  go to the beginning of the next word

 b  go to the beginning of the previous word

 e  go to the end of the current word

You can specify the number of times the commands listed above should be repeated by adding a number next to it. For example, you can go down 4 lines with 4j command.

Navigating on the line

 0  go to the beginning of the line

 $  go to the end of the line

 \_  go to first non space character of the line

 g\_  go to last non space character of the line

Navigation between lines

gg  go to the first line

 G  go to the last line

 nG  go tho n'th line ( where n is a positive integer )

Screen-based navigation

These are commands based on the range you are viewing on the screen:

 H  go to the first line currently visible

 M  go to the line that is in the middle of the screen

 L  go to the last line currently visible

 z.  move the window vertically so that the current line is in the middle

 zt  move the window vertically so that the current line is at the top

 zb  move the window vertically so that the current line is at the bottom

 Ctrl-D  move half page down

 Ctrl-U  move half page up

 Ctrl-B  move whole page up

 Ctrl-F  move whole page down

Navigating by navigation history

 Ctrl-o  Go to the previous cursor position

 Ctrl-i  Go to the next cursor position (works only if you had gone back before)

Navigating by search criteria

 n  next occurence of the search expression (to search, use :?\<exp> )

 N  previous occurence of the search expression

 \*  next repetition of the word on which the cursor is on

 \#  previous repetition of the word on which the cursor is on

Navigating by bracket opening / closures

%  go to the matching bracket { } [] ( ) of the bracket that the curser is on

Further Reading

Loading...
Omer Gurarslan

Omer Gurarslan is a software developer based in London who loves developing Web & Mobile Applications using modern frameworks and JavaScript.