Vi

From Wiki
Revision as of 18:31, 4 February 2011 by Scott (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Intro

vi <file>

opens <file> for editing. Type "ZZ" to save and exit.

command mode vs insert mode

You start out in command mode. Type "i" (insert) or "a" (append) to get to insert mode. Esc to get back to command mode.

moving the cursor

h  left
j  down
k  up
l  right

modifying text

x  delete
i  insert
a  append
Y  yank/copy line
D  cut line
P  paste line

deleting text

x  deletes the character under the cursor.
X  deletes the character to the left of your cursor.
dw deletes from the character selected to the end of the word.
dd deletes all the current line.
D  deletes from the current character to the end of the line.