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

How do I repeat the last f/t/F/T motion in the opposite direction?

Answer

,

Explanation

After using f, t, F, or T for single-character motion on a line, Vim lets you repeat that character search without retyping the target. Most users know ; repeats in the same direction. The less-used companion is ,, which repeats the same character search in the opposite direction. This makes local line navigation much faster in dense code.

How it works

  • f{char} and t{char} search forward on the current line
  • F{char} and T{char} search backward on the current line
  • ; repeats the previous find in the same direction
  • , repeats it in the opposite direction

Because , reuses the last find target, it is ideal for bouncing between nearby delimiters or arguments while staying in Normal mode.

Example

Given:

call(first_arg, second_arg, third_arg)

Place the cursor near the start and press:

f,

Now ; jumps to the next comma, while , jumps back to the previous comma.

Tips

  • Use counts with repeats, e.g. 2; or 2,
  • This works with t/T motions too, not just f/F
  • Great for quick edits inside long argument lists without invoking search mode

Next

How do I store the current file path in a named Vim register?