navigation
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.
<C-d> <C-u> (normal mode) Variations
| Keystroke | Effect |
|---|---|
| <C-f> | Full page down (like PgDn) |
| <C-b> | Full page up (like PgUp) |
| <C-e> | Scroll one line down WITHOUT moving cursor |
| <C-y> | Scroll one line up without moving cursor |
Examples
<C-d> Move down half a screen
<C-u> Move up half a screen
10<C-d> Set scroll amount to 10 lines and scroll down
Gotcha
Passing a count (10
Related
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.
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.
Ctrl-W
Ctrl-W is the prefix for every window-management command. Follow it with h/j/k/l to move between splits, with =/_/| to resize, or with c/o to close windows.
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.
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.