首页 > 解决方案 > vscode + vim:注释行不会向下移动光标

问题描述

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

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

但它不起作用。

使用 Linux Manjaro + vscode 1.27.2

标签: visual-studio-codevscodevim

解决方案


当前 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

推荐阅读