Jas
Jas

Reputation: 15093

is there something similar to f command in vim for multiple chars?

Beginning to use vim as a macro, is there an f command but instead of catching single char i want to catch multiple chars? While I know I can use the / I didn't see that I could repeat it with the ; to take me to the next target only with f

Upvotes: 2

Views: 1242

Answers (3)

ChatterOne
ChatterOne

Reputation: 3541

If your issue is that / is interactive (meaning: you have to type something) and you want to use that in a fixed value macro, then you can still do it.

For example if you do:

:map g /something^M

then you hit g, it will look for the string something.

Keep in mind that ^M is the combination of keys Ctrl+V followed by Ctrl+M

As a side note, the same goes when you want to enter some text and go back to normal mode:

:map g 0i--^[j

If you hit g it will insert -- at the beginning of the line and move down one line.

Here ^[ is Ctrl+V followed by Esc

Upvotes: 1

d0niek
d0niek

Reputation: 228

Put your cursor on the word and pres:

  • gd - goto first one
  • # - goto previous
  • * - goto next

and then n or N to repeat.

Upvotes: 4

Johannes Riecken
Johannes Riecken

Reputation: 2515

You can get to the next target with n and to the previous one with N when using /.

Upvotes: 7

Related Questions