why “Comment with Block comment” is always disabled in Pycharm 1.5.4

StackOverflow https://stackoverflow.com/questions/7810672

  •  26-10-2019
  •  | 
  •  

سؤال

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

How to fix it?

هل كانت مفيدة؟

المحلول

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

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

نصائح أخرى

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!

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.

Some IDEs (Wingware, PyCharm) allow you to select a range of lines and then ttype 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.

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

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 uncomment do it again while keeping those lines selected.

    Cheers!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top