Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to move left and right by words using ctrl + left/right arrow in terminal (I'm on ubuntu 12.10). Currently when I use these keystrokes I get ;5D or ;5C appended onto the line, which is useless for me.

share|improve this question

2 Answers 2

Use Escb to go backward and Escf to go forward.

See https://www.gnu.org/software/bash/manual/bash.html#Command-Line-Editing

share|improve this answer
    
Thank you, those keystrokes work for me, but do you know any way to bind the ctrl + left/right arrow to do the same thing - perhaps by editing in .bashrc file something? –  wim Dec 21 '12 at 1:46
    
Don't know exactly. Start researching the bind command –  glenn jackman Dec 21 '12 at 11:42
up vote 1 down vote accepted

glenn jackman's answer above pointed me in the right direction, and I've figured it out - add the following lines into file ~/.inputrc:

# 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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.