Vim Regex For Python2 Print To Python3
So say I have a python v2.7 file with some code like this: print 'asdf' print 'hi mom!' But I want to run it in python3, I'll need to add those parenthesis to them like so: print(
Solution 1:
This would work for your examples
:%s/print \('.*'\)/print(\1)/g
- You don't need to escape the space.
- You don't actually capture anything in parenthesis so the
\1
is an empty string in your regex.
But I also recommend using 2to3
Post a Comment for "Vim Regex For Python2 Print To Python3"