?

Log in

No account? Create an account

Previous Entry | Next Entry

Vim Tip: t/f/F/T

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

March 2016
S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728293031  

Tags

Powered by LiveJournal.com
Designed by Tiffany Chow