Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

(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

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).

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

like image 222
Geo Avatar asked Jun 21 '12 06:06

Geo


People also ask

How do you move the cursor in putty?

Left and Right keys move the cursor one single char. Home and end keys move the cursor to the beginning and end of line resp. Ctrl + A and Ctrl + E combos bring my cursor to the beginning and end resp. This is the behaviour I would like for all my shells.

Which arrow key is used to move the cursor right?

When using word processors, the 'up arrow' moves your cursor up one line of typed characters at a time, the 'down' arrow moves it down one line of typed characters at a time. The left and right arrows move the cursor one character to the left or right. To move more than one character, press the key continually.

Which keys are used to move the cursor left and right?

Press w (“word”) to move the cursor to the right one word at a time. Press b (“back”) to move the cursor to the left one word at a time. Press W or B to move the cursor past the adjacent punctuation to the next or previous blank space.


1 Answers

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

~/.bashrc:

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

~/.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.

like image 135
n. 1.8e9-where's-my-share m. Avatar answered Oct 14 '22 04:10

n. 1.8e9-where's-my-share m.