这是我使用ctrl + /
在VS Code中注释HTML代码的示例:
<!-- </label>
<label>Confirm Your Email:
<!-- <input type="email" name="emailConfirm" required>
<!-- </label>
<label> -->
<input type="checkbox" name="termsAgree" required/>
I agree to the <a href="/legal/terms/">Terms & Conditions</a>. -->
</label> -->
ctrl+/
注释整个内容ctrl+/
注释为[[un],但只添加了一个新注释,从而破坏了较大的注释ctrl + /
CSS代码块时,我有同样的问题。 PHP代码中没有问题,因为它使用//
逐行注释如何更改此行为?
<!-- </label> -->
<!-- <label>Confirm Your Email: -->
<!-- <input type="email" name="emailConfirm" required> -->
</label>
<label>
<!-- <input type="checkbox" name="termsAgree" required/> -->
<!-- I agree to the <a href="/legal/terms/">Terms & Conditions</a>. -->
<!-- </label> -->
[请忽略html无效的事实。我只是在此示例中使用了一个随机块。
将其放入您的settings.json
:
"multiCommand.commands": [
{
"command": "multiCommand.blockHTMLCommentByLine",
"sequence": [
"editor.action.insertCursorAtEndOfEachLineSelected",
"cursorHomeSelect",
"editor.action.blockComment",
"cancelSelection",
]
}
]
它会将您的选择分成几行,然后在每一行之间切换块注释。添加键盘绑定以触发该宏-重载
ctrl + /键盘绑定(将其放入
keybindings.json
中:]{ "key": "ctrl+/", "command": "extension.multiCommand.execute", "args": { "command": "multiCommand.blockHTMLCommentByLine" }, // "when": "editorTextFocus && editorHasSelection && resourceExtname =~ /\\.(html|css|scss)/" "when": "editorTextFocus && editorHasSelection && resourceExtname =~ /\\.html/" },
我将其限制为.html
文件,但您可以看到如何在其他when
子句中包括其他扩展名。演示:
如果要注释整行,则必须选择完整的行。