[ACCEPTED]-Bash CTRL to move cursor between words/strings-bash
With the default readline key bindings, ALT+B goes 5 back one word, ALT+F goes forward one word.
The 4 default Ubuntu setup additionally provides 3 CTRL+arrows like you're used to. These are in 2
/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 1 need three of them...
As Thomas explained, you can add the bindings 10 to
Another alternative so it loads every 9 time you log in, is putting them in
~/.bashrc like 8 this:
#use ctl keys to move forward and back in words bind '"\eOC":forward-word' bind '"\eOD":backward-word'
I learned that you can use
cat > /dev/null to look 7 at the characters that your keyboard is 6 sending, e.g., CTRL + right arrow shows:
^[ is the same as
\e so that's where the code 4 comes from in the
You can also 3 look up bindings like this:
bind -p | grep forward-word
All of this is 2 pretty damn awesome and I'm glad I found 1 out some more power of bash.
A .inputrc in your home directory will cause 3 ctrl+left to stop working on Ubuntu (for 2 example).
To get everything working, add 1 the following to ~/.inputrc:
# Include system-wide inputrc, which is ignored by default when # a user has their own .inputrc file. $include /etc/inputrc
credit to f.kowal
Worked for CentOS Linux release 1 8.2.2004 (Core)
More Related questions