19

Is there a way to fold JSDoc-style comment blocks in VSCode v1.25 for JavaScript files? I get normal code collapse offered, but comment blocks seem excluded. Is there a keyboard shortcut that would collapse code even without the GUI handlebars showing?

enter image description here

alphadogg
  • 12,762
  • 9
  • 54
  • 88

2 Answers2

36

I had the same issue, and fixed it by doing this:

Go to File -> Preferences -> Settings and change the following entry from auto to indentation

"editor.foldingStrategy": "indentation"

Now JSDoc comments are folding as expected, hope this works for you as well!

Paolo
  • 20,112
  • 21
  • 72
  • 113
locofierro
  • 361
  • 2
  • 2
6
{
  "key": "ctrl+k ctrl+/",
  "command": "editor.foldAllBlockComments",
  "when": "editorTextFocus"
}

will fold block comments, like jsdoc. But I don't see a command for specifically unfolding (all or just) )block comments. But you can use:

{
  "key": "ctrl+shift+]",
  "command": "editor.unfold",
  "when": "editorTextFocus"
}

o do that when cursor is on that line of folded jsdoc comment.

Mark
  • 143,421
  • 24
  • 428
  • 436