favicon mika @ schillinger's lab

Folding Julia code regions in Visual Studio Code

March 12, 2021, 7:10 PM

Folding long regions of code can improve readability and help getting a better view of what a file contains. As of now, Visual Studio Code does not provide a possibility to define custom folding rules (PR) and the default folding is rather unsatisfying when it comes to Julia source code.

Until we get custom folding in VS Code, I'm using Explicit Folding (v0.8.2) with the following settings in settings.json

{
    "editor.showFoldingControls": "always",
    "editor.foldingStrategy": "auto",

    "folding": {
        "*": [
            {
                "begin": "##region",
                "end": "##endregion"
            },
            {
                "begin": "##docs",
                "end": "##enddocs"
            },
            {
                "beginRegex": "\"\"\"",
                "endRegex": "\"\"\"",
            }
        ]
    },
}

Keep in mind the correct JSON syntax and don't forget the ...

Read more...