Niloct
Niloct

Reputation: 9995

Moving cursor with t and f, using word as parameter, vim

Is it possible in vim to move forward with t and f (or in the other way with T and F), but using words as a parameter ?

Upvotes: 6

Views: 880

Answers (3)

sehe
sehe

Reputation: 392833

What about /word?

It can be combined with operators just like anything else:

the lazy cow jumped over the high moon

cursor at start, d/highEnter:

high moon

Bonus

Also, you might be interested in learning some of the ex mode commands like that:

the lazy cow jumped over the high moon
the hazy cow jumped over the high moon
the noble cow jumped over the high moon
the crazy cow jumped over the high moon

Now enter

:g/azy/ norm! /jumped<CR>d/high/e<CR>

(Note: <CR> denotes C-vC-m for the enter key (^M))

Result:

the lazy cow  moon
the hazy cow  moon
the noble cow jumped over the high moon
the crazy cow  moon

The /e flag achieves inclusive behaviour like with f; To get 'till behaviour instead:

:g/azy/ norm! /jumped<CR>d/high/<CR>

Result:

the lazy cow high moon
the hazy cow high moon
the noble cow jumped over the high moon
the crazy cow high moon

Upvotes: 7

Josh Lee
Josh Lee

Reputation: 177500

Try using * or # to search for instances of the word under the cursor. You’ll notice that it sets the pattern to \<foobar\>, so you can use a pattern like that to find the word you want, surrounded by word boundary characters.

Upvotes: 2

Xavier T.
Xavier T.

Reputation: 42188

You probably want to use /word for that kind of search.

set incsearch might also help.

Upvotes: 0

Related Questions