Skip to main content Skip to navigation

Vi Edtor

vi Starts Vi editor for editing and entering text and writing it to a file

vi filename Opens file having filename in the current directory

vi -r filename Restores the vi buffer for the file filename to exactly the state it was in immediately before the system failed

ZZ or :wq Quit vi and save the contents ofthe buffer to the file that vi is being used to edit

:q! Quit vi without saving the contents of the buffer to the file

:w filename Quit vi and save the contents of the buffer to a new file having name filename

:s/that/which Replaces first occurence of the word "that " in the current line with the word "which"

:s/that/which/g Replaces every occurence of the word "that " in the current line with the word "which"

:g/that/s//which/g Replaces every occurence of the word "that " throughout the file with the word "which"

:g/that/s//which/gc Replaces every occurence of the word "that " throughout the file with the word "which" after confirmation from user

LIST OF "INSERT" COMMANDS 

a Insert text after the cursor

i Insaert text before the cursor

A Append text at the end of the line

I Append text at the start of the line

o Open a new line below the current line

O Open a new line below the current line

:r filename Inserts the contents of the file filename immediately after the current line

y) Yanks the current sentence into the temporary buffer

y{ Yanks the text from the present cursor position to the the beginning of the current paragraph into the temporary buffer

p Places the contents of the temporary buffer after the current cursor position

MOVE THE CURSOR ALONG THE LINE 

l Next character

h Previous character

w Next word

wn Next n words

b Previous word

bn Previous n words

0(zero) Start of current lin

$ End of current line

e End of current word

MOVE THE CURSOR BETWEEN THE LINES

j Next line down (same column)

k Previous line up (same column)

+ Start of next line down

- Start of previous line

MOVE BETWEEN TEXT BLOCKS

) Begining of next sentence

( Begining of previoys sentence

} Begining of next paragraph

{ Begining of previos paragraph

MOVING OVER FILE

IG Top of the file

G Bottom of the file

MOVE AROUND THE SCREEN

H Top of the screen

M Middle of the screen

L Last line of the screen

Ln Last line but n

MOVING BETWEEN SCREENS

^F Forward one screen

^B Backward one screen

^D Forward half screen (down)

^U backward half screen (up)

DELETING CHARACTERS

x Current character

dh Previous character

DELETING WORDS AND LINES

dw Current word

db Previous word

dd Entire line

d$ To end of line

do(zero) To start of line

next n lines next n lines

DELETING SENTENCES AND PARAGRAPHS

d) To end of sentence

d( To begining of sentence

d} To end of paragraph

d{ To begining of paragraph

SEARCHING FOR TEXT

/pattren <RETURN> Forward for a pattren

? pattren <RETURN> Backward for a pattren

n Repeat previos search

N Repeat previous search in reverse direction