简体   繁体   English

为什么不能在inputrc中将\\ Ce设置为vi命令键盘映射的行尾?

[英]Why can't I set \C-e in inputrc to be end-of-line for vi-command keymap?

I have this in my .inputrc, but Control-e doesn't move to end of line in command mode. 我的.inputrc文件中有此文件,但Control-e在命令模式下不会移至行尾。 All other bindings work. 所有其他绑定有效。

$if mode=vi
    set show-mode-in-prompt on

    set keymap vi-insert
    "\C-e": end-of-line
    "\C-a": beginning-of-line

    set keymap vi-command
    "\C-e": end-of-line
    "\C-a": beginning-of-line
$endif

I can see it's taking: 我可以看到它正在:

$ bind -p | grep 'end-of-line'
"\C-e": end-of-line
"\eOF": end-of-line
"\e[F": end-of-line

And I can see nothing else is bound to \\Ce: 而且我看不到其他绑定到\\ Ce的内容:

$ bind -p | grep 'C-e'
"\C-e": end-of-line
"\C-x\C-e": shell-expand-line

If I set it to \\Cl, it works. 如果我将其设置为\\ Cl,它将起作用。 So, what's special about \\Ce in readline's vi mode that I'm not able to override? 那么,在readline的vi模式下\\ Ce有什么我无法覆盖的特殊之处?

Only other clue is \\Ce causes a terminal beep. 仅当有其他提示时,\\ Ce会导致发出哔声。

Nothing else is in my .inputrc 我的.inputrc中没有其他内容

I just tried and it also does not work for me. 我只是尝试了,对我也不起作用。 But the bind command works fine: 但是bind命令可以正常工作:

bind -m vi-command ' "\C-e": end-of-line '

Seems like there's something weird in readline loading .inputrc . 似乎readline加载.inputrc So as a workaround you can put the bind command in your bashrc files. 因此,作为解决方法,您可以将bind命令放入bashrc文件中。

According to Chet Ramey via the bug-bash@gnu.org mailing list, 根据Chet Ramey通过bug-bash@gnu.org邮件列表的说法,

This has been there forever. 这一直存在。 The default readline vi command-mode keymap has ^E bound to switch to emacs editing mode. 默认的readline vi命令模式键盘映射已将^ E绑定为切换到emacs编辑模式。 Since bash uses `set -o emacs' for that, the bash readline initialization code unbinds the key sequence. 由于bash为此使用`set -o emacs',因此bash readline初始化代码取消了键序列的绑定。 It needs to make sure that the function it's bound to is still rl_emacs_editing_mode. 它需要确保绑定的功能仍然是rl_emacs_editing_mode。

He provides a patch, which is probably beyond the scope of a SO answer here, so I'll just link to it: http://lists.gnu.org/archive/html/bug-bash/2019-01/msg00217.html 他提供了一个补丁,可能不在此处的SO解答范围内,因此我将其链接至: http : //lists.gnu.org/archive/html/bug-bash/2019-01/msg00217。 HTML

@pynex's workaround works fine. @pynex的解决方法工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM