Published on

Introduction to VIM movements

Authors

Every developer I know who uses Vim went through the same phase: spending more time figuring out how to exit than actually editing. Then something clicked, and now they won't shut up about it.

This is the post I wish I had when I started. Just the movements, explained plainly.

Why bother?

Vim movements show up everywhere. Your terminal, VS Code (with the Vim extension), JetBrains IDEs, even the browser (with Vimium). Once you have the muscle memory, you carry it everywhere. The payoff compounds.

The other reason: keeping your hands on the home row. Every time you reach for the arrow keys or the mouse, you break your flow. Vim movements are designed so you never have to.

The modes

Vim has modes. This is the thing that trips people up first.

ModeHow to enterWhat it does
NormalEscNavigate and issue commands
InsertiType text like a normal editor
VisualvSelect text
Command:Run editor commands

You spend most of your time in Normal mode. That's the point, it's the default, not insert mode.

Basic movements

In Normal mode, h j k l replace the arrow keys:

h  ←  left
j  ↓  down
k  ↑  up
l  →  right

It feels wrong at first. Give it a week. The positioning is intentional, your right hand's home row.

Word movements

Character-by-character is slow. Word movements are where things start to feel fast:

w   move forward to the start of the next word
b   move backward to the start of the previous word
e   move forward to the end of the current word

Uppercase versions (W, B, E) do the same thing but treat anything separated by whitespace as a word, ignoring punctuation. Useful for jumping over things like some.method.call in one move.

Line movements

0   jump to the start of the line
^   jump to the first non-whitespace character
$   jump to the end of the line

^ is the one you'll actually use day-to-day. 0 sends you to column 1 including any indentation.

Jumping around the file

gg  go to the top of the file
G   go to the bottom of the file
{   jump up one paragraph (or code block)
}   jump down one paragraph (or code block)
Ctrl+d  scroll down half a page
Ctrl+u  scroll up half a page

{ and } are underrated. In code they jump between blank lines, which usually means jumping between functions or blocks.

Find on the line

f{char}   jump forward to the next occurrence of {char} on the current line
F{char}   jump backward
t{char}   jump to just before {char} (useful for deleting up to a delimiter)
;         repeat the last f/F/t/T movement
,         repeat it in the opposite direction

Example: f( jumps your cursor to the next opening parenthesis on the line. Combine with d to delete: df( deletes everything from the cursor up to and including (.

Counts

Most movements accept a count prefix. Type a number before the movement to repeat it:

5j    move down 5 lines
3w    jump forward 3 words
2}    jump down 2 paragraphs

You don't need to use counts constantly, but they're there when you need to move precisely without hammering a key.

Combining movements with operators

This is where Vim starts to feel like a language. Operators like d (delete), c (change), y (yank/copy) combine with any movement:

dw    delete to the start of the next word
d$    delete to the end of the line
yy    yank (copy) the whole line
cw    change (delete and enter insert mode) to the next word

The pattern is: operator + motion. Once you internalize it, you stop thinking about individual commands and start composing.

Getting started

Don't try to learn everything at once. Pick one layer at a time:

  1. This week: h j k l only, no arrow keys
  2. Next week: add w b e and 0 $ gg G
  3. After that: f t and counts

vimtutor is built into most systems, run it in your terminal. It takes about 30 minutes and covers the basics interactively. Worth doing once.

The first few days are slower than your normal workflow. That's expected. Push through it.