regex - VIM: Replace function call without the arguments -
How do I search for a function call, but how can I do without the arguments of the function?
My goal is to search and replace the How do I solve it? Is there any best practice? Try it out: Insert a row at the top of the file - We will write a macro here (this letter is not O, zero). followed by an open bracket for a string of word-letters Instructions to do, and Other Back to the Front (ctrl-letter o then, This field will be from then perform this macro again (it is assumed that it is Our macro is done, exhaust insert mode (should read your line: Drag the line / Code> register, which will replace the entire file. Demo: < P> Edit : Typo ( to
foobar: arg1, arg2;
foobar (arg1, arg2) to keep
I> Arg1, arg2 .
ggO
/ \ w * (/ e> & lt; Ctrl-M & gt; < P> Then we leave the cursor at the end of the match, go to the mailing bracket and replace it with a semicolon
:
Change:
P>
s:
q register
@q
/ \ w * (/ a ^ m% r; ^ OS: ^ [[[@ q] now)
& lt; Esc & gt;
q register (which also removes it from the current file, sends back its file. Finally, Big moment: Created by us Execute recursive macro
@
@q BENEFITS : This handles nested functions properly, because it is not relying on those regular expressions, who have brackets Instead, we rely on
% to match the parentheses.
foo (Bar, baz) foo (foo (bar), foo (foo, foo, foo)) foo (bar (baz ()))
\ w , not in search
\ e ).
Comments
Post a Comment