Bash CTRL to move cursor between words/strings

后端 未结 4 1166
深忆病人
深忆病人 2020-12-22 17:41

I am use to using the CTRL key to move faster when using the left and right arrow keys (goes to end of a word, instead of one char at a time).

Can I do

4条回答
  •  自闭症患者
    2020-12-22 18:17

    With the default readline key bindings, ALT+B goes back one word, ALT+F goes forward one word.

    The default Ubuntu setup additionally provides CTRL+arrows like you're used to. These are in /etc/inputrc and specified as follows:

    # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
    "\e[1;5C": forward-word
    "\e[1;5D": backward-word
    "\e[5C": forward-word
    "\e[5D": backward-word
    "\e\e[C": forward-word
    "\e\e[D": backward-word
    

    Not sure why we need three of them...

提交回复
热议问题