VIM Reference / Cheat Sheet

  Command   Mnemonic   Description
.
Repeat the last command
h
Move left 1 char
j
Move down 1 line
k
Move up 1 line
l
Move right 1 char
w
word Move to the start of the next word
e
end Move to the end of the current word
^
Move to the start of the line
$
Move to the end of the line
gg
goto Move to the top of the file
G
goto Move to the bottom of the file
[number]G
goto Move to the specified line number
%
Move to the matching bracket
%
Move to the matching bracket
<CTRL-w>
window Switch to another window
<CTRL-w>s
window
split
Split the window horizontally
<CTRL-w>v
window
vertical
Split the window vertically
:ls
list List buffers
:w
write Write (or save) the current file
:w [filename]
write Write (or save) the current file as the specified filename
:wq
write Write (or save) the current file and quit
:q
quit Exit the editor
:q!
quit Exit the editor and discard changes
x
Delete the character under the cursor
i
insert Insert text before the cursor
I
insert Insert text at the start of the line
a
append Append text after the cursor
A
append Append text at the end of the current line
d[number]w
delete Delete N number of words
dw
delete Delete up to the next word
d$
delete Delete to the end of the line
de
delete Delete to the end of the current word
dd
delete Delete the current line
[number]dd
delete Delete N number of lines
[number]w
word Move the cursor N number of words forward
[number]e
end Move the cursor to the end of the Nth word
0
Move to the start of the line
$
Move to the end of the line
u
undo Undo the last command
U
undo Undo all changes on the current line
y
yank Yank (or copy) text
p
put Put (or paste) copied or deleted text after the cursor
r
replace Replace the character under the cursor
R
replace Enter replace mode
cw
change Change (or replace) the current word
c$
change Change (or replace) text to the end of the line
C
change Change (or replace) text to the end of the line
/[text]
Search forward for the text
?[text]
Search backward for the text
%
Find the matching brace (or bracket)
s
substitute Substitute (or replace) the current character and remain in insert mode.
S
substitute Substitute (or replace) the current line from the start of the line.
:s/[old]/[new]/
substitue Substitue (or replace) first occurence of 'old' with 'new' on line
:s/[old]/[new]/g
substitue Substitue (or replace) all occurences of 'old' with 'new' on line
:%s/[old]/[new]/
substitue Substitue (or replace) first occurence of 'old' with 'new' in file
:%s/[old]/[new]/g
substitue Substitue (or replace) all occurences of 'old' with 'new' in file
:[number],[number]s/[old]/g[new]/g
substitue Substitue (or replace) all occurences of 'old' with 'new' in between lines
n
next Find the next occurence of a search result
N
next Find the previous occurence of a search result
<CTRL-O>
Move to older result while navigating search results
<CTRL-I>
Move to newer result while navigating search results
:![command]
Execute an external command
:r [filename]
Read the specified file and put its contents below the cursor
:r !dir
Execute the dir command and put the results below the cursor
:v [motion] :w [filename]
visual
write
Save the visually selected lines to the specified filename
o
open Open a line below the cursor and switch to insert mode.
O
open Open a line above the cursor and switch to insert mode.
:set [option]
Set an option
:set hls
Turn on search highlighting
:set nohls
Turn off search highlighting
:h
help Open VIM's built in help
:h [text]
help Search VIM's built in help for specific answers (i.e. :h w)
f[char]
find Find the next occurrence of char
;
Move to the next target or match (i.e. after an f[char] find)
&
Repeat a search/replace operation on the next match
*
Search for the word under the cursor
:b[number]
buffer Load a buffer into the current window
:bd[number]
buffer Delete a buffer
<CTRL-w>J
Move the active pane to the bottom
<CTRL-w>L
Move the active pane to the far right





comments powered by Disqus


Copyright © 2008-2013 Hopsoft