VI Reference
VI Reference
a Append text after cursor. h Move cursor left (left arrow; backspace)
A Append text at the end of the line. j Move cursor down (down arrow)
i Insert text before the cursor. k Move cursor up (up arrow)
I Insert text at the beginning of the line. l Move cursor right (right arrow, spacebar)
o Open a new line below the cursor.
O Open a new line above the cursor. H Move to top of screen.
w Move forward one word. M Move to middle of screen.
W Move forward one word past punctuation. L Move to bottom of screen.
b Move backward one word.
B Move backward one word past punctuation. CTRL-f Page forward one screen.
e Move forward at end of word. CTRL-d Scroll down one-half screen.
E Move forward at end of word past punctuation. CTRL-b Page back up one screen.
x Delete character at cursor. CTRL-u Scroll up one-half screen.
X Delete character left of cursor.
:5,10d Delete lines 5 through 10.
D Delete line to right of cursor. :1,3co 5 Copy lines 1 to 3; put after line 5.
dw Delete word right of cursor. :4,6m 8 Move lines 4 to 6 to line 8
ndw Delete n number of words.
dd Delete line containing the cursor. cw Change word.
ndd Delete n lines. ncw Change n words.
dG Delete to end of FILE. nyy Yank n lines (copy).
Y Yank current line.
R Overwrite characters on line. p Put yanked/deleted line(s) below current line.
r Replace one letter only. P Put yanked/deleted line(s) above current ilne.
C Change from cursor to end of line. :r insert_file Insert insert_file below the current line.
s Substitute string for character. :n r Insert insert_file after line number n.
insert_file
J Join current line and line below current line.
xp Transpose/switch letters. u Undo previous command.
~ Change case of letter. U Undo all changes to current line.
:u Undo previous last line command.
:w Save changes.
:w new_file Save with name new_file :set nu Show line numbers.
:w! existing Overwrite existing file existing :set nonu Hide line numbers,
:wq Save changes and quit vi. :set ic Search ignore case.
ZZ Save changes and quit vi :set noic Search case sensitive
:q! Quit without saving. :set list Display invisible characters (tabs)
:set nolist Don't display invisible characters.
G Go to last line. :set showmode Show current mode of operation.
1G Go to first line of file. :set noshowmode Don't show current mode of operation.
:21 Go to line 21. CTRL-L Clear scrambled screen.
21G Go to line 21.