Vim provides the
T command to jump forward or backward to a character in current line, and you can repeat the action by pressing
;. While these commands are useful, they are not powerful enough to be of real value:
- The movement is restricted to current line.
- There are possibly many repetitions since you can only provide one character.
vim-sneak solves these two issues neatly. With vim-sneak, you can go anywhere your eyes can see in just four key strokes in most cases, which is one of the most amazing plugins I have ever seen.
After installing this plugin, add the following minimal settings to your configuration:
let g:sneak#label = 1
nmap f <Plug>Sneak_s
nmap F <Plug>Sneak_S
The above settings will map
F to search forward and backward respectively and use the sneak label mode.
For example, if you want to go to the character
i which is followed by
m, first press
f, then press
im, all occurrences of im will be highlighted and given a label.
Press the character in a label, the cursor will jump to that location, which is really amazing.
Another similar vim plugin is vim-easymotion.
Ref: precise cursor movement in vim.