navigation
0 / $
0 jumps to the very first column of the line; $ jumps to the last character. Use ^ (bonus) if you want the first non-blank character instead of column zero.
0 $ (normal / visual mode) Variations
| Keystroke | Effect |
|---|---|
| ^ | First NON-BLANK character on line (respects indentation) |
| g_ | Last non-blank character (skips trailing whitespace) |
| d$ | Delete from cursor to end of line (same as D) |
| y0 | Yank from cursor back to start of line |
Examples
0 Jump to column 1 of current line
$ Jump to end of line
c$ Change from cursor to end of line
Gotcha
0 takes no count — it always goes to column zero. $ with a count uses [count-1] as the offset — 2$ moves to the end of the NEXT line, not two lines down, which surprises most people.
Related
h j k l
The four fundamental cursor keys in Vim: h moves left, j down, k up, l right. Reach for them any time you would instinctively hit an arrow key — keeping your hands on the home row is the whole point.
w / b / e
Word motions: w jumps to the start of the next word, b to the start of the previous word, e to the end of the current/next word. These are the fastest way to hop across a line without leaving the home row.
gg / G
gg jumps to the first line of the file; G jumps to the last line. Prefix G with a number to jump to that absolute line — the fastest way to reach a specific line from a stack trace.
%
In normal mode, % jumps between matching pairs of (), [], {}, and (with matchit) HTML/XML tags. Indispensable for navigating nested code and confirming that a stray brace really does close where you think it does.
Ctrl-D / Ctrl-U
Ctrl-D scrolls the view (and cursor) half a screen down; Ctrl-U scrolls half a screen up. Faster than jkjk when skimming a long file, and the cursor stays in a predictable place on screen.