8

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?

1
  • They move between lines... just that the line is very long.
    – vonbrand
    May 4, 2013 at 1:58

6 Answers 6

11

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.

1
5

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.

1
3

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

3
  • Xiki looks amazing! I want something like that that can run on windows...
    – Max
    May 10, 2013 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
    – jason
    May 11, 2013 at 17:34
  • 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, 2013 at 23:22
3

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.

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

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

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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