Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

ie:

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 (wether 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
  PATH=$PATH:/home/bleakcabal/.rvm/gems/ruby-2.0.0-p247/bin
  set -o vi
share|improve this question
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 '13 at 4:09
    
Which version of bash do you use? –  Raphael Ahrens Sep 6 '13 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). –  200_success Sep 6 '13 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 '13 at 14:01
1  
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. –  Patrick Sep 7 '13 at 4:10
show 2 more comments

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
add comment

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.