VI Editor

v – Visual
o – Insert a new line below the current line
O – Insert a new line above the current line
yy – Copying Code

Put Command
P bring back before cursor
p bring back after cursor

Deleting
x delete character under cursor

dd delete line under cursor

dw delete word under cursor

db delete word before cursor

Find Commands
? finds a word going backwards
/ finds a word going forwards

Cursor Movement
h move left (backspace)
j move down
k move up
l move right (spacebar)

0 move cursor to the first column on the current line
$ last column on the current line
H move cursor to the top of the screen
M move cursor to the middle of the screen
L move cursor to the bottom of the screen
b move to the beginning of the previous word or punctuation mark
e end of next word or punctuation mark

Screen Movement
G move to the last line in the file

Miscellaneous Commands
. repeat last command
u undoes last command issued
J join current line with the next line
xp deletes first character and inserts after second (swap)

TO DISPLAY THE LINE NUMBER IN FILE
:set number
or
:set nu

TO REPLACE THE STRING IN FILE
:%s/SourceString/ReplaceString/g

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s