vi commands cheat sheet

These are the commands i always use in vi.

####################################
# Moving the cursor in file buffer #
####################################
0   #Go to the first character of the current line
$   #Go to the last character of the current line
H   #Go to the first line of the current page
M   #Go to the middle line of the current page
L   #Go to the bottom line of the current page
gg  #Go to the first line of the file
G   #Go to the last line of the file
<n> #Go to the nth line of the file

####################################
#           Text editing           #
####################################
yy     #Copy the current line
<n>yy  #Copy nth rows of lines starting from current line
P      #Paste text above the current line
p      #Paste text below the current line
u      #Undo
ctrl+r #Redo
.      #Repeat last action
dw     #Delete the word which contains the cursor
dd     #Delete the current line
<n>dd  #Delete the nth rows of lines starting from current line

 

Done =)

Reference: vi cheatsheet from apolzon / meticulous_vim

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.