Skip to main content
added 6 characters in body
Source Link
Vivian De Smedt
  • 21.2k
  • 5
  • 22
  • 40

I would do:

/public static \(\S\+\) \(\w\+\)(

or maybe more readable using super magic:

/\vpublic static (\S+) (\w+)\(

What I believe happen on your test is that .\{-} is eating all the symbols you don't want (i.e: =, ).

Before you enter the parenthesis it does not because it is not greedyof its non-greedy nature (\{-}) and it. It doesn't have to eat to find the next space but. But has soon as you add the ( it has too to match and so it does.

You can analyse that by converting your search into a substituion:

:s/public static \(.\{-}\) \(\w\+\)(/1:\1, 2:\2/

I would do:

/public static \(\S\+\) \(\w\+\)(

or maybe more readable using super magic:

/\vpublic static (\S+) (\w+)\(

What I believe happen on your test is that .\{-} is eating all the symbols you don't want (i.e: =, ).

Before you enter the parenthesis it does not because it is not greedy (\{-}) and it doesn't have to eat to find the next space but has soon as you add the ( it has too to match and so it does.

I would do:

/public static \(\S\+\) \(\w\+\)(

or maybe more readable using super magic:

/\vpublic static (\S+) (\w+)\(

What I believe happen on your test is that .\{-} is eating all the symbols you don't want (i.e: =, ).

Before you enter the parenthesis it does not because of its non-greedy nature (\{-}). It doesn't have to eat to find the next space. But has soon as you add the ( it has too to match and so it does.

You can analyse that by converting your search into a substituion:

:s/public static \(.\{-}\) \(\w\+\)(/1:\1, 2:\2/
added 294 characters in body
Source Link
Vivian De Smedt
  • 21.2k
  • 5
  • 22
  • 40

I would do:

/public static \(\S\+\) \(\w\+\)(

or maybe more readable using super magic:

/\vpublic static (\S+) (\w+)\(

What I believe happen on your test is that .\{-} is eating all the symbols you don't want (i.e: =, ).

Before you enter the parenthesis it does not because it is not greedy (\{-}) and it doesn't have to eat to find the next space but has soon as you add the ( it has too to match and so it does.

I would do:

/public static \(\S\+\) \(\w\+\)(

or maybe more readable using super magic:

/\vpublic static (\S+) (\w+)\(

I would do:

/public static \(\S\+\) \(\w\+\)(

or maybe more readable using super magic:

/\vpublic static (\S+) (\w+)\(

What I believe happen on your test is that .\{-} is eating all the symbols you don't want (i.e: =, ).

Before you enter the parenthesis it does not because it is not greedy (\{-}) and it doesn't have to eat to find the next space but has soon as you add the ( it has too to match and so it does.

Source Link
Vivian De Smedt
  • 21.2k
  • 5
  • 22
  • 40

I would do:

/public static \(\S\+\) \(\w\+\)(

or maybe more readable using super magic:

/\vpublic static (\S+) (\w+)\(