user5972209
user5972209

Reputation:

Line comments in Pycharm

Hi when I comment out a line in Pycharm using the ctrl+slash keyboard shortcut, I get

# code

but instead I want

##Code

like in IDLE. Is this possible?

Upvotes: 1

Views: 4674

Answers (2)

Amrit
Amrit

Reputation: 2165

Ctrl+Slash on any line comments the line i.e. Ctrl + /

Upvotes: 0

LearnerEarner
LearnerEarner

Reputation: 1020

You can register a new file type and at the time of registration specify comment characters. You need to reassign *.py to this new type from the default Python file type that comes with installation.

Step by step procedure:

  1. Ctrl+Alt+S to open File Types dialogue.
  2. Alt+Insert (or click on +) to create a new file type
  3. In the new File Type dialogue for Syntax Highlighting -> Line comment: provide ##
  4. Provide rest of the details (including Name and Description) as needed and click OK.
  5. Select the newly created File Type and in Registered Patterns section click + to add a wildcard.
  6. In Add wildcard dialogue box enter *.py and click Ok
  7. Since *.py is already assigned to the default type you will be asked to confirm Reassign wildcard. Do so.
  8. Apply and Ok

Note: We have to do all this because we can not edit default file types and Python is a default file type.

Now, open a Python file (.py extension) and check Ctrl+Slash on any line. You should now see ## prepended to the line.

Upvotes: 3

Related Questions