Introduction

This Vim commands cheat sheet also includes commands and shortcuts for Vimium & Nerdtree.

Cursor movement

CommandExplanation
hLeft
jDown
kUp
lRight
wJump by start of words (punctuation considered words)
WJump by words (spaces separate words)
eJump to end of words (punctuation considered words)
EJump to end of words (no punctuation)
bJump backward by words (punctuation considered words)
BJump backward by words (no punctuation)
geJump 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
ggGo to first line
GGo to last line
nGGo to line n
:nGo 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 {
HTo the top of the screen
MTo the middle of the screen
LTo the bottom of the screen
fxSearch line forward for 'x'
FxSearch line backward for 'x'
txSearch line forward before 'x'
TxSearch line backward before 'x'

Bookmarks

CommandExplanation
:marksList all the current marks
maMake a bookmark named a at the current cursor position
`aGo to position of bookmark a
'aGo to the line with bookmark a
`.Go to the line that you last edited

Insert mode

CommandExplanation
iStart insert mode at cursor
IInsert at the beginning of the line
aAppend after the cursor
AAppend at the end of the line
oOpen (append) blank line below current line
OOpen blank line above current line
<Esc>Exit insert mode

Editing

CommandExplanation
rReplace a single character (does not use insert mode)
RReplace characters rather than inserting
JJoin line below to the current one
ccChange (replace) an entire line
cwChange (replace) to the end of word
c$Change (replace) to the end of line
sDelete character at cursor and substitute text
SDelete line at cursor and substitute text (same as cc)
xpTranspose two letters (delete and paste, technically)
uUndo
CTRL-rRedo
.Repeat last command
~Switch case
g~iwSwitch case of current word
gUiwMake current word uppercase
guiwMake current word lowercase
gU$Make uppercase until end of line
gu$Make lowercase until end of line
:%retabFix spaces / tabs issues in whole file
:%s/pattern/replace/gSearch and replace
:bufdo %s/pattern/replace/gSearch 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

CommandExplanation
CTRL-fForward by a screen of text
CTRL-bBackward by a screen of text
CTRL-uUp by half a screen
CTRL-dDown by half a screen

Links

Permalink: https://hanez.org/document/vim-cheat-sheet/