I am using the bash shell with the XFCE4 terminal. I have configured the shell so that it is in Vi mode.

I have done this by adding the following line in my ~/.bashrc file:

set -o vi

When in a shell in Normal Mode, the first character I press gets inputed in Normal Mode but then I get thrown in Insert Mode.


I am in Normal Mode. If I press b, I will go back one word and get dropped in Insert Mode.

If I press bb, I will have got back one word, enter Insert Mode and then insert the b character.

Another example, if I press dd, the first d will be caught by Normal Mode, I will then go to Insert Mode where the second d will be inserted.

If I manually enter set -o vi in the shell (whether it is in my .bashrc or not) I will not get this behaviour and instead get the normal behaviour. I know the change in my .bashrc is getting read as I am not in Emacs mode.

I am using bash 4.2.45(1)-release.

Here is the full content of my .bashrc:

  PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
  set -o vi
  • 4
    I've been using vi since before Bill Joy was born but have never had a productive experience with bash/readline vi-mode. I suggest giving up while you still have your sanity.
    – msw
    Sep 6, 2013 at 4:09
  • Which version of bash do you use? Sep 6, 2013 at 9:08
  • 1
    I agree with @msw. Even though love vi and can't stand Emacs, I just stick with the default Emacs mode in bash. If I ever need to do serious command-line editing, I hit C-x C-e, which brings up the previous command in $VISUAL or $EDITOR (which is set to vim, of course). Sep 6, 2013 at 9:18
  • @msw Ok I hadn't considered that. I have started learning Vim 2-3 weeks ago and I would have thought it would be a good idea to use the same shortcuts for both productivity and learning reasons.
    – Gilles
    Sep 6, 2013 at 14:01
  • 4
    The behavior you're describing is emacs mode. I know you stated that you're in vi mode, but you're not. That behavior you described is exactly how emacs mode behaves (try set -o emacs and you'll see). I also have to disagree with msw on using vi mode. I've been using vi mode in my shell for years, and I couldn't live without it.
    – phemmer
    Sep 7, 2013 at 4:10

2 Answers 2


I fixed my problem after reading the comment from @Patrick

The behavior you're describing is emacs mode.

Which made me realise I wasn't in vi mode. I also put the

set -o vi

Line in my .bash_profile and now everything works fine. Which is weird because from what I read .bash_profile is used for login shells and .bashrc for interactive non-login shells which I would believe is my situation.


Your problem is that you are still in emacs-mode. However, I think a better way is to change your .inputrc file, rather than .bashrc. That way everything using GNU readline stays consistent with your shell (and it works for other shells than bash).

I add the following to my .inputrc. It gives me vi-mode by default, and also puts me in vi's "normal"-mode by hitting the keys j and k quickly in succession. Since those keys are on the home row, it is much easier than reaching for esc, and "jk" is a surprisingly rare combination in text.

# Make GNU readline (including bash) use vi-mode
set editing-mode vi
set vi-ins-mode-string \1\e[6 q\2
set vi-cmd-mode-string \1\e[2 q\2
set keymap vi-insert
"jk": vi-movement-mode

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .