Reputation: 35982
I have found that the menu Code | "Comment with Block comment" is always disabled.
How to fix it?
Upvotes: 23
Views: 27305
Reputation: 202
Because in Python, there is no such thing as a block comment.
The """ stuff here """
is for documentation.
Upvotes: 17
Reputation: 588
Some IDEs (Wingware, PyCharm) allow you to select a range of lines and then type the #
character (Wingware), select Ctrl + / (PyCharm), or other method. This comments out each line by placing #
just before the first none-white character in each line.
Upvotes: 1
Reputation: 763
Generally, In PyCharm for commenting out the code, we use Hash symbol #
, shortcut keys are:
For a single line comment we use Ctrl + / , for uncomment do it again.
For multiline comments we select those lines and then use Ctrl + / , for uncommenting do it again while keeping those lines selected.
Upvotes: 1
Reputation: 81
Ctrl+/ (un)comments all selected lines. Agree it is not intuitive, but works
Upvotes: 6
Reputation: 43
The Code | "Comment with Block Comment" stays grayed out if pycharm does not know the syntax for adding comments for the particular file type. You can configure this in File | Settings, then select Editor/File Type. Select the Recognized File type that you want to configure comments for, or add it if it does not exist.
Upvotes: 4
Reputation: 51
While it's true that Python doesn't have block comments, I've recently switched from Aptana Studio and that had a nice block comment format which preserved spaces/idents, allowed you to uncomment by block and supported wrapping which was neat.
###############################
# a = b
# code_block = commented_out
###############################
I guess you can't have everything!
Upvotes: 5