I use Vim to write my Python source and use the debugging library pdb.
Let's say I have this code with break points commented out:
import pdb #pdb.set_trace() def func1(): #pdb.set_trace() foo_bar I then want to globally un-comment all the pdb.set_trace() commands. Also, I'll want to re-comment them.
I figured out how to search for the commented string:
^\(\s*#\)\@!\s*pdb.set_trace() After this I don't know how to build a string of commands that would globally find the string and add a # to the beginning of the string so as not to mess up the indentation.
UPDATE:
I realized that I need to not re-comment lines with an existing # so I built upon the accepted answer:
To comment out:
:g/\s*\(#\)\@<!pdb.set_trace()/normal I#