Nov 19, 2009

vi editor reference



vi commands , quick reference
Moving Cursor in File
Left   
h
Right
i
Up
k
Down
j
Line
Beginning
^ or B
end
$
Sentance :
 Next sentance
)
Previous sentance
(
Paragraph
Next
}
Previous 
{
file
Go to end of file
:$
on chacter forword
:w
One word forword
:W
go to a line number
:line_number
display file info .
^g
Inserting and appending text :
inserts text to the left of  cursor
i
nserts in the beginning of line 
I
appends text to right of cursor
a
appends to the end of line
A
Adding new line
add a new line below the current line
o
adds a new line above the current line.
O
deleting the text :
deletes text above the text
x
deletes text character on  right of cursor
X
deletes line 20
20d
deletes current line
dd
 delete till end of current line.
D
Replacing a character & word
 replace the character above the cursor.
r
replces characters until Esc is pressed.
R
replaces the word from cursor to the end indicated by $ sign .
cw
 replaces till end of line.
C
Substitute
subistutes current charcater.
s
substitutes entire line.
S
Undo the last change
undo last change.
u
undo changes to the current line.
U
Copy and pasting lines
copys the current line into buffer.
yy
copies 5 lines from the current line.
5yy
pastes the current buffer.
p
Searching
Searches for the word name in the file
:/name  
n continues search forward.
n
N searches backwards
N
Saving
saves the text does not quit.
:w
 saves & quit the editor .
:wq!
save
ZZ
Quit without saving
q!
Search & Replace
s///g  .
Repeating  last command
.
Recovering a unsaved vi file.
vi -r  filename 

No comments:

Post a Comment

Search This Blog