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
?
在 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-autosuggestion
或forward-char
可以通过以下方式列出bind --function-names
编辑:由于#2254,这比应有的更难。最简单的事情是将调用放入函数fish_vi_mode
中fish_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
保存它。