Please let me know how you get on, also let me know if you have improvements, the idea should be that it would fit onto an A4 sheet. So anything added has to replace something else. I will come back to this page with updates from time to time.
Command Mode ESC Insert Mode i
Movement commands
h, j, k, l left, down, up, right
w, W, b, B forward, backward by word
H highest line of the screen
M middle line of the screen
L lowest line of the screen
Ctrl-F forward one screen
Ctrl-B backward one screen
Ctrl-D halfway down (i.e. forward) the screen
Ctrl-U halfway up (i.e. back) the screen
0 (zero), $ start, end of current line
Inserting text
a append after cursor
i insert before cursor
A append to end of line
I insert at start of line
o open a line below current line
O open a line above current line
r replace char
Delete text
x current character
dh previous character
dw current word
db previous word
dd entire line
d$ to end of line
d0 (zero) to start of line
ndd next n lines
Undelete
p insert after cursor
P insert before cursor
Goto line
:linenumber
nG Goto line n
:7 Goto line 7
Save and exit
ZZ write if changes and quit
:wq write and quit
:w filename save to new file
:q! quit vi
Search
/pattern forward for a pattern
?pattern backward for a pattern
n repeat previous search
N repeat previous search in reverse direction
*Search and replace
Example:
- Search from current line and replace first occurance
:s/search_string/replace_string/
- Search from current line and replace all matches
:s/search_string/replace_string/g
- Search from every line, replace confirmation (with [y]es)
:%s/search_string/replace_string/gc
:1,$s/search_string/replace_string/gc
- Search lines from 10 to 20
:10,20s/search_string/replace_string/g
Undo
u the latest change
U all changes on a line
Concatenate
J concatenate two lines
<p>There is a great post by a Command Line Warrior about Vi, I put a print out
on my wall next to my pc.</p>
<p>Not to slight your efforts, but I found this to be much better and printable
<a class="reference external" href="http://www.digilife.be/quickreferences/QRC/Vi%20Reference%20Card">http://www.digilife.be/quickreferences/QRC/Vi%20Reference%20Card</a></p>
<p>Of course, credit goes to <a class="reference external" href="http://www.digilife.be/quickreferences/indexe.html">http://www.digilife.be/quickreferences/indexe.html</a>.</p>