vimtricks.wiki Concise Vim tricks, one at a time.

What is the difference between 0 and ^ for moving to the beginning of a line?

Answer

^ vs 0

Explanation

Vim has two distinct motions for moving to the start of a line: 0 goes to column 1 (the absolute start), while ^ goes to the first non-blank character. Understanding when to use each is key to efficient horizontal navigation in indented code.

How it works

  • 0 — move to column 1 (absolute beginning of line)
  • ^ — move to the first non-blank character
  • _ — same as ^ (alternative mapping)
  • With indented code, ^ is almost always what you want

Example

    function hello() {
0 → ^                   ^
|                       |
col 1                   ^ (first non-blank)

Tips

  • d^ deletes from cursor to the first non-blank — useful for changing indentation
  • d0 deletes from cursor to column 1 — removes all leading content
  • I enters insert mode at ^ position (first non-blank)
  • 0 then w is sometimes easier than ^ for muscle memory
  • Some users remap 0 to toggle between column 1 and first non-blank

Next

How do I return to normal mode from absolutely any mode in Vim?