q0987
q0987

Reputation: 35982

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

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

How to fix it?

Upvotes: 23

Views: 27305

Answers (6)

foo
foo

Reputation: 202

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

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

Upvotes: 17

xxyzzy
xxyzzy

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

Iqra.
Iqra.

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

Michael Vashkevich
Michael Vashkevich

Reputation: 81

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

Upvotes: 6

Karl Sebby
Karl Sebby

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

EclipseUser
EclipseUser

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

Related Questions