Skip to content
Advertisement

How to comment out a HTML tag in .Vue ‘s template

Recently, I’m start learning Vue and using Vue-Cli. There’s a problem that I can not use hot-key(VSCode) to comment out a HTML tag in the . when I use “Ctrl+/” the line I want to comment out turns like this.

// <div> comment out this line</div>

not like this.

<!--<div> comment out this line</div>-->

Is there any possibility that I changed some setting in the VSCode to result this situation? Anyone know how to solve this problem?

Advertisement

Answer

For single line comment use Ctrl + /. This will do something like this

// <div> comment out this line</div>

and for block comment use Ctrl + Shift + /. This will comment lines like this

<!-- <div> comment out this line</div>

     <div> comment out this line</div>

     <div> comment out this line</div> -->

or

/* <div> comment out this line</div>

   <div> comment out this line</div>

   <div> comment out this line</div> */

In order to change shortcut key

  • Windows: File > Preferences > Keyboard Shortcuts.

  • MacOS: Code > Preferences > Keyboard Shortcuts.

and then search for comment like this Screenshot

Advertisement