# vi commands
 switch to the COMMAND mode from INSERT mode


commands used to enter INSERT mode
i   - switch to insert mode, before curosr
I   - switch to insert mode, at beginning of current line
a   - switch to insert mode after cursor
A   - switch to insert mode at end of line

o   - start a new line of text after the current line
O   - start a new line of text before the currnet line

commands used in COMMAND mode
u   - undo do last entry
U   - undo changes on current line

d   - delete text
dd  - delete line
3dd - delete next three lines

y   - copy text, yank
yy  - copy line of text
2yy - copy next two lines of text

w   - move one word forward
dw  - delete word  from cursor to end of word
cw  - change word at cursor

!   - filter text through a program
<   - shift a region of text to the left
>   - shift a region of text to the right

h   - move cursor to the left one charcter
l   - move cursor to the right one character
j   - move the cursor down one character
k   - move the cursor up one character
^   - move the cursor to the beginning of the line
$   - move the cursor to the end of the line
nnG - move to nn line of text - ex. 1G to first line 50G to line 50
G   - move to last line of text
^CU -  U - move cursor up 12 lines
^CD - move cursor down 15 lines
w   - move cursor to next word, stopping at punctuation
W   - move to next word skipping punctuation
e   - move cursor to the end of the word, stopping at punctuation
E   - move to end of word, ignoring punctuation
b   - move cursor backwards to the previous word - stopping at punctuation
B   - move backwards to previous word, ignor punct
H   - move cursor to the top of the screen
M   - move cursor to the middel of the screen
L   - move cursor to the last line of the screen
%   - move cursor to the matching paren or brace
(   - move to beginning of previous sentence - a period and two spaces
)   - move to beginning of next sentence
{   - move to the beginning of current paragraph
}   - move to the  beginning of next paragraph

'   - move to a previously marked location in the file
      example mL marks the letter L and 'L would take you there
f   - find the next occurance of the character typed after the "f"
      on the current line only
F   - same as "f" but move  backwards

x- delete n characters starting under the cursor
r   - replace the character under the cursor with the next key typed
J   - join lines
R   - replace lines
p   - paste lines you yanked
.   - period, repeat last command

:r filename  - append file below cursor

^CL - redraw the screen

d$  - delete from cursor to end of line
d^  - delete excluding the current character
ndw - delete n words stopping at punctuation
ndW - delete n words ignoring punctuation
nde - delete to end of next word
ndd - delete n lines
dG  - delete from current line to end of document
dH  - delete to line shown at top of screen

search and replace, from the COMMAND mode

/abc - find next occurance of letters "abc"
?abc - find the previous letters abc
n    - repeats the last search command
d/abc- deletes the next occurance of letters abc

:g/oldword/s//newword/gc 
Find all occurances of oldword and replace with newword. The "c" at the end says
you want to confirm each change - y for yes and n for no.

 :wq  - go to command mode, write file to disk and quit vi
 :q!  - quit and don't save