I'm trying to get it to be like default text editing in Mac. I tried
map! <D-Left> 0
map! <D-Right> $
in ~/.vimrc, but of course it didn't work. How can i do this?
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-Right> (respectively, to
<Home> (nearly identical to
<End> (identical to
$)). One caveat is that these default mappings are established in
$VIM/gvimrc, so they can only be properly overridden from your
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:
~/.gvimrc. Since MacVim’s
<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”.