The Vim pyramid
A visualization of motion commands of the Vim text editor in the shape of a pyramid. Vim's multitude of commands are kind of a language of its own, but memorizing at least some of them is a huge help for efficient text processing. The following Vim command pyramid can be printed on a single sheet of paper and serve as a memorization aid at your desk when learning Vim.
Vim motion commands
gg top
Ctrl+b previous screen1
[] end of previous C function
[* or [/ beginning of previous C comment
[[ beginning of C function
{ previous paragraph
( previous sentence
k previous line
0 beginning of line
^ first non-blank character
F
{char}
to previous {char}
characterT
{char}
till previous {char}
charactergE end of previous WORD2
B previous WORD2
ge end of previous word2
b previous word2
h previous character
l next character
e end of word2
w next word2
E end of WORD2
W next WORD2
t
{char}
till next {char}
characterf
{char}
to next {char}
characterg_ last non-blank character
$ end of line
j next line
) next sentence
} next paragraph
][ end of C function
]* or ]/ end of next C comment3
]] beginning of next C function
Ctrl+f next screen1
G bottom
1 Technically not a motion command, but also moves the cursor.
2 Assuming that cursor is at the middle of a word. Order differs if cursor is on first/last character.
3 Assuming multiline comments on top of each function.
Note that there are additional motion commands not shown in the pyramid, for example:
- To jump to a specific line number (e.g. 42), type 42G.
- You can type H, M, and L to get to the first, middle or last line currently visible on screen, respectively.
- + and - work like j and k, but they move to the first non-blank character of the line.
- The f, t, F, and T commands can be repeated using ;, or in the opposite direction using ,.
- % moves to matching paranthesis, or C comment, or C preprocessor conditional.
- When programming in C, there is also [# and ]# to move to the beginning, or end of a preprocessor block, respectively.
- When programming in Java or similar object-oriented languages, there are [M and [m to move to the end of previous Java method, and the beginning of Java method, respectively, as well as, ]M and ]m to move the end of Java method, and beginning of next Java method, respectively. These must not be confused with mark commands which also use the m key.
-
When lines wrap (i.e. the
wrap
option is set and there are lines longer than one screen width in the document), the additional commands g0, g^, gm, and gM are available.
You can find more information about these commands in the
motion.txt
chapter of the official Vim manual.
Run the :h motion.txt
command in Vim to open the chapter.
Side-by-side comparison
A side-by-side comparison of the commands from the pyramid in tabular form:
Level | Keys | Backwards or upwards motion | Keys | Forwards or downwards motion |
---|---|---|---|---|
1 | h | previous character | l | next character |
2 | b | previous word | w | next word |
3 | ge | end of previous word | e | end of word |
4 | B | previous WORD | W | next WORD |
5 | gE | end of previous WORD | E | end of WORD |
6 | T{char} | till previous {char} | t{char} | till next {char} character |
7 | F{char} | to previous {char} | f{char} | to next {char} character |
8 | ^ | first non-blank character | g_ | last non-blank character |
9 | 0 | beginning of line | $ | end of line |
10 | k | previous line | j | next line |
11 | ( | previous sentence | ) | next sentence |
12 | { | previous paragraph | } | next paragraph |
13 | [[ | beginning of C function | ][ | end of C function |
14 | [* a | beginning of previous C comment | ]* b | end of next C comment |
15 | [] | end of previous C function | ]] | beginning of next C function |
16 | Ctrl+b | previous screen | Ctrl+f | next screen |
17 | gg | top | G | bottom |
a or [/
b or ]/
Copyright © 2021 by Thomas Heller [ˈtoːmas ˈhɛlɐ]