Ctrl-F 不再用于接受建议。为什么?

jor*_*ver 3 shell fish

fish_vi_mode我最近通过添加到我的配置中启用了 Vi 模式。由于我这样做了Ctrl+F不再可以完成建议,因此我必须使用右箭头。

forward-char无论启用或未启用,键绑定都是相同的fish_vi_mode。根据fish_config,它们是:

forward-char    Right Arrow
forward-char    Right Arrow
forward-char    CTRL - f
Run Code Online (Sandbox Code Playgroud)

Ctrl为什么+不能与启用F一起使用fish_vi_mode

rid*_*ish 5

在 vi 模式下,运行bind并查找\cf,它在这里:

bind -M insert \cf forward-word
Run Code Online (Sandbox Code Playgroud)

这就是发生的事情:control-F 向前移动一个字。您可以恢复非 vi 行为:

bind -M insert \cf forward-char
Run Code Online (Sandbox Code Playgroud)

这是前进一个字符,或者如果光标位于末尾则接受自动建议(这确实有点奇怪)。

或者,如果您希望它只接受自动建议,您可以在之后运行fish_vi_mode

bind -M insert \cf accept-autosuggestion
Run Code Online (Sandbox Code Playgroud)

现在,它可以随时接受自我暗示,而不仅仅是在最后。

顺便说一句,这些功能如accept-autosuggestionforward-char可以通过以下方式列出bind --function-names

编辑:由于#2254,这比应有的更难。最简单的事情是将调用放入函数fish_vi_modefish_user_key_bindings

function fish_user_key_bindings
    fish_vi_mode
    bind -M insert \cf accept-autosuggestion
    bind \cf accept-autosuggestion
end
Run Code Online (Sandbox Code Playgroud)

您可以用来funced fish_user_key_bindings编写该函数,然后funcsave fish_user_key_bindings保存它。

  • 也许您运行了两次fish_vi_mode?运行“bind” - 您的新接受自动建议绑定是否存在?如果您仅在命令行运行“bind -M insert \cf Accept-autosuggestion”会发生什么? (2认同)
  • 呃 - 好吧,由于 [#2254](https://github.com/fish-shell/fish-shell/issues/2254),这比应有的要困难。我已经用我认为最好的方法编辑了我的回复。 (2认同)