PyCharm comment print lines
Question:
Is there any shortcut in the IntelliJ IDE such as PyCharm to comment all the lines start with 'print'
?
Since during the debug I always write many prints, after the code runs well I want to find a convenient way to comment on all lines starting with 'print'
. Now I select each line/block
with command + /
which is trouble.
Answers:
Not sure about pycharm, but I guess you could use find/replace with a regex like '^print'
and substitute with '# print'
. Maybe you can even make this a macro / Hotkey in pycharm.
Find: (^[ t]*)(print)
Replace: $1## $2
Why not just:
Find: print(
Replace: #print(
And, to get back:
Find: #print(
Replace: print(
This worked pretty well for me. I don’t find the reason for using complex regex for this.
Is there any shortcut in the IntelliJ IDE such as PyCharm to comment all the lines start with 'print'
?
Since during the debug I always write many prints, after the code runs well I want to find a convenient way to comment on all lines starting with 'print'
. Now I select each line/block
with command + /
which is trouble.
Not sure about pycharm, but I guess you could use find/replace with a regex like '^print'
and substitute with '# print'
. Maybe you can even make this a macro / Hotkey in pycharm.
Find: (^[ t]*)(print)
Replace: $1## $2
Why not just:
Find: print(
Replace: #print(
And, to get back:
Find: #print(
Replace: print(
This worked pretty well for me. I don’t find the reason for using complex regex for this.