I’m trying to add a print statement to all functions in a python script (the programming language shouldn’t matter here though) using vim. Basically I want to change this:
def func1(a, b):
pass
into this:
def func1(a, b):
print 'in func1'
pass
I was thinking of something like :g/\vdef (\w+)\(/CMD , but my vim skills are not yet good enough to come up with CMD. Does anyone know what I could use?
Thanks!
You can use whatever you’ve used to do this job by yourself, prefixed with
:normal!:(note: according to the help, you must escape space when using
\v:. You see, space is not listed here.)