How to comment JSX code out in .js files in VSCode?

前端 未结 16 783
天涯浪人
天涯浪人 2020-12-02 18:02

Unlike in webstorm, I\'m unable to comment JSX code out in .js files in the Visual Studio Code.

相关标签:
16条回答
  • 2020-12-02 18:37

    =>To comment a selected single line or multi-lines of code:

    For Windows or Linux machine select the code and use:

    1. Ctrl + / to get comment pattern //
    2. Ctrl + Shift + A to get comment pattern {/* */}

    For Mac machine select the code and use:

    1. Cmd + / to get comment pattern //
    2. Cmd + Shift + A to get comment pattern {/* */}

    => To uncomment the commented line(s) of code: Just repeat the step, you used for commenting.

    0 讨论(0)
  • 2020-12-02 18:38

    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

    0 讨论(0)
  • 2020-12-02 18:39

    Currently in Visual studio code it could be done by pressing combination - Shift+Alt+A and comment "jsx" code it produces - {/**/} comments.

    0 讨论(0)
  • 2020-12-02 18:40

    If You want to comment JSX syntax block, you can do like this

    {
      /* <section>
         <header><h3>Contact Form</h3></header>
         <figure>
           <Form />
         </figure>
       </section> */
    }
    
    0 讨论(0)
  • 2020-12-02 18:41

    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.

    0 讨论(0)
  • 2020-12-02 18:43

    Search Babel JavaScript in VS Code:

    https://marketplace.visualstudio.com/items?itemName=mgmcdermott.vscode-language-babel

    Install and command + / will comment jsx with { /* */ }

    0 讨论(0)
提交回复
热议问题