Command | Meaning |
---|---|
:q |
quit |
:w |
save |
:w <filename> |
save as <filename> |
:w! |
force save |
:help <topic> |
get help on <topic> |
:e <filename> |
open the file given by <filename> |
<esc> |
enter Command Mode |
i |
enter Insertion Mode (functions like a normal editor) |
u |
undo |
ctrl+r |
redo |
Command | Meaning |
---|---|
h, j, k, l |
left, down, up, right |
w |
bring cursor to start of next word |
W |
bring cursor to start of next WORD |
e |
bring cursor to end of this word/next word |
E |
bring cursor to end of this WORD/next WORD |
b |
bring cursor to start of this word/previous word |
B |
bring cursor to start of this WORD/previous WORD |
x |
delete the character under the cursor (essentially, delete forwards) |
s |
delete the character under the cursor and enter Insertion Mode |
r<char> |
replace the character under the cursor with <char> |
R |
enter Replace Mode (like the Insert key) |
c |
enter the "submode" for changing (basically, deleting and entering Insertion Mode) |
C |
change to end of line (basically, delete to end of line and enter Insertion Mode) |
d |
enter the "submode" for deleting/cutting |
D |
delete to end of line |
y |
enter the "submode" for yanking/copying |
p |
paste (by default, from the first register) |
"<char>p |
paste from register number <char> |
"<shift+char> |
append to the register given by name <char> |
:reg |
list contents of all registers |
. |
repeat the last change |
<esc> |
enter Command Mode |
i |
enter Insertion Mode to the left of the cursor/on the cursor |
I |
enter Insertion Mode right before the first non-whitespace character of the line |
a |
enter Insertion Mode to the right of the cursor |
A |
enter Insertion Mode at the end of the line |
O |
insert line above |
o |
insert line below |
J |
join selected lines together (replacing newline with a single space) |
Command | Meaning |
---|---|
v |
enter Visual Mode (character) |
V |
enter Visual Mode (line) |
ctrl+v |
enter Visual Block Mode |
ggVG |
select all |
Command | Meaning |
---|---|
gg |
bring cursor to first line of file |
G |
bring cursor to last line of file |
<num>G |
bring cursor to line number <num> |
^f |
move forward through the buffer (PageDown) |
^b |
move backwards through the buffer (PageUp) |
^o |
move cursor to a previous position |
^i |
move cursor to a more-recent position |
{ |
bring cursor to start of code block/next block |
} |
bring cursor to end of code block/previous block |
0 |
bring cursor to the first character of the line |
^ |
bring cursor to the first non-whitespace character of the line |
$ |
bring cursor to the last character of the line |
<num>` |
bring cursor to column number <num> of the line |
f<char> |
bring cursor to the next occurrence of <char> |
F<char> |
bring cursor to the previous occurrence of <char> |
t<char> |
bring the cursor to the character before the next occurrence of <char> |
T<char> |
bring the cursor to the character before the previous occurrence of <char> |
; |
repeat the last f/F/t/T command |
, |
repeat the last f/F/t/T command reversed |
# |
bring cursor to previous occurrence of word under cursor |
* |
bring cursor to next occurrence of word under cursor |
% |
bring cursor to matching delimiter (e.g. paren, brace) |
vat + o |
highlight around tag and jump to matching |
/<term> |
search the file forwards for an occurrence of <term> |
?<term> |
search the file backwards for an occurrence of <term> |
n |
continue last search |
N |
continue last search in opposite direction |
Command | Meaning |
---|---|
3w |
Jump forward three words |
3dw |
Delete the next three words |
10. |
Repeat the last command 10 times |
5fx |
Jump to the fifth-next occurrence of the letter ‘x’ |
de |
Delete to end of word |
yy |
Yank entire line |
ciw |
Delete current word and drop into Insert mode |
dip |
Delete current paragraph |
vip |
Select current paragraph |
va( |
Select inside parens (including parens) |
dat |
Delete HTML tag |
Command | Meaning |
---|---|
m<char> |
create a mark with name <char> |
`<char> |
bring the cursor to the exact location where mark <char> was set |
:marks |
list your marks |
q<char> |
start recording a macro, stored into register <char> |
q |
cease recording macro |
@<char> |
run the macro stored in register <char> |
`:earlier <[0-9]+(s | m |
`:later <[0-9]+(s | m |
Command | Meaning |
---|---|
:!pwd |
run pwd in the shell and see the result in Vim |
:r !pwd |
run pwd in the shell and paste the result into Vim |
:!sort |
run Unix sort on the selection |
:!rm % |
delete this file |
Command | Meaning |
---|---|
zf |
fold/collapse selected lines |
zo |
open/uncollapse fold at current line |
zc |
close/recollapse fold at current line |
zd |
delete fold at current line |
:tabe <filename> |
open the file given by <filename> in a new tab |
shift+h |
navigate to the tab on the left |
shift+l |
navigate to the tab on the right |
:new <filename> |
open the file given by <filename> in a horizontal pane |
ctrl+w |
enable pane navigation mode |
h, j, k, l |
move to pane in that direction |
Command | Meaning |
---|---|
<selection> -> u |
make the current selection to be all lowercase |
<selection> -> U |
make the current selection to be all uppercase |
~ |
toggle case |
= |
autoindent (only semi-reliable) |
<< |
shift line left by one indentation (defaults to four spaces) |
>> |
shift line right by one indentation |
^a |
increment the number under the cursor |
^x |
decrement the number under the cursor |
:X |
save and encrypt this file |
:jumps |
list all modifications that you've made to this file |