How to move one editing row up (back) or down (forward) in a multi-line command in bash/readline?

Somethnig like gj/gk in Vim.


I'm assuming you're using Emacs keybindings in readline (the default), in which case you can use the following:

  • Ctrl + P - go to previous line
  • Ctrl + N - go to next line

If you prefer vi keybindings, those can be enabled by adding the following to your ~/.inputrc: set editing-mode vi

  • 2
    Yes, emacs mode. But it's not the answer. Ctrl+P/N goes to the previous/next command line. I am asking how to move cursor "screen width" characters back/forward so it's looks like moving one editing line up/down in a (long) multi-line command. – Hans Ginzel Jul 13 '15 at 8:43
  • @HansGinzel Ah, I misunderstood slightly. Unfortunately I can't see anything obvious in the readline documentation. I believe the Emacs equivalent commands would be next-logical-line and previous-logical-line but I don't think readline has anything similar. – mjturner Jul 13 '15 at 9:00

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.