Я думаю, что это работает, модифицируя мой ответ от Комментируйте VSCode, начиная с позиции столбца 0
Вам необходимо мультикомандное расширение.
В ваших настройках:
"multiCommand.commands": [
{
"command": "multiCommand.insertCommentColumn0",
"sequence": [
"cursorLineStart",
{
"command": "type",
"args": {
"text": "//"
}
},
"deleteRight",
"deleteRight"
]
},
{
"command": "multiCommand.AddCommentColumn0MultipleLines",
"sequence": [
"editor.action.insertCursorAtEndOfEachLineSelected",
"cursorLineStart",
{
"command": "type",
"args": {
"text": "//"
}
},
"deleteRight",
"deleteRight",
"removeSecondaryCursors"
]
},
{
"command": "multiCommand.removeCommentsSingleLine",
"sequence": [
"editor.action.removeCommentLine",
"cursorLineStart",
{
"command": "type",
"args": {
"text": " "
}
},
"removeSecondaryCursors"
]
},
{
"command": "multiCommand.removeCommentsMultipleLines",
"sequence": [
"editor.action.insertCursorAtEndOfEachLineSelected",
"cursorLineStart",
"editor.action.removeCommentLine",
{
"command": "type",
"args": {
"text": " "
}
},
"removeSecondaryCursors"
]
}
]
В ваших сочетаниях клавиш. json:
{ // disable ctrl+/ for js/php files only
"key": "ctrl+/",
"command": "-editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly && resourceExtname =~ /\\.(js$|php)/"
},
{ // call the macro multiCommand.insertCommentColumn0 when
// commenting a single line
"key": "ctrl+/",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.insertCommentColumn0" },
"when": "!editorHasSelection && editorTextFocus && !editorReadonly && resourceExtname =~ /\\.(js$|php)/"
},
{ // call the macro multiCommand.AddCommentColumn0MultipleLines when
// commenting more than one line
"key": "ctrl+/",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.AddCommentColumn0MultipleLines" },
"when": "editorHasSelection && editorTextFocus && !editorReadonly && resourceExtname =~ /\\.(js$|php)/"
},
{ // call the macro multiCommand.removeCommentsSingleLine when
// uncommenting a single line
"key": "ctrl+shift+/",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.removeCommentsSingleLine" },
"when": "!editorHasSelection && editorTextFocus && !editorReadonly && resourceExtname =~ /\\.(js$|php)/"
},
{ // call the macro multiCommand.removeCommentsMultipleLines when
// uncommenting multiple lines
"key": "ctrl+shift+/",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.removeCommentsMultipleLines" },
"when": "editorHasSelection && editorTextFocus && !editorReadonly && resourceExtname =~ /\\.(js$|php)/"
},
Те же предостережения, что и в другом связанном ответе, поэтому прочитайте это. Я сделал выше только для файлов js / php, очевидно, это не будет работать для html / css / s css, et c. файлы с маркерами комментариев, отличными от javascript.
Ctrl + Shift + / для удаления комментариев (вы можете выбрать любую комбинацию клавиш, которая вам нравится). Ctrl + / для комментариев.
![comments at col 0 with no indentation](https://i.stack.imgur.com/EicGk.gif)