我找不到在Visual Studio code中注释和取消注释多行代码的方法。
是否可以在Visual Studio Code中使用一些快捷方式注释和取消注释多行?如果有,怎么做?
我找不到在Visual Studio code中注释和取消注释多行代码的方法。
是否可以在Visual Studio Code中使用一些快捷方式注释和取消注释多行?如果有,怎么做?
当前回答
首先,选择要注释/取消注释的行(CTRL+L可以方便地选择几行)
然后:
要切换行注释,执行editor.action.commentLine (Windows下的CTRL+/) 或 要添加行注释,执行editor.action.addCommentLine (CTRL+K CTRL+C) 要删除行注释,执行editor.action.removeCommentLine (CTRL+K CTRL+U) 或 要切换块注释,请执行editor.action.blockComment (SHIFT-ALT-A)
参见官方文档:Visual Studio Code的键绑定
其他回答
对于我的键盘布局,它是Ctrl +§为:
//
//
//
Shift + Alt + A用于:
/*
...
*/
在我的例子中,Ubuntu的快捷键是ctrl+shift+A。
MacOS上VSCode的键盘快捷键:https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf
我使用⌘/来切换注释。
如何注释掉VS Code中的多行/单行:
一样:
Shift + Option + A:
/* multiline
comment */
CMD + /:
// single line comment
窗口:
Shift + Alt + A:
/* multiline
comment */
按下CTRL + /:
// single line comment
如何重新映射/更改这些快捷方式?
Windows:文件>首选项>键盘快捷方式。
MacOS:代码>首选项>键盘快捷键。
您可以通过键绑定(键名)和命令名在列表中搜索。
阅读:如何从另一个文本编辑器(Sublime, Atom等)设置快捷方式?
官方文档:Visual Studio代码的键绑定
在windows中,您需要按ctrl + /在mac中,您可以使用⌘+ /进行多个注释
// public function index()
// {
// $badgeIcon = BadgeIcon::all();
// return $this->showAll($badgeIcon);
// }
然后如果你想取消注释,那么再次选择这些行,然后再次按ctrl + /(在windows中)⌘+ /(在mac中)。