Reputation: 113365
I have a VIM buffer containing the following pieces of code:
function foo () {...}
foo ();
foo();
if (foo ()) {...}
function bar() {...}
bar = function () {...}
for (...) {}
bar (foo());
I want only match the function declarations and function calls (that means that JavaScript statements and keywords will be excluded. e.g. if
, for
, switch
etc) that contain a space between the last letter and opening bracket, but excepting function () {...}
case.
So, the matched parts in the example above will be:
function foo () {...}
foo ();
if (foo ()) {...}
bar (foo());
I tried to do:
/[a-z] (
This matches all cases where the space preceds the opening bracket.
What's the regular expression that matches these cases?
Upvotes: 0
Views: 94
Reputation: 196546
This substitution works on your sample:
:%s/\(if\|for\|while\)\@<!\zs\s\+\ze(//g
More info:
:help \@<!
:help \zs
:help \ze
Upvotes: 2