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.

In text editors, if I press the up and down arrow keys, it moves the cursor between lines of text.

In Bash, if I’m typing a long command that spans multiple lines and I press the up and down arrow keys, it cycles through the command history.

I want the former behavior in Bash. Is this possible? If not, is there any way to move the cursor directly up or down in a multi-line command?

share|improve this question
    
They move between lines... just that the line is very long. –  vonbrand May 4 '13 at 1:58

6 Answers 6

up vote 11 down vote accepted

No, it's not possible. Bash uses GNU Readline to handle interactive line input. There is no command in Readline that moves between display lines as you desire, nor is there a configuration variable comparable to the line-move-visual variable of GNU Emacs that causes next-line and previous-line to move by display lines.

share|improve this answer
    
Disappointing, but thanks! And I think the answers to another question would be useful to people with this same question: stackoverflow.com/questions/657130/… –  Frungi May 11 '13 at 23:15

What I do is press CTRL + Left Arrow and it will leap to the first letter after the last space found. You can quickly get to where you need by doing this.

share|improve this answer
1  
That's a non-standard key binding. The standard key binding for moving backwards by one word is Alt+b. See cnswww.cns.cwru.edu/php/chet/readline/rluserman.html#SEC5 –  sleske May 5 '13 at 10:42

Maybe you're looking for something like xiki. It's like a shell/text-editor.

Here's a video demo: http://youtu.be/bUR_eUVcABg

share|improve this answer
    
Xiki looks amazing! I want something like that that can run on windows... –  Max May 10 '13 at 7:12
2  
@Max according to the projects github page, "We just patched el4r, so there's a chance Xiki might work in windows." You can check it out here: github.com/trogdoro/xiki –  not__p May 11 '13 at 17:34
    
thanks for the tip –  Max May 11 '13 at 22:00
    
This is startlingly neat and nerdy, but really not what I was wanting to do. I just wanted to use Bash or some other common shell. Thanks, though! –  Frungi May 11 '13 at 23:22

You can use Ctrl+Left and Ctrl+Right to navigate through words rather than characters, and Home and End to go to the beginning and the end of the typed command.

share|improve this answer
2  
Also, Ctrl+A to go to the beginning and Ctrl+E to go to the end –  ignis May 4 '13 at 8:35
1  
@ignis you should put that in an answer. –  evilsoup May 4 '13 at 20:49

See also the bash(1) manpage under the heading Commands for Moving section for other navigation shortcuts.

share|improve this answer

Ctrl+A to go to the beginning and Ctrl+E to go to the end of the command.

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.