Search
Quick Link

vi editor

>> Return back to Knowledge Base


General vi commands:

open a file _________________________ vi filename
read a file _________________________ :r filename
enter vi edit mode ___________________ :i
exit vi edit mode ____________________ [esc]
save changes without exiting ___________ :w
exit vi without saving changes __________ :q!
exit vi and save changes ______________ ZZ orĀ  :wq

Inserting:

replace character under cursor _________ r
keep replacing character until [esc] ______ R
insert before cursor __________________ i
append after cursor __________________ a
append at end of line _________________ A
open line above cursor ________________ O
copy line (precede with # for multiple) ____ yy
past before cursor ___________________ P
past after cursor _____________________ p

Deleting:

delete character under cursor __________ x
delete word under cursor ______________ dw
delete word before cursor ______________ db
delete line under cursor _______________ dd

Miscellaneous:

repeat last command _________________ .
undo last command __________________ u
undo all commands on this line _________ U
join current line with next line ___________ J
find word going forward _______________ /
find word going backward ______________ ?

Cursor Movement:

move left __________________________ h or [backspace]
move right _________________________ l or [space bar]
move down ________________________ j
move up __________________________ k
move to beginning of next word _________ w
move to beginning of previous word _____ b
move cursor to top of the screen ________ H
move cursor to bottom of the screen _____ L
move to the last line in the file _________ G
move to line x ______________________ xG
move cursor to last column ____________ $
move cursor to first column ____________ 0


>> Return back to Knowledge Base


Convert to PDF