Making paragraphs for the outline using comments in vscode

Viewed 197

Is it possible to use comments to organise the code in paragraphs that could be available in the outline.

This would be helpful for organizing classes with a lot of methods.

I would be in particular interested in doing that inside python classes.

Example:

class Class():
# Special comment to be in the outline: First methods
def a(self):
    pass
def b(self):
    pass
def c(self):
    pass
# Special comment to be in the outline: Other methods
def d(self):
    pass
def e(self):
    pass

Outline should group the function according to the special comment Outline should group the function according to the special comment

Thanks !

1 Answers

vscode supports #regions for python, which makes it possible to collapse & expand the regions using the outline markers in the gutter. These regions don't appear in the Outline in the sidebar. There have been discussions in the vscode issues for outlines but it doesn't seem to be in any danger of being implemented any time soon.

Here's the #region example

class Class():
    #region Special comment to be in the outline: First methods
    def a(self):
        pass
    def b(self):
        pass
    def c(self):
        pass
    #endregion
    #region Special comment to be in the outline: Other methods
    def d(self):
        pass
    def e(self):
        pass
    #endregion
Related