Vim: Moving Around Cheat Sheet

Basic motion commands

  k              <up>
h   l      <left>    <right>
  j             <down>
h<Left>[count] characters to the left (exclusive)
l<Right><Space>[count] characters to the right (exclusive)
k<Up>CTRL-P[count] lines upward
j<Down>CTRL-J<NL>CTRL-N[count] lines downward (linewise)
0<Home>To the first character of the line (exclusive)
^To the first non-blank character of the line
$<End>To the end of the line and [count – 1] lines downward
g0g<Home>To the first character of the screen line (exclusive) when lines wrap (‘wrap on). Differs from 0 when a line is wider than the screenTo the leftmost character of the current line that is on the screen when lines don’t wrap (‘wrap’ off). Differs from 0 when the first character of the line is not on the screen
g^To the first non-blank character of the screen line (exclusive) when lines wrap (‘wrap’ on). Differs from ^ when a line is wider than the screen.To the leftmost non-blank character of the current line that is on the screen when lines don’t wrap (‘wrap’ off). Differs from ^ when the first non-blank character of the line is not on the screen
g$g<End>To the last character of the screen line and [count – 1] screen lines downward (inclusive) when lines wrap (‘wrap’ on). Differs from $ when a line is wider than the screen.To the rightmost character of the current line that is visible on the screen when lines don’t wrap (‘wrap’ off). Differs from $ when the last character of the line is not on the screen or when a count is used
f{char}To [count]’th occurrence of {char} to the right. The cursor is placed on {char} (inclusive)
F{char}To the [count]’th occurrence of {char} to the left. The cursor is placed on {char} (inclusive)
t{char}Till before [count]’th occurrence of {char} to the right. The cursor is placed on the character left of {char} (inclusive)
T{char}Till after [count]’th occurrence of {char} to the left. The cursor is placed on the character right of {char} (inclusive)
;Repeat latest f, t, F or T [count] times
,Repeat latest f, t, F or T in opposite direction [count] times
- <minus>[count] lines upward, on the first non-blank character (linewise)
+CTRL-M<CR>[count] lines downward, on the first non-blank character (linewise)
_ <underscore>[count] – 1 lines downward, on the first non-blank character (linewise)
CTRL-EndGGoto line [count] on the first non-blank characterDefault: last line.
CTRL-HomeggGoto line [count] on the first non-blank characterDefault: first line.
SHIFT-Rightw[count] words forward
CTRL-RightW[count] WORDS forward
eForward to the end of word [count]
EForward to the end of WORD [count]
SHIFT-Leftb[count] words backward
CTRL-LeftB[count] WORDS backward
geBackward to the end of word [count]
gEBackward to the end of WORD [count]
HMove to the top of the screen
MMove to the middle of the screen
LMove to the bottom of the screen
zzScroll the line with the cursor to the center of the screen
ztScroll the line with the cursor to the top
zbScroll the line with the cursor to the bottom

The following commands move over words or WORDS.

A word consists of a sequence of letters, digits and underscores, or a sequence of other non-blank characters, separated with white space (spaces, tabs, <EOL>). This can be changed with the ‘iskeyword’ option.

A WORD consists of a sequence of non-blank characters, separated with white space. An empty line is also considered to be a word and a WORD.

([count] sentences backward
)[count] sentences forward
{[count] paragraphs backward
}[count] paragraphs forward
]][count] sections forward or to the next ‘{‘ in the first columnWhen used after an operator, then the ‘}’ in the first column.
][[count] sections forward or to the next ‘}’ in the first column
[[[count] sections backward or to the previous ‘{‘ in the first column
[][count] sections backward or to the previous ‘}’ in the first column

Leave a Reply

Your email address will not be published. Required fields are marked *