Basic Motions

In Vim, you rarely use the arrow keys. Instead, you use keys that are right under your fingertips on the home row.

[!NOTE] This section explores the core principles and derivations related to this topic.

1. Character Navigation: h j k l

This is the first hurdle for every Vim beginner. It feels weird at first, but it makes sense because you don’t have to move your hand to the arrow cluster.

  • h: Left
  • j: Down (Think “J” looks like a hook pointing down)
  • k: Up (Think “K” is a king standing tall / upwards)
  • l: Right

[!TIP] Pro Tip: Disable your arrow keys. It’s the only way to learn. Force yourself to use hjkl.

[!NOTE] The Hardware Legacy: Why hjkl? Bill Joy created vi (Vim’s predecessor) on an ADM-3A terminal in 1976. That specific keyboard did not have dedicated arrow keys. Instead, the arrows were printed directly on the H, J, K, and L keys. This hardware constraint became a massive ergonomic advantage.

2. Word Navigation

Moving character by character is slow. Vim lets you move by words.

  • w: Move to the start of the next word.
  • b: Move to the start of the back (previous) word.
  • e: Move to the end of the current word.

These are much faster than holding down an arrow key.

Word vs. WORD

Vim distinguishes between a lowercase word and an uppercase WORD. This is a crucial distinction based on how text is tokenized:

  • A word (lowercase w, b, e) consists of a sequence of letters, digits, and underscores, OR a sequence of other non-blank characters (like punctuation). It stops at punctuation.
  • A WORD (uppercase W, B, E) consists of a sequence of non-blank characters. It only stops at whitespace.

If your cursor is on the c in console.log("hello");, pressing w will jump to the ., then the l, then the (, then the ", and so on. Pressing W will jump all the way to the next space (or next line).

3. Line Navigation

Jump to the extremes of a line.

  • 0 (Zero): Jump to the start of the line (column 0).
  • ^ (Caret): Jump to the first non-blank character of the line (useful for indented code).
  • $ (Dollar): Jump to the end of the line.

4. Interactive: Vim Navigator

Practice your motions. Move the highlighted cursor to the Target using h, j, k, l, w, b, e.

Target: Reach the highlighted character. (Click to focus)

5. Motion Heatmap

h Left j Down k Up l Right

6. Summary & Cheat Sheet

Here is a quick reference cheat sheet for the motions covered in this chapter:

Keystroke Action
h Move Left
j Move Down
k Move Up
l Move Right
w Move to start of next word
b Move to start of previous word
e Move to end of current word
0 Jump to start of line
^ Jump to first non-blank character of line
$ Jump to end of line
  • hjkl: The core navigation keys. Use them until they become second nature.
  • w / b: Move faster by jumping words.
  • 0 / $: Jump to start/end of line.