I'm running vim on a Linux VM that I'm ssh'd into via Mac OS X's Terminal app, and I want to configure it to do useful things with my arrow keys (among others).

For example, I want option-left to move the cursor back one word, similarly to how it works in other Mac applications.

In normal mode, this is easy enough; I can simply map the sequence to b. But when I'm in insert mode, I want to stay in insert mode (i.e., map the sequence to <c-o>b.

In my .vimrc` file, I have these lines:

nmap ^[[xol~ b
imap ^[[xol~ <c-o>b

Where ^[[xol~ is the character sequence that I've configured Terminal to send when I press option-left.

This works, but it gets pretty tedious, especially when I've got nearly two dozen commands that I want to map.

Is there a better way to do this?

2 Answers 2


Yes, there is a better way. Download and install MacVim, it comes with a lot of Mac OS X keybindings by default and some more if you add a simple option (which I don't have at hand) to your .vimrc. Plus it supports more colors than Terminal.app and is better integrated in the OS than CLI Vim.

IMO your fixation on having Mac OS X keybindings in vim in the terminal (of all places) and to stay in INSERT mode are quite big obstacles on an already steep learning curve. You should leave INSERT mode as soon as you are done with actual text insertion and just use Vim's amazing power in a more productive way.

If you want a modeless CLI editor you may try emacs, joe or nano ranked from über powerful to really simple. If you want a modeless GUI editor you may try TextMate or Sublime Editor but none will be remotely as powerful as Vim.

  • Thanks for the suggestion, but I'm actually running vim on a Linux VM, so Mac applications aren't an option for me in this case (I've updated the question updated to reflect this).
    – user67218
    Jun 22, 2011 at 12:00
  • @Phoenix — It doesn't change anything to the fact that you want to use Vim in a very unproductive/unnatural way. That said, I don't see a better way to achieve your goal. You'll need to remap all of Vim's basic commands to escape sequences just like you did for b, that's a lot of commands and you are going to come out of keys and Mac OS X keybindings quickly. Seriously, learn the proper way it will pay very quickly.
    – romainl
    Jun 22, 2011 at 12:36

Creating the separate mappings for each mode seems to do the trick. Perhaps that is the best way to do it.

You must log in to answer this question.