Unlike in webstorm, I\'m unable to comment JSX code out in .js
files in the Visual Studio Code.
=>To comment a selected single line or multi-lines of code:
For Windows or Linux machine select the code and use:
Ctrl + /
to get comment pattern //Ctrl + Shift + A
to get comment pattern {/* */}For Mac machine select the code and use:
Cmd + /
to get comment pattern //Cmd + Shift + A
to get comment pattern {/* */}=> To uncomment the commented line(s) of code: Just repeat the step, you used for commenting.
If we press cmd + /
by default vs code will do single line comments which can't be applied for JSX. Just install the below vs code extension it will be fine.
vscode-language-babel
Currently in Visual studio code it could be done by pressing combination - Shift+Alt+A and comment "jsx" code it produces - {/**/} comments.
If You want to comment JSX syntax block, you can do like this
{
/* <section>
<header><h3>Contact Form</h3></header>
<figure>
<Form />
</figure>
</section> */
}
The keyboard commands...
Ctrl + /
- Windows & Linux
Cmd + /
- MacOS
...now work as expected for single line and block code by adding {/* */}
around the selected lines.
It has been fixed in recent Insiders builds of Visual Studio Code and will make it into the next full release.
Search Babel JavaScript
in VS Code:
https://marketplace.visualstudio.com/items?itemName=mgmcdermott.vscode-language-babel
Install and command + /
will comment jsx with { /* */ }