Why "Comment with Block comment" is always disabled in PyCharm 1.5.4?

20,471

Solution 1

Because in Python, there is no such thing as a block comment.

The """ stuff here """ is for documentation.

Solution 2

Ctrl+/ (un)comments all selected lines. Agree it is not intuitive, but works

Solution 3

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!

Solution 4

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.

Solution 5

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.

Share:
20,471
q0987
Author by

q0987

Updated on February 20, 2022

Comments

  • q0987
    q0987 over 2 years

    I have found that the menu Code | "Comment with Block comment" is always disabled.

    How to fix it?

  • Andrey Shipilov
    Andrey Shipilov over 6 years
    And obviously you will do that for commenting one line, sure. Instead of putting a hash in front of it with a command.
  • rahul-ahuja
    rahul-ahuja about 3 years
    And I found that the """ comment """ could only be used once, at the top in a .py file in PyCharm. The next time I surrounded some lines, they were interpreted as string.
  • kokserek
    kokserek almost 3 years
    Thank you. It works for mac with cmd+/.