Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

My favorite text editor beeing VIM made me add the follwing line to my ~/.bashrc

set -o vi

As expected, hitting escape lets me execute a vi command, BUT ONLY ONE ?!? For example if I do this:

escape, b, b

it jumps to the beginning of the word and then types "b" to the line instead of jumping another word back.

This happens on all my osx boxes (10.6 and 10.7) and non of the linuxes I use.

Anyone else experiencing this? Or is this expected?

share|improve this question
    
Hmm, works as expected here, what other settings do you have defined? Maybe you can add the output of set -o to your question (or post it as a comment for somebody with editing rights to add)? –  patrix Jan 2 '12 at 11:09
    
Thanks for that, I created a ~/.bashrc with only set -o vi and it seems that terminal ignores it because set -o shows emacs on... investigating further, hints welcome... –  anonymous tekkie Jan 2 '12 at 12:16
    
Try to run bash --norc --noprofile and set vi mode manually. If this works the problem is in one of the init files. –  patrix Jan 2 '12 at 12:19
    
Yep, that fixed it. osx terminal is starting bash as login shell. created a ~/.profile with if [ -f ~/.bashrc ]; then . ~/.bashrc fi this way I only have to worry about the rc and can copy it between systems. Thanks for hints patrx –  anonymous tekkie Jan 2 '12 at 12:29
1  
I'm having the exact same issue. I have my default shell set to zsh rather than bash and generally use iTerm rather than termal, but I removed my .profile and .zshrc files and tried in terminal as well and same issue? any other insights? –  Kurt Harriger Oct 24 '12 at 16:52

3 Answers 3

You can use C-xC-e to go into editor mode. This will use vim if your $EDITOR is set to vim. Also, if you switch to zsh there are options to have a psuedo-normal mode on the command line. See this blog post describing it: http://www.civet.ws/?p=165

share|improve this answer

If you're using set vi then C-xC-e will not open your editor as Conner suggested. Instead, use Escv.

share|improve this answer

This problem can come up when you have both ~/.bash_profile (or ~/.profile) and ~/.bashrc files with different settings. To determine if this is your issue, try typing these commands to start a "clean" bash prompt and set vi mode therein:

bash --norc --noprofile
set -o vi

If the vim keybindings don't vanish after one movement, then read on.

The fix for me was first to change ~/.bash_profile to only read:

[ -r ~/.bashrc ] && . ~/.bashrc

Then I put the set -o vi option in ~/.bashrc.

For me, it was no problem for .bash_profile to refer exclusively to .bashrc. Notably, command-line tools with automagic installers like [gvm|http://gvmtool.net/] and [rvm|http://rvm.io/] may manipulate your .bash_profile file, so you may need to set it back after an install or update of those.

share|improve this answer

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.