Vim tip 20: character based motions within the current line
These commands allow you to move based on a single character search, within the current line only.
- f( move forward to the next occurrence of character
( - fb move forward to the next occurrence of character
b - 3f" move forward to the third occurrence of character
" - t; move forward to the character just before
; - 3tx move forward to the character just before the third occurrence of character
x - Fa move backward to the character
a - Ta move backward to the character just after
a - ; repeat previous
forFortorTmotion in the same direction - , repeat previous
forFortorTmotion in the opposite direction- for example, tc becomes Tc and vice versa
Note that the previously used count prefix wouldn't be repeated with ; or , commands, but you can use a new count prefix. If you pressed a wrong motion command, use the Esc key to abandon the search instead of continuing with the wrongly chosen command.
Video demo:
See also my Vim Reference Guide and curated list of resources for Vim.