Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSDoc Comment Folding In VSCode

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

like image 343
alphadogg Avatar asked Jul 19 '18 02:07

alphadogg


People also ask

How do I comment out code in Visual Studio Java?

Comment Code Block Ctrl+K+C/Ctrl+K+U If you select a block of code and use the key sequence Ctrl+K+C, you'll comment out the section of code.


2 Answers

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!

like image 139
locofierro Avatar answered Sep 27 '22 19:09

locofierro


{
  "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.

like image 28
Mark Avatar answered Sep 27 '22 17:09

Mark