How do I jump to any location on screen using a two-character search in Vim?
Answer
s{char}{char}
Explanation
The vim-sneak plugin by Justin Keyes provides a motion that lets you jump to any visible location by typing just two characters. It fills the gap between Vim's built-in f (which only searches for a single character on the current line) and / (which requires typing a full search pattern and pressing Enter). Sneak is fast, precise, and works across lines.
How it works
Press s followed by two characters to jump to the next occurrence of that two-character sequence:
s{char}{char} " jump forward to the next match
S{char}{char} " jump backward to the previous match
After the first jump, press ; to go to the next match and , to go to the previous match — just like Vim's built-in f and t repeat keys.
Example
Given this code with the cursor at the beginning of the line:
const result = calculateTotal(items, discount);
To jump to di in discount, press sdi. The cursor lands directly on the d. Pressing ; moves to the next occurrence of di in the file.
Why two characters?
A single-character search (like f) produces too many matches on any given screen. A full regex search (/) requires too many keystrokes. Two characters hit the sweet spot — they narrow the matches enough that you usually land exactly where you want in one or two jumps.
Sneak as an operator motion
Sneak works with operators, making it a powerful editing motion:
dzab " delete from cursor to the next occurrence of 'ab'
czab " change from cursor to 'ab'
yzab " yank from cursor to 'ab'
vzab " visually select from cursor to 'ab'
Note: when used with operators, sneak uses z instead of s to avoid conflicting with the built-in s (substitute) operator.
Label mode
Enable label mode for an EasyMotion-like experience where each match gets a unique label you can press to jump directly to it:
let g:sneak#label = 1
With label mode enabled, pressing sab highlights every occurrence of ab on screen with a letter label. Press the label character to jump directly to that match — no repeated ; presses needed.
Replacing f and t
Sneak can enhance Vim's built-in f, F, t, and T motions to work across lines (by default they only work on the current line):
map f <Plug>Sneak_f
map F <Plug>Sneak_F
map t <Plug>Sneak_t
map T <Plug>Sneak_T
Now fa jumps to the next a even if it is on a line below the cursor.
Useful configuration
let g:sneak#label = 1 " enable label mode for instant jumps
let g:sneak#use_ic_scs = 1 " case-insensitive matching (follows ignorecase/smartcase)
let g:sneak#s_next = 1 " press s again to go to the next match
Tips
- Sneak is intentionally minimal — under 400 lines of code — making it extremely reliable and fast
- For Neovim users, leap.nvim and flash.nvim are spiritual successors to vim-sneak with additional features like treesitter integration
- Sneak highlights the search target area and dims the rest of the screen, making matches visually obvious
- Works perfectly with
.repeat and vim-repeat — the full sneak motion plus any operator is repeatable - The
;and,repeat keys work identically to how they work withfandt, so the muscle memory transfers instantly