These precise jumps make operators like dt) and cf, quick and exact.
On the current line, f followed by a character jumps onto the next occurrence of that character, and t jumps till it (one position before). F and T do the same backwards.
;repeats the last f/t/F/T in the same direction,,in the opposite direction.- Counts work:
2f,jumps to the second comma.
They shine combined with operators. dt) deletes up to the closing parenthesis but keeps it; cf, changes up to and including the next comma; yT( yanks back to just after the opening parenthesis.
The % motion jumps to the matching bracket: on a ( it goes to the ) and back again. If the cursor is not on a bracket, it searches forward on the line for one first. d% on an opening brace deletes the whole block including the braces. (The bundled matchit plugin, enabled with :packadd matchit, extends % to if/endif and HTML tags.)
A good habit: look at where you want to land, pick a distinctive character next to it, and use f/t instead of tapping l or w several times. Tools like relativenumber help vertically; f and t are the horizontal equivalent.
Example
" line: total = compute(a, b, c) + offset
f( " cursor onto '('
; " (no further '(' : stays)
t) " cursor onto 'c', just before ')'
F, " back onto the ',' before c
dt) " from cursor delete up to, not including, ')'
% " on '(' -> jump to its matching ')'
d% " delete from bracket to its match, inclusiveRemember
- f lands on the character, t stops just before it
- ; repeats forward, , repeats backward
- % jumps between matching brackets
Watch out for
- Forgetting f/t only search the current line; use / to search across lines.