Moving Around in Vim

Man wearing sunglasses and black outfit inside a computer, flying over terminals with faces on them as Vim commands emanate from him.

Here’s a quick guide to help you learn how to move around in Vim.

The Memorization Aid column contains a tip on remembering the actions of the command.
The Count column tells you if you can modify the command with a Count. A Count is a way to trigger the command more than once (equal to the value of the Count). For example, the 5w command will jump five WORDs.

Movement Commands

Key

Count

Move Type

Action

Memorization Aid

0

Line

Go to first character of the line.

^

Line

Go to the first non-whitespace character of the line.

Similar symbol meaning in regex

$

Line

Go to the last character of the line.

Similar symbol meaning in regex

W

Words

Jump to the first character of the next WORD

WORD

w

Words

Jump to the first character of the next word

word

E

Words

Jump to the last character of the next WORD

End of WORD

e

Words

Jump to the last character of the next word

End of word

B

Words

Jump to the first character of the previous WORD

Back a WORD

b

Words

Jump to the first character of the previous word

Back up a word

gE

Words

Jump to the last character of the previous WORD.

Back up to the end of a WORD

ge

Words

Jump to the last character of the previous word.

Back up to the end of a word

f<char>Code language: HTML, XML (xml)

Line

Moves cursor on top of the next instance of the <char>. The <char> can be any character you can type in insert mode, including whitespaces.

Find the character forwards

F<char>Code language: HTML, XML (xml)

Line

Moves cursor on top of the previous instance of the <char>. The <char> can be any character you can type in insert mode, including whitespaces.

Find the character backwards

t<char>Code language: HTML, XML (xml)

Line

Moves cursor to one character before the next instance of the <char>. The <char> can be any character you can type in insert mode, including whitespaces.

UnTil the character forwards

T<char>Code language: HTML, XML (xml)

Line

Moves cursor to one character before the previous instance of the <char>. The <char> can be any character you can type in insert mode, including whitespaces.

UnTil the character backwards

)

Sentence

Jump to the first character of the next sentence.

In code, () contains parameters (like a sentence), and {} contains a large block of code (like a paragraph)

(

Sentence

Jump to the first character of the previous sentence

In code, () contains parameters (like a sentence), and {} contains a large block of code (like a paragraph)

}

Paragraph

Jump to next paragraph

In code, () contains parameters (like a sentence), and {} contains a large block of code (like a paragraph)

{

Paragraph

Jump to previous paragraph

In code, () contains parameters (like a sentence), and {} contains a large block of code (like a paragraph)

h

Character

Left

j

Character

Down

k

Character

Up

l

Character

Right

%

Matcher

Jump to the matching brace under the cursor (can be used on either opening or closing brace). Works on the following braces: { } [ ] ( ).

The percentage symbol is made of a slash and two matching circles, like two matching braces.

*

Matcher

Jumps to the next instance of the word. Uses the non-symbol word underneath the cursor. Otherwise it jumps to the next word if cursor is on whitespace or a symbol.

Symmetrical with # key on your keyboard if you think of the 1 and 0 keys as the boundaries.

#Code language: PHP (php)

Matcher

Jumps to the previous instance of the word. Uses the non-symbol word underneath the cursor. Otherwise it jumps to the next word if cursor is on whitespace or a symbol.

This symbol is sometimes called a “hash”. This finds a word like a hash function uses a “hash” to find a value. (It’s not perfect, but maybe you’ll remember this even better).

H

Cursor/Screen

Move cursor to the top of the screen.

Move to the HIGH point of the screen

M

Screen

Move cursor to the center of the screen.

Move to the MID point of the screen

L

Screen

Move cursor to the bottom of the screen.

Move to the LOW point of the screen

zz

Screen

Move screen to place cursor in the middle

Recenter the screen to my cursor

zt

Screen

Move screen to place cursor at the top

Recenter the screen so my cursor is at the TOP

zb

Screen

Move screen to place cursor at the bottom

Recenter the screen so my cursor is at the BOTTOM

,

Repeat

Repeat movement in same direction. If direction was backwards, this movement will go forwards.

It’s easy to jump back and forth with , and ;

;

Repeat

Repeat movement in same direction. If direction was backwards, this movement will also be backwards.

It’s easy to jump back and forth with , and ;



Leave a Reply

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