Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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'm trying to get it to be like default text editing in Mac. I tried map! <D-Left> 0 and map! <D-Right> $ in ~/.vimrc, but of course it didn't work. How can i do this?

share|improve this question
up vote 7 down vote accepted

As far as I know, the Command key modifier syntax (<D-...>) is only effective in GUI-mode instances of Vim on Mac OS X.

The Vim instance must be GUI-based because most terminal emulators (Terminal, iTerm, etc.) do not generate control sequences for Command key combinations, so a tty-only instance of Vim has no way to know that a Command key combination was ever pressed (the terminal emulator never sends anything across the tty interface). In fact, Terminal binds ⌘← and ⌘→ (Command-Left and -Right) to cycling through its open windows, so those keys are “already taken” when you are typing in the context of Terminal.

MacVim (when run in GUI mode) does come with functional mappings for (among other Mac-style keystrokes) <D-Left> and <D-Right> (respectively, to <Home> (nearly identical to 0) and <End> (identical to $)). One caveat is that these default mappings are established in $VIM/gvimrc, so they can only be properly overridden from your ~/.gvimrc.

I think there have been other GUI-based versions of Vim for Mac OS X, but MacVim seems like the only modern one.

Roughly, the startup files are processed in this order: $VIM/vimrc, ~/.vimrc, $VIM/gvimrc, ~/.gvimrc. Since MacVim’s $VIM/gvimrc maps <D-Left>, you need to put your mapping of <D-Left> (if you actually want to override it) in your ~/.gvimrc so that it has the “final say”.

share|improve this answer
thanks. i tried iTerm 2, it worked with that, but still...what a pain...welcome back into my life, Xcode – Marty Jan 22 '12 at 4:17

Your Answer


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.