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 ?
Asked
Active
Viewed 731 times
6
3 Answers
7
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/high
Enter:
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
-
added bonus examples because it's rather usual to want to do this repeatedly – sehe Sep 26 '11 at 12:37
-
Your example is great! But I failed to understand the ex mode commands. Nevertheless, combining `/` (and `?`) with quantifiers (and other operators) is what I was looking for! – Niloct Sep 26 '11 at 12:53
-
Yeah the ex commands really combine a lot of power tools: `:global`, command ranges, pattern modifiers. Sometimes it is enough to tease a little - it triggers the curiosity genes with tech people, doesn't it? – sehe Sep 26 '11 at 13:11
-
Fully understood the example now! – Niloct Sep 26 '11 at 13:33
-
What is *norm!* – jgomo3 Mar 12 '18 at 13:12
-
I see. I was trying to run your example in Spacemacs and it was not working. There should be a way to do it there. – jgomo3 Mar 12 '18 at 13:43
2
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.

Josh Lee
- 171,072
- 38
- 269
- 275
0
You probably want to use /word
for that kind of search.
set incsearch
might also help.

Xavier T.
- 40,509
- 10
- 68
- 97
-
Thanks. Yes I do this often, but I really needed to know to combine this with movement and other operators. – Niloct Sep 26 '11 at 12:49