Basic Vi Commands




vim or vi   Run vim and open the given filename.

:w Save file.:x or SHIFT ZZ  Save and exit.

:q Exit if no changes have been made.

:q! Exit and undo any changes made.

:set nu Display line numbers.



h            Move left one character.
j             Move down one character.
k            Move up one character.
l             Move right one character.
w           Move forward one word.
b            Move to the start of the word.
e             Move to the end of the word.
(             Move back one sentence.
)             Move forward one sentence.
{             Move back one paragraph.
}            Move forward one paragraph.
^           Move to the beginning of the line.
$            Move to the end of the line.
<n>G    Move to the nth line.
G            Move to the last line.
gg            Move to the first line.
%             Move to the matching bracket.


x          Delete a single character.
D         Delete the rest of the line.
dd        Delete the entire current line.
ndw     Delete the next n words.
ndd      Delete the next n lines.
:x,yd    Delete from line x through to line y.

Entering Insert mode

i      At the cursor.
a     After the cursor.
I      Before the current line.
A     After the current line.
o      Insert a new line after the current line.
O      Insert a new line before the current line.
C       Ovewrite the whold current line.
ESC   Exit Insert mode.

View more at





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s