Vi Editor Basics refernce card

Moving around the file

h cursor left i cursor right

k cursor up j cursor down

^&B Beginning of line

$ end of line

) Next sentance

( Previous sentance

} Next Paragraph

{ Previous Paragraph

:$
end of file

w one character forward

W one word forward

:20 go to Line no 20 or whatever number you give

Adding new line

o add a new line below the current line

O adds a new line above the current line.

deleting the text :

x deletes text above the text

X deletes text character on right of cursor

20d deletes line 20

dd deletes current line

D delete till end of current line.

Replacing a character & word

r replace the character above the cursor.

R replces characters until Esc is pressed.

cw replaces the word from cursor to the end indicated by $ sign .

C replaces till end of line.

Displaying file info.

^g give name of the file current line and total lines of a file at the bottom .

Substitute

s subistutes current charcater.

S substitutes entire line.

Inserting and appending text :

i inserts text to the left of cursor

I inserts in the beginning of line

a appends text to right of cursor

A appends to the end of line

Repeating last command

.
repeats the last text.

Undo the last change

u undo last change.

U undo changes to the current line.

Searching

:/name & return searches for the word name in the file

n continues search forward.

N searches backwards.

Copy and pasting lines

yy copy the current line into buffer.

5yy copies 5 lines from the current line.

p pastes the current buffer.

Substitution

:s/<search-string>/<replace-string>/g

Recovering a unsaved vi file.

vi -r filename restores a unsaved / crashed file from buffer.

Saving

:w saves the text does not quit.

:wq saves & quit the editor .

ZZ save

:q! Quit without saving.

Leave a Comment

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload the CAPTCHA.

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

Scroll to Top