广告

vscode中如何设置多行注释快捷键

介绍

在vscode中,多行注释是一项非常常用的功能,能够快速地注释/取消注释多行代码。本文将介绍如何设置多行注释的快捷键。

步骤

步骤1:打开Keyboard Shortcuts

在菜单栏中找到“File” => “Preferences” => “Keyboard Shortcuts”,或使用快捷键 “Ctrl + K” followed by “Ctrl + S”,进入Keyboard Shortcuts。

步骤2:搜索 Comment

在搜索框中输入"comment",这会显示所有与注释相关的命令。

"editor.action.commentLine": {

"category": "Editor",

"descrption": "Comment Line",

"keybindings": [

{

"when": "editorTextFocus && !editorReadonly",

"mesage": "Toggle Line Comment",

"primary": "Ctrl+/",

"linux": "Ctrl+/",

"mac": "Shift+Option+A"

}

]

},

"editor.action.blockComment": {

"category": "Editor",

"descrption": "Toggle Block Comment",

"keybindings": [

{

"when": "editorTextFocus && !editorReadonly",

"mesage": "Toggle Block Comment",

"primary": "Shift+Alt+A"

}

]

},

vscode中如何设置多行注释快捷键

"editor.action.addCommentLine": {

"category": "Editor",

"descrption": "Add Comment Line",

"keybindings": [

{

"when": "editorTextFocus && !editorReadonly",

"mesage": "Add Line Comment",

"primary": null

}

]

}

步骤3:修改快捷键

点击需要修改的命令对应的“+”,选择需要使用的快捷键,例如“Ctrl + Shift + /”。

注意:不建议使用已有的快捷键,需要确保新的快捷键没有冲突。

步骤4:保存修改

在修改快捷键后,需要点击“Save”保存修改。

现在,多行注释的快捷键已经设置好了!在需要注释多行代码的时候,按下快捷键,就能快速实现注释功能了!

广告