vimtricks.wiki Concise Vim tricks, one at a time.

How do I repeat or reverse inline character search with f, t, ; and , in Vim?

Answer

f{char} ; ,

Explanation

The f, F, t, and T motions search for a character on the current line. Combined with ; (repeat forward) and , (repeat backward), they become one of the fastest ways to navigate within a line — especially for jumping to specific punctuation or delimiters.

How it works

  • f{char} — move to next occurrence of {char} on the line
  • F{char} — move to previous occurrence
  • t{char} — move to just before the next occurrence ("till")
  • T{char} — move to just after the previous occurrence
  • ; — repeat the last f/F/t/T in the same direction
  • , — repeat in the opposite direction

Example

Line: def calculate(price, tax, discount):
Cursor at 'd':

f( → jumps to '('
f, → jumps to first ','
;  → jumps to second ','
,  → jumps back to first ','

Tips

  • Use with operators: dt) deletes everything until ), cf, changes up to and including ,
  • f and t are case-sensitive by default
  • For multi-line f/t, consider plugins like leap.nvim or vim-sneak
  • Count prefix works: 3f, jumps to the 3rd comma

Next

How do I return to normal mode from absolutely any mode in Vim?