Emacs and Terminal Key-Bindings
I finally bothered to find out how to make, for example, Ctrl-rightarrow, do what I want it to do in BASH and also Emacs terminal (-nw) sessions. . .
Emacs
.emacs:
(global-set-key "\M-[1;5C" 'forward-word) ; Ctrl+right->forward word (global-set-key "\M-[1;5D" 'backward-word) ; Ctrl+left-> backward word ;; ;; Ctrl-V followed by the key combo (e.g., Ctrl-rightarrow) reveals the ;; code required. ;; (global-set-key "\M-[1;5A" 'backward-paragraph) (global-set-key "\M-[1;5B" 'forward-paragraph)
Terminal
BASH uses the readline lib to read input and this is configured useing /etc/inputrc, or ~/.inputrc.
For some reason, /etc/inputrc on some boxes includes the lines labelled ...added... below, while some include only those labelled ...existing....
To determine the required character sequence, use
Ctrl-V <key-sequence>
.inputrc or /etc/inputrc:
# # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving # "\e[1;5C": forward-word "\e[1;5D": backward-word # # ...added... # "\e[5C": forward-word "\e[5D": backward-word "\e\e[C": forward-word "\e\e[D": backward-word # # ...existing... #