【问题标题】:vscode + vim: commenting line doesn't move cursor downvscode + vim:注释行不会向下移动光标
【发布时间】:2018-09-19 12:48:29
【问题描述】:

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

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

但它不起作用。

使用 Linux Manjaro + vscode 1.27.2

【问题讨论】:

    标签: visual-studio-code vscodevim


    【解决方案1】:

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

    MacOS:

    • ~/Library/Application\ Support/Code/User/keybindings.json
    • ~/Library/Application\ Support/Code/User/settings.json

    【讨论】:

    • 我将编辑答案以在答案中添加keybindings.json 位置,但在此之前使用以下这些:
    • 对于 linux:~/.config/Code/User/keybindings.json
    • 对于 Windows:%UserProfile%\AppData\Roaming\Code\User\keybindings.json
    • 没有为我工作与代码抛出错误命令macros.commentLine 未找到
    • @Farhad 我编辑了答案,将适当的宏添加到settings.json。立即尝试。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2018-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多