I wanted to try vi mode in bash but now I would like to change it back to normal.

How can I unset -o vi ?


The only two line editing interfaces currently available in bash are vi mode and emacs mode, so all you need to do is set emacs mode again.

set -o emacs
  • 1
    It should be noted that this was me reading between the lines rather than answering the question directly. emacs is the default line editing mode in bash. Setting emacs mode disables vi mode as a side effect, but as mentioned by jlliagre below, you can actually disable them both.
    – Chris Down
    Dec 25 '12 at 11:37

That depends on what you define "normal". If that's turning off line editing, the documented way to unset -o vi is to set +o vi

$ set -o vi
$ set -o|egrep -w "(vi|emacs)"
emacs           off
vi              on
$ set +o vi
$ set -o|egrep -w "(vi|emacs)"
emacs           off
vi              off

Chris has already answered if your normal mode is emacs.

  • turning off the mode(s) also takes away the shell history feature, now I cannot use up/down arrow keys to see command history :(
    – rsjethani
    Dec 24 '12 at 21:39
  • 2
    It doesn't take away the shell history feature. You can still view your history with the history command and run previous commands by prefixing their number with the ! character.
    – jlliagre
    Dec 24 '12 at 22:53
  • yes 'history' n family commands still work but the up/down arrow keys which I use more frequently do not work. As soon as I turn any of the modes on keys start working...I don't understand?
    – rsjethani
    Dec 25 '12 at 7:57
  • 3
    The up/down arrows are only managed by the shell if line editing is enabled (i.e. one of emacs or vi mode is set). Otherwise, the arrows keys just send their escape sequence unprocessed.
    – jlliagre
    Dec 25 '12 at 9:59

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.