I want to add a multi-line TODO comment to my PyCharm project.
# TODO: Multiple errors can be wrapped inside an exception.
# WfcApiException should do recursive error checking to locate
# and store an arbitrary number of nested errors.
Unfortunately, PyCharm only recognizes the first line as a TODO comment. Any following lines are viewed as standard Python comments.
What is the correct way to format a multi-line TODO comment in PyCharm?
Comment out multiple lines in Pycharm If we have to comment out multiple lines of code in Pycharm, we can select the lines to be commented out and then press ctrl+shift+/ .
In the Settings/Preferences dialog ( Ctrl+Alt+S ), select Editor | TODO. Use a regular expression to specify a custom pattern. This matches the word "optimize" ( \b designates word boundaries) and allows any number of other characters in the comment. Then click OK to save the new pattern.
Place the caret where you want to create a TODO item and add a comment, for example, by pressing Ctrl+/ , then type TODO or FIXME , and then type your note.
To comment a line of code, place the caret at the appropriate line and press Ctrl+/ . Press Ctrl+/ again on the same line to uncomment it. To move a line up or down, press Alt+Shift+Up or Alt+Shift+Down respectively.
Pycharm 2018.3 does support multiline todo, yay!
https://youtu.be/5gJ7_3wCfUk?t=65
https://blog.jetbrains.com/pycharm/2018/11/pycharm-2018-3-out-now/
So, using your TODO comment:
# TODO: Multiple errors can be wrapped inside an exception.
# WfcApiException should do recursive error checking to locate
# and store an arbitrary number of nested errors.
yields:
Actually, you only need to indent the following lines one character to the right of the TODO
so this would be just on the limit from being detected:
And the todo is captured as a single item, of course:
Update: It appears JetBrains added this feature, see payala's answer
PyCharm does not support multi-line TODOs, one alternative option would be to use a multi line string
'''
TODO foobar
foobar
'''
This won't have the TODO highlighting like # TODO foo
, but it will stand out from the rest of your code with the string highlighting.
You could also try
# TODO -----------------
# TODO foobar this
# TODO comment
# TODO comment
# TODO comment
# TODO ------------------
If you have a particularly chunky and important TODO note.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With