Can somebody explain to me what the f and t commands do in vim and exactly how they work? I can\'t seem to find this information but people keep telling me
Your first stop with questions like these should be vim's internal help, :h f
and :h t
. However, in this case, those entries are a bit cryptic without an example. Suppose we had this line (^
= cursor position):
The quick brown fox jumps over the lazy dog.
^
These commands find characters on a line. So fb
would place the cursor here:
The quick brown fox jumps over the lazy dog.
^
t
is like f
but places the cursor on the preceding character. So tb
would give you:
The quick brown fox jumps over the lazy dog.
^
You can remember these commands as f
ind and t
ill. Also, you can prepend the commands with a number to move to the nth occurrence of that character. For example, 3fb
would move to the third b to the right of the cursor. My example sentence only has one b though, so the cursor wouldn't move at all.