A cheatsheet for Vim motions.
:%s/foo/bar/g |
Replace whole file
|
:%s/\<cat\>/dog/g |
Whole word
|
|
(empty)
|
Current line
|
% |
Entire file
|
.,$ |
Current line to end of file
|
10,20 |
Line 10 to line 20
|
, == "to". == "current line"$ == "end of file"
g |
Replace all occurrences in given range
|
c |
Ask for confirmation
|
i |
Ignore case
|
I |
Case sensitive
|
n |
Print count only, does not make any changes
|
q {register} |
Record to register
{register} |
q |
Stop recording
|
@{register} |
Play macro
|
5j@a is valid
j |
Down 1 line
|
k |
Up 1 line
|
10j |
Down 10 lines
|
10k |
Up 10 lines
|
Ctrl-d |
Half-page down
|
Ctrl-u |
Half-page up
|
H |
Go to top of the current screen (High)
|
L |
Go to bottom of the current screen (Low)
|
M |
Go to middle of the current screen (Middle)
|
|
{
|
Jump to the previous paragraph/block
|
|
}
|
Jump to the next paragraph/block
|
I |
Insert at start of line
|
A |
Append at end of line |
o |
New line below
|
O |
New line above
|
gg |
Go to first line (top of file)
|
G |
Go to last line (bottom of file)
|
123G or :123 |
Go to line 123
|
h |
Move left 1 character
|
l |
Move right 1 character
|
w |
Start of next word
|
b |
Start of previous word (Back)
|
e |
End of current/next word
|
W |
Next WORD
|
B |
Previous WORD
|
E |
End of WORD
|
some_var=value, path/to/file, foo(bar) are all WORDS
0 |
Go to column 0 (absolute start of line)
|
^ |
Go to first non-blank of line
|
$ |
Go to end of line
|
f<char> |
Move to the next occurrence of
<char> |
F<char> |
Move to the previous occurrence of
<char> |
t<char> |
Move before the next occurrence
|
T<char> |
Move before the previous occurrence.
|
d |
Delete
|
c |
Change (delete + insert)
|
y |
Yank (copy)
|
~ |
Flip case
|
gu |
To lowercase
|
gU |
To uppercase
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.