| $ vi [filename] - start
vi |
:wq - write file and quit
|
:q! - quit without saving |
| U - undoes all edits on 1 line |
u - undo |
^L - redraw the screen |
| i - insert text / Esc to exit insert mode |
a - append text |
c - change text |
| cw - change word (del & then insert) |
cc - change entire line |
C - from cursor to eol |
| r - replace a single letter & stay in com. mode |
rW - replace a word |
R - overstrike mode for 1 line |
| ~ - change the case of a letter |
x - delete single character |
50i* - inserts 50 asterisks |
| dw - delete word |
dd - delete entire line |
d$ or D - del to end of line |
| p - put deleted text after or below cursor |
P - put above |
yw, y$, yy, 4yy - yank (copy) |
| a7yy - yank 7 lines to buffer a |
fyy - yank curr. line to buf-f |
fp - put buffer f after cursor |
| h, j, k, l - move cursor 1 space |
4l - move cursor 4 to right |
4k - move cursor up 4 lines |
| 0 - move to beginning of line (zero) |
$ - move to end of line |
w - move cursor forward 1 word |
| W - move cursor forward, ignore punct. |
b - backward by word |
B - by word ignore punct. |
| ^f, ^b, ^d, ^ u- scroll by screen |
|
:44 - goto line 44 |
| H - move cursor to top |
M - move cursor to middle |
L - move cursor to last line scrn |
| z <Enter> - move current line to top of screen |
z. - move cur. line to center |
z- - move cur. line to bottom |
| ( - move to beginning of current sentence |
) - beginning of next sent. |
d) - deletes to end of current sent. |
| { - beginning of current paragraph |
} - beginning of next par. |
2y} - yanks 2 paragraphs ahead |
| 44G - goto beginning of line 44 |
^G - reports total lines |
d?move - del back through move |
| /pattern - searches forward for a match |
?pattn - search backward |
/,?,n,N - next match |
| :50,100s/old/new/g - change old to new |
:1,$s/old/new/g - all lines |
:1,30s/his/the/gc - with confirm |
| :!date - execute UNIX command |
:sh - start new shell (ctrl-D) |
:r newfile - reads file into your file |
| :ab - list abbreviations |
:ab abbr phrase - add abbr. |
:unab abbr - remove abbr. |
| :set autoindent - turns on indenting |
ctrl-T - add indent |
ctrl-D - take indent away |
| :set shiftwidth=4 |
5>> - shift 5 lines right |
<< - shift line left |
| :set nu - set line numbers on |
:set nonu |
|
| J - joins 2 lines into 1 |
% - find matching bracket |
. - repeats last command |
| $ vi file1 file2 - edit
multiple files |
:e filename - edit another file |
:w - write current file |
| :n - show next file |
^^ - switch back to prev. file |
:args - shows files open |
| :split [filename] - create a new window |
^w^w - switch between win |
^w=, ^w-, ^w+ - resize wins |
| :help - start help system |
:] - follow help reference |
^T - back to prev. reference |