Cursor Movement
h,j,k,l
ctrl-f = page up
ctrl-b = page down
% = jump to matching brace
w = jump to end of words (punctuation)
W = jump by words
e = jump to end of words (punctuation)
E = jump to end of words
b = jump backward by words (punctuation)
B = jump backward by words
0 = start of line
^ = first character of line
$ = end of line
gg = go to first line
gd = go to def of the function or var under the cursor
[N]G = go to line N or last line
fx = move the cursor forward to the next occurrence of character x on the current line
; = repeat last f command
tx = like fx but move right before the character
Fx = move the cursor backwards to the next occurrence of x
) ,(= move the cursor to next, previous sentence
* = Read the string under the cursor and go to next occurrence
# = same as * but goes to previous occurrence
`. = Go to line last edited
Screenwise
H = move the cursor to the Highest line on the screen
M = move the cursor to the Middle of the screen
L = move the cursor to the Lowest line of the screen
Bookmarks
ma = Make a bookmark name a at the current cursor position
`a = Go to bookmark a (backtick, not single quote)
Insert Mode
i = insert mode at cursor
I = insert at the beginning of line
a = append after the cursor
A = append at the end of the line
o = open blank line below current line
O = open blank line above current line
Esc = exit insert mode
Completions (type a few chars then)
ctrl-n = next completion
ctrl-p = previous completion
Editing
r = replace a single character (!insert mode)
J = join line below to the current line
cc = change an entire line
cw = change to the end of word
c$ = change to the end of line
s = delete character at cursor and
substitute text
S = delete line at cursor and substitute text
xp = transpose to letters
u = undo
ctrl-r = redo
. = repeat last command
~ = switch case
g~iw = switch case of current word
gUiw = make current word uppercase
guiw = make current word lowercase
>> = indent line one column right
<< = indent line one column left
== = auto-indent current line
Cut and Paste
dd = delete (cut) a line
dw = delete the current word
x = delete current character
X = delete previous character
D = delete to end of line
yy = yank (copy a line)
2yy = yank (copy) 2 lines
yw = yank word
y$ = yank to end of line
p = put the clipboard after cursor/current line
P = put the clipboard before the cursor/current line
]p = put the clipboard at the proper indentation
"a = use a register named a for the next yank/paste operation
Visual Mode
Marking Text
v = start visual mode
V = start linewise visual mode
ctrl-v = start blockwise visual mode
o = move to other end of marked area
U = upper case of marked area
O = move to Other corner of block
aw = mark a word
ab = a block with parens (braces)
aB = a block with brackets (curly braces)
ib = inner () block
iB =inner {} block
Commands
> = shift right
< = shift left
y = yank
d = delete
~ = switch case
Search/Replace
/pattern = search for pattern
?pattern = search backwards for pattern
n = repeat search in same direction
N = repeat search in opposite direction
:s/old/new/g = replace all old
throughout file
:s/old/new/gc = replace all old with
new and confirm each one
Exiting
:w = save
:wq = save and quit
:x = save and quit
:q = quit, but failed if unsaved
:q! = quit
Multi-File
:e filename = edit a file in a new bu!er
:bn = go to next bu!er
:bd = delete a bu!er (close file)
:sp fn = open a file in new bu!er and split window
ctrl w - window commands
ctrl-w s = split window
ctrl-w w = switch windows
ctrl-w q = quit a window
ctrl-w v = split windows vertically
Tab Commands
:tabe fn = edit file in new tab
gt = next tab
gT = previous tabs
:tabr = First tab
:tabl = Last tab
:tabm [N] = move current tab after tab N
Macros
qa = start recording a macro in register a
q = end recording
@a = replay macro in register a
Vim Commands and Shortcuts
By: Joe Martinez
http://jrmiii.com
@capitalist