Introduction
This Vim commands cheat sheet also includes commands and shortcuts for Vimium & Nerdtree.
Cursor movement
Command | Explanation |
---|
h | Left |
j | Down |
k | Up |
l | Right |
w | Jump by start of words (punctuation considered words) |
W | Jump by words (spaces separate words) |
e | Jump to end of words (punctuation considered words) |
E | Jump to end of words (no punctuation) |
b | Jump backward by words (punctuation considered words) |
B | Jump backward by words (no punctuation) |
ge | Jump backward to end of words |
0 | (zero) Start of line |
^ | First non-blank character of line |
$ | End of line |
- | Line upwards, on the first non blank character |
+ | Line downwards, on the first non blank character |
<enter> | Line downwards, on the first non blank character |
gg | Go to first line |
G | Go to last line |
nG | Go to line n |
:n | Go to line n |
) | Forward to the next sentence |
( | Backward by a sentence |
{ | A paragraph backwards |
} | A paragraph forwards |
]] | A section forwards or to the next { |
[[ | A section backwards or the previous { |
H | To the top of the screen |
M | To the middle of the screen |
L | To the bottom of the screen |
fx | Search line forward for 'x' |
Fx | Search line backward for 'x' |
tx | Search line forward before 'x' |
Tx | Search line backward before 'x' |
Bookmarks
Command | Explanation |
---|
:marks | List all the current marks |
|
ma | Make a bookmark named a at the current cursor position | `a | Go to position of bookmark a |
'a | Go to the line with bookmark a |
`. | Go to the line that you last edited |
Insert mode
Command | Explanation |
---|
i | Start insert mode at cursor |
I | Insert at the beginning of the line |
a | Append after the cursor |
A | Append at the end of the line |
o | Open (append) blank line below current line |
O | Open blank line above current line |
<Esc> | Exit insert mode |
Editing
Command | Explanation |
---|
r | Replace a single character (does not use insert mode) |
R | Replace characters rather than inserting |
J | Join line below to the current one |
cc | Change (replace) an entire line |
cw | Change (replace) to the end of word |
c$ | Change (replace) to the end of line |
s | Delete character at cursor and substitute text |
S | Delete line at cursor and substitute text (same as cc) |
xp | Transpose two letters (delete and paste, technically) |
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 |
gU$ | Make uppercase until end of line |
gu$ | Make lowercase until end of line |
:%retab | Fix spaces / tabs issues in whole file |
:%s/pattern/replace/g | Search and replace |
:bufdo %s/pattern/replace/g | Search and replace in multiple buffers |
:r [name] | Insert the file [name] below the cursor |
:r !{cmd} | Execute cmd & insert its standard output below cursor |
Scrolling
Command | Explanation |
---|
CTRL-f | Forward by a screen of text |
CTRL-b | Backward by a screen of text |
CTRL-u | Up by half a screen |
CTRL-d | Down by half a screen |
Links
Permalink: https://hanez.org/document/vim-cheat-sheet/