Home

Vim Tip: t/f/F/T

  • Feb. 1st, 2007 at 8:55 PM
EvilPHish evil fish shlomi fish

Third Vim tip in a row on this blog (must be a record for me) and this time a blast from the past. Well, at least something I learned a long time ago, but many people are not aware of.

By using the "f" command and then a character one can move to the next occurence of that character on the same line. So "ts" will move to the next occurence of the letter "s". "t" is the same except it moves to the character before that. "F" and "T" are for moving backwards. You can specify an optional count for jumping to the N'th occurence in the same line.

This for example is useful for quickly selecting tokens. If for example, you have a C-style string delimited by double-quotes, you can position your character to its start using the "f" command and then right (The right arrow key or "l"), and then select up to the end of the string using yt" , or alternatively replace it with something else using ct". Alternatively, one can select the string including the quotes, by positioning the cursor at the opening quote and typing yf".

For more information consult :help f.

Latest Month

August 2008
S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
31      

Tags