Putty / Bash alt + 向左/向右箭头键按单词移动光标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11132866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 02:32:44  来源:igfitidea点击:

Putty / Bash alt + left/right arrow key to move cursor by word

bashkeyboard-shortcutsputty

提问by Geo

I can't get this putty to handle alt + left/right properly.

我无法让这个腻子正确处理 alt + 左/右。

(Edit: By "properly", I obviously mean the way I have grown used to moving the cursor about;-)

(编辑:通过“正确”,我显然是指我已经习惯于移动光标的方式;-)

Usually I can do:

通常我可以这样做:

cat > /dev/null
..<hold alt and left arrow>..

to get the proper key. In this case I get: ^[^[[D

以获得正确的密钥。在这种情况下,我得到:^[^[[D

I then proceed to do:

然后我继续做:

bind '^[^[[D:backward-word'

I've also tried:

我也试过:

bind '\e\e[D:backward-word'

Please note that this problem is the same in screen (with TERM=screen) and outside of screen (with TERM=xterm).

请注意,此问题在屏幕内(使用 TERM=screen)和屏幕外(使用 TERM=xterm)是相同的。

Any tips on what I should try next? Any putty options that need to be enabled/disabled?

关于我接下来应该尝试什么的任何提示?任何需要启用/禁用的腻子选项?

回答by n. 'pronouns' m.

This format of binddoesn't work for me either for some reason, but I've had success with bind -f.

bind由于某种原因,这种格式对我也不起作用,但我已经成功使用bind -f.

~/.bashrc:

~/.bashrc:

if [ -f ~/.readline-bindings ] ; then
    bind -f ~/.readline-bindings
fi

~/.readline-bindings:

~/.readline-bindings:

"\e[1;3D": backward-word
"\e[1;3C": forward-word

Note the space after the :character. Obviously you should use your own control sequence here.

注意:字符后面的空格。显然你应该在这里使用你自己的控制序列。