2

ctrl + /在使用快捷方式注释当前行后,如何使 Visual Studio Code 将光标向下移动一行?我试过(在用户设置中):

"vim.normalModeKeyBindings": [
    {
        "before": ["<C+/>"],
        "after": ["<C+/>", "j"]
    }
]

但它不起作用。

使用 Linux Manjaro + vscode 1.27.2

4

2 回答 2

5

当前 vscode (1.48.0) 的解决方案:

  1. 安装这个扩展:geddski.macros
  2. 将此行添加到settings.json
"macros": { "commentLine": ["editor.action.commentLine","cursorDown"] },
  1. 将这些行添加到keybindings.json
{
    "key": "ctrl+/",
    "command": "macros.commentLine",
    "when": "editorTextFocus && !editorReadonly"
},

如何快速打开这些文件:

  • 用于keybindings.json新闻Ctrl+Shift+p和写作Preferences: Open Keyboard Shortcuts (JSON)
  • 按上面的settings.json快捷方式并写Preferences: Open Settings (JSON)

文件的物理位置:
Linux:

  • ~/.config/Code/User/keybindings.json
  • ~/.config/Code/User/settings.json

视窗:

  • %UserProfile%\AppData\Roaming\Code\User\keybindings.json
  • %UserProfile%\AppData\Roaming\Code\User\settings.json

苹果系统:

  • ~/Library/Application\ Support/Code/User/keybindings.json
  • ~/Library/Application\ Support/Code/User/settings.json
于 2020-09-04T11:07:42.210 回答
0

如果您检查keybindings.json(单击齿轮图标)搜索comment
,您会发现那里有一个Toggle Line Comment命令。
所以你可能需要先禁用它。

于 2018-10-26T09:20:35.757 回答