Vim’s movement model is one of its strongest advantages—when used intentionally.
This guide compiles techniques that are especially valuable in day-to-day development: jumping across locations, navigating within code, and controlling how your screen follows your cursor.
Table of Contents
Jump
Jumping is about teleporting: moving to a meaningful location with minimal keystrokes—often across large distances in a file or across navigation history.
Jump by percentage of file
When working with large files, line numbers are not always the most convenient reference point. Vim allows you to jump to an approximate location using percentages.
TIP: Jump to the middle of the file
50%
TIP: Jump to the Nth portion of the file
N%
-
Ncan range from 1 to 100 - Example: jump near the end of the file:
90%
This is useful for quickly scanning large source files, logs, or generated output.
Return to last edit location
It is common to search, inspect code in different places, and then return to the place you were actively editing.
TIP: Go to the last edited location (and enter INSERT mode)
gi
TIP: Go to the last edited location (remain in NORMAL mode)
`^
This is especially useful after:
- searching (
/pattern) - jumping between functions or blocks
- exploring a file during debugging
Navigate jump history (Ctrl+O / Ctrl+I)
Vim maintains a jump list—a history of significant cursor moves. This makes it easy to move backward and forward through where you’ve been.
TIP: Jump backward in history
Ctrl+O
TIP: Jump forward in history
Ctrl+I
This is highly effective after:
- repeated searching (
/pattern) - jumping around during refactors
- navigating between distant sections of a file
Jump to the Nth character
For character-precise positioning (common in configs, logs, or long content), Vim supports direct character offsets across the file.
TIP: Jump to the Nth character from the start of the file
:gotoN
Example: jump to the 25th character in the file:
:goto25
TIP: Jump forward N characters from the cursor
N<space>
Example: move forward 200 characters:
200<space>
TIP: Jump backward N characters from the cursor
N<Backspace>
Example: move backward 300 characters:
300<Backspace>
Navigate
Navigation is about controlled movement: staying oriented while moving inside code with precision and minimal scrolling.
Screen positioning commands
Cursor movement is not always enough—screen positioning improves readability and reduces unnecessary scrolling.
TIP: Center/top/bottom the screen on the cursor
zz " Center the screen on the cursor
zt " Place the cursor line at the top of the window
zb " Place the cursor line at the bottom of the window
Alternative equivalents
z. " Center the screen on the cursor
z<ENTER> " Place the cursor line at the top of the window
z- " Place the cursor line at the bottom of the window
These commands are particularly useful when reviewing dense code or maintaining context during debugging.
Start/end of line: physical vs screen line
Vim distinguishes between physical lines (newline-delimited lines in the file) and screen lines (how lines appear when wrapped in the editor window). This distinction matters when working with long lines.
TIP: Navigate to the end of a line
$ " End of the physical line (NORMAL mode)
g_ " Last non-whitespace character of the physical line (NORMAL mode)
A " End of the physical line and enter INSERT mode
TIP: Navigate to the start of a line (first non-whitespace)
^ " First non-whitespace character (NORMAL mode)
I " First non-whitespace character and enter INSERT mode
TIP: Navigate to the absolute start (column 0)
0 " Column 0 (NORMAL mode)
0i " Column 0 and enter INSERT mode
Physical line vs screen line navigation
$ and 0 " End/beginning of the physical line
g$ and g0 " End/beginning of the screen line (wrapped)
For long lines, g0 and g$ are often more accurate than 0 and $.
Navigate blocks
When working in brace-heavy codebases, jumping by structure is often faster than scrolling.
TIP: Jump to the start of the previous { block
[m
Navigate comments
For documentation-heavy files or legacy codebases, comment navigation can reduce scanning time.
TIP: Place cursor to previous start of a C comment
[/
Window-relative navigation (H, M, L)
Window-relative navigation allows you to move inside the visible portion of the file without scrolling.
TIP: Jump within the current window
H " Top of the window
M " Middle of the window
L " Bottom of the window
You can also provide a count:
10H " Move to 10 lines below the top of the window
3L " Move to 3 lines above the bottom of the window
Summary:
H Go to top of screen
M Go to middle of screen
L Go to bottom of screen
nH Go n lines from top
nL Go n lines from bottom
Refine search without leaving the prompt
When iterating on search patterns, you can refine without immediately executing the search.
TIP: Stay in search mode after entering a pattern
Instead of pressing Enter, use:
Ctrl-gCtrl-t
This keeps you in the search prompt so you can refine the pattern efficiently.
Conclusion
Efficient Vim movement is not about memorizing every command—it is about adopting a small set of high-value techniques and using them consistently.
A practical approach:
- Select 3–5 commands from this post
- Use them daily for one week
- Add more only when the current set becomes automatic
Top comments (0)