Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have used vi as my main text editor for years now on Linux (and a few years back Mac too) and on my brand new Mac (running 10.8.4) I find when trying to edit a file using vi in Terminal I can not use the standard vi shortcuts e.g. using 'CTRL + E' to navigate to the end of a line. Instead the shortcut is set to the vim shortcut which is '$' to navigate to the end of a line. I a using bash. How can I get the standard vi shortcuts?

share|improve this question

marked as duplicate by Mark, bmike Jul 17 '13 at 21:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

vi in osx is vim. :h and check help file. although check this out… – hoss Jul 17 '13 at 14:12
Are you looking for ^A/^E to work in bash (to navigate in the command line) or inside vi/vim? – patrix Jul 17 '13 at 17:26
up vote 1 down vote accepted
set -o vi

Add that to your ~/.bashrc

If you meant to write "I cannot use the standard bash shortcuts Ctrl-E and Ctrl-A in vim", then add these lines to your ~/.vimrc

map <C-E> $
map <C-A> 0|

If you want these to also work in input insert mode, you also need

map! <C-E> <esc>A
map! <C-A> <esc>0i

These maps for CtrlA send you to the left margin. If you want to go to the first non-space character

map <C-A> ^
map! <C-A> <esc>I
share|improve this answer
This will enable vi mode in bash, not in vim – patrix Jul 17 '13 at 14:55
that's how I interpreted the question, but re-reading I guess you're right. – glenn jackman Jul 17 '13 at 15:01
The answer from this post seeemd to do the trick. Thanks for the very fast responses.… – user53423 Jul 17 '13 at 16:17

Ctrl-a for beginning of line and Ctrl-E for end of line are Emacs shortcuts, not vi. As such, they will not work in vi.

share|improve this answer
Having used vi for years on linux I never realised that these shortcuts are from emacs. I have always used vi and any linux machine I work on has had these shortcuts so I guess they have always been specially enabled without having realised these were not from vi. Thanks for pointing this out. – user53423 Jul 17 '13 at 16:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.