Francis Padron
Francis Padron

Reputation: 327

VIM select all matching patterns in one line

Can anybody please help on my issue regarding VIM? This is my scenario:

The red redfox02animal jump over the blue reddog01animal.

I tried this search patten

/red.*[0-9]

but the result is "redfox02animal jump over the blue reddog01". What I want are two matched "redfox02" and "redfox01"

Any advice?

Upvotes: 1

Views: 62

Answers (2)

Kent
Kent

Reputation: 195029

this should go too:

/red\D*\d\+

Note that this gives the same matches as Tobi's answer, the first match is:

red redfox02

if you just want to have redfox02 and reddog01 (there is no redfox01 in your input, you cannot get it, as you stated in your question), you can try:

/red[^0-9 ]\d\+

Upvotes: 2

tlehman
tlehman

Reputation: 5167

Use /red.\{-}[0-9]\+ instead of /red.*[0-9], the former is non-greedy, while the latter (default) is greedy.

enter image description here

Upvotes: 4

Related Questions