Skip to main content
1 of 3
Tumbler41
  • 7.8k
  • 1
  • 23
  • 48

You should be able to do a search and replace.

:%s/^\(\s*\)#\(\s*pdb.set_trace()\)/\1\2/ 

To un-comment and

:%s/^\(\s*\)\(pdb.set_trace()\)/\1#\2/ 

To re-comment.

This is done by using back-references. Anything matched in between memory parentheses \(\) can be recalled by using a back-reference (\1 and \2 in this case).

Tumbler41
  • 7.8k
  • 1
  • 23
  • 48