如何启用“向上滚动”在代码建议/提示中使用 vscode vim 而不是使用箭头键?

发布于 2025-01-12 01:22:12 字数 991 浏览 3 评论 0原文

VScodevim 默认情况下将 extension.vim_ctrl+j 映射到 Ctrl+j,这允许您向下导航弹出代码建议窗口(通过在插入模式下按 Ctrl+Space 触发) )像这样:

image

它还将 extension.vim_ctrl+k 映射到 Ctrl+k,但向下绑定不起作用,所以我无法向上滚动弹出-up 代码建议窗口。在插入模式下默认输入 digraph 但只需将类似的内容添加

    {
      "before": ["<C-k>"],
      "after": ["extension.vim_ctrl+k"]
    }

到我的 settings.json 不起作用,因为尽管它删除了有向图功能,但据我了解,每当我现在在插入模式下按 Ctrl+k 时,VSCode 都会查阅 settings.json,找到到 的映射“extension.vim_ctrl+k”以某种无限循环的方式将其指向 settings.json

vim 中的 :h i_ctrl-j 显示此键绑定映射到“开始新行”,因此 VScode 似乎将“开始新行”解释为向下弹出窗口窗口处于插入模式,而不是像通常的 vim 行为那样创建新行并将光标移动到那里,尽管不确定这是如何工作的。无论如何,我找不到 VSCode 可以用来在弹出窗口中向上滚动的等效 vim 命令。任何帮助将不胜感激!

VScodevim has extension.vim_ctrl+j by default mapped to Ctrl+j which allows you do navigate down pop-up code suggestion windows (triggered by hitting Ctrl+Space in insert mode) like this:

image

It also has extension.vim_ctrl+k mapped to Ctrl+k but this binding down not work, so I cannot scroll up pop-up code suggestion windows. in insert mode defaults to entering a digraph but simply adding something like this

    {
      "before": ["<C-k>"],
      "after": ["extension.vim_ctrl+k"]
    }

to my settings.json does not work since although it removes the digraph functionality, from what I understand, whenever I now press Ctrl+k in insert mode, VSCode will consult the settings.json, find the mapping of to "extension.vim_ctrl+k" which points it back to settings.json in a sort of infinite loop.

:h i_ctrl-j in vim reveals this keybind to be mapped to "Begin new line" so it seems VScode interprets "Begin new line" as navigating down a pop-up window in insert mode instead of it's usual vim behaviour of creating a new line and moving the cursor there, although not sure this is how it works. In any case, I could not find an equivalent vim command that perhaps VSCode could use to scroll up in pop-up windows. Any help would be much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等待我真够勒 2025-01-19 01:22:12

我通过复制 ctrl+pctrl+n 的现有默认键绑定来完成此工作,默认情况下,这些键绑定在整个 VSCode 中用于上下滚动。

我在 keybinds.json 文件中使用了 alt,但您可以轻松地将其替换为 ctrl 来实现您想要的

keybinds .json

// Down Motion
{
  "key": "alt+j",
  "command": "cursorDown",
  "when": "textInputFocus"
},
{
  "key": "alt+j",
  "command": "showNextParameterHint",
  "when": "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible"
},
{
  "key": "alt+j",
  "command": "selectNextSuggestion",
  "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
  "key": "alt+j",
  "command": "list.focusDown",
  "when": "listFocus && !inputFocus"
},
{
  "key": "alt+j",
  "command": "workbench.action.quickOpenSelectNext",
  "when": "inQuickOpen"
},

// Up Motion
{
  "key": "alt+k",
  "command": "cursorUp",
  "when": "textInputFocus"
},
{
  "key": "alt+k",
  "command": "showPrevParameterHint",
  "when": "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible"
},
{
  "key": "alt+k",
  "command": "selectPrevSuggestion",
  "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
  "key": "alt+k",
  "command": "list.focusUp",
  "when": "listFocus && !inputFocus"
},
{
  "key": "alt+k",
  "command": "workbench.action.quickOpenSelectPrevious",
  "when": "inQuickOpen"
}

I got this working by copying the existing default keybinds for ctrl+p and ctrl+n which are used throughout VSCode by default for scrolling up and down.

I've used alt here in my keybinds.json file but you can easily replace it with ctrl to achieve what you want

keybinds.json

// Down Motion
{
  "key": "alt+j",
  "command": "cursorDown",
  "when": "textInputFocus"
},
{
  "key": "alt+j",
  "command": "showNextParameterHint",
  "when": "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible"
},
{
  "key": "alt+j",
  "command": "selectNextSuggestion",
  "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
  "key": "alt+j",
  "command": "list.focusDown",
  "when": "listFocus && !inputFocus"
},
{
  "key": "alt+j",
  "command": "workbench.action.quickOpenSelectNext",
  "when": "inQuickOpen"
},

// Up Motion
{
  "key": "alt+k",
  "command": "cursorUp",
  "when": "textInputFocus"
},
{
  "key": "alt+k",
  "command": "showPrevParameterHint",
  "when": "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible"
},
{
  "key": "alt+k",
  "command": "selectPrevSuggestion",
  "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
  "key": "alt+k",
  "command": "list.focusUp",
  "when": "listFocus && !inputFocus"
},
{
  "key": "alt+k",
  "command": "workbench.action.quickOpenSelectPrevious",
  "when": "inQuickOpen"
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文