Salvador Dali
Salvador Dali

Reputation: 222591

Folding of comments in PyCharm

For a long time I was looking for a way to fold comments in PyCharm. Basically I was looking for a way to achieve the same + for comments as for the block of code.

screenshot of code in editor

Upvotes: 3

Views: 2735

Answers (2)

congusbongus
congusbongus

Reputation: 14622

Comment folding has been available for a while now. Any multi-line comment, regardless of type (#, """), will cause clickable folding icons to show up.

enter image description here

The #region feature is still useful, if you want to fold mixed content.

Upvotes: 2

Salvador Dali
Salvador Dali

Reputation: 222591

It is easy to achieve this with

#region Description 
# all your comments go here
#endregion 

or this:

// <editor-fold desc="Description"> 
// all your comments go here
// </editor-fold> 

Important thing to remember is that you can not mix both kinds of folding.

Also instead of typing all these #region Desription you can just press CRTL+ALT+T (but not on ubuntu, where this combination is for opening terminal) or going to Code -> Surround With and selecting your surrounding type.

Using this type of surrounding you can fold any arbitrary parts of the code. But you can also do this with CTRL + .

Upvotes: 7

Related Questions