VI Quick Ref
Command Mode = esc
Cursor Control
h = left one character
b = left one word
0 = beginning of line (zero)
l = right one character
w = right one word
$ = to end of line
k = up one line
j = down one line
ctrl e = shift screen up one line
ctrl y = shift screen down one line
{{ = top of paragraph
}} = bottom of paragraph
ctrl u = up one page
ctrl d = down one page
ctrl f = forward one screen
ctrl b = back one screen
[[ = top of document
]] = end of document
ctrl g = display line number at cursor
39G = place cursor on specified line 39 or any other specified line
Copy / Yank
yy = copy line into buffer
3yy = copy three lines from cursor down into buffer
: x,xmx = copy lines from x through x and paste to line x
Paste
p = paste buffer to line below cursor (lower case)
P = paste buffer to line line above cursor (upper case)
. = repeat last command
Delete
x = delete character
4x = delete 4 characters to right of cursor
dw = delete word to right - put into temp buffer
shift d = delete to end of line - put into temp buffer
dd = delete line - put into buffer
4dd = delete four lines from cursor down - put into buffer
dG = delete to end of document including line at cursor - put into buffer
12dd = delete 12 lines from cursor down - put into buffer
. = repeat last command
Find
/string = find "string string" - search forward
?string = find "search string" - search backwards
n = forward to next match
N = backward to next match
Find and Replace
: %s/search string/replace string = find & replace first match
: %s/search string/replace string/g = find & replace globally
Find and Replace from line x to line x
: ma a = mark beginning
: ma b = mark end
: 'a,'b s/search string/replace string = find and replace from line 'a to 'b
Move
: x,xmx = move lines x through x and paste at line x
Replace
r = replace character at cursor
R = overwrite until done typing - end with (esc)
cw = change word at cursor - end with (esc)
Save
: w = write (save without quiting)
: wq = write and quit (save and quit)
: wq! = write, quit no matter what
: w "new-file-name" = save file as new file name
ZZ = save and exit vi
Quit
: q = quit
: q! = quit no matter what
Miscellaneous
u = undo last command
J = join line at cursor with next line
: set list = show hidden characters
Insert Mode
i = insert at cursor
a = insert to right of cursor
A = insert at end of line
shift o = insert line above cursor
o = insert line below cursor
esc = exit insert mode to command mode
Suggestions... Send to:
charly@skunk.net