Make Notepad++ collapse Python triple double content?

Question:

Q: I’ve tried all Notepad++ Preferences and Options and Style Configurator but I couldn’t find a way to collapse Python docstring (the content between triple double quotes). Can we do that or is there any plug-in to support that need?

Context: I decided to move to Notepad++ from ipython notebook (which is an interactive shell running inside a browser window). The simple reasons that Notepad++ offers far more flexible in customizing editing environment, and it has better syntax highlighting.

Now I miss the function of collapsing a chunk of docstring within the code to have a better sense of the code structure (normally they’re OpenCV2 docs, I just want to make them available in the script, without going to the online document every time I need references).

E.g. Netbeans allows collapse chunk of code, or comment blocks or Javadoc.

Asked By: Jim Raynor

||

Answers:

Notepad++ will allow you to collapse whatever it thinks are blocks of codes, which it decides based on indents. So the simple answer is to indent your doc strings

"""
    This is a collapsible doc string
"""


"""This is not"""

"""
Neither is this
"""

"""
 This one is, but I think it looks a little odd"""
Answered By: wnnmaw

The accepted answer only solves for doc strings and in cases where people are willing to adjust the message in the triple quoted text. I currently have test cases where I have to paste in a complete message and I use triple double quotes. In this case, I am not going to adjust my multiline test message and sadly, notepad++ will only fold the first paragraph.

    testcases.append("""Lorem Ipsum is simply dummy text of
the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s, when
an unknown printer took a galley of type and scrambled it to make
a type specimen book.

It has survived not only five centuries, but also the leap into
electronic typesetting, remaining essentially unchanged. It was
popularized...""")
Answered By: Scott
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.