Super User is a question and answer site for computer enthusiasts and power users. 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 can remap unused combinations like <d-1> (Cmd+1) in MacVim, but there are many combinations like <d-f>, <d-o> or <d-b> that are already bound to MacVim menu items. If I try to remap those inside my .vimrc, nothing changes.

Is there some way I can remap those combinations inside MacVim, or stop MacVim from assigning them to menu items so they are properly passed on to the Vim core?

share|improve this question
up vote 19 down vote accepted

Found it: Command-T recommends using the following snippet:

if has("gui_macvim")
  macmenu &File.New\ Tab key=<nop>
  map <D-t> :CommandT<CR>

So basically you unmap the respective menu item, and then you are free to map the shortcut you were trying to map. (I'm not sure what the ampersand is doing; it works with and without it.)

This must be put in ~/.gvimrc, not ~/.vimrc! (Apparently ~/.vimrc is read too early, so the (un)mappings will be clobbered if you put them there.)

share|improve this answer
I tried this on the current version of MacVim (7.3) and it didn't work. I ended up going into $VIMRUNTIME/menu.vim, searching for <D- and putting a && 0 at the end of the surrounding if statement. Then I copied the contents to my .gvimrc and replaced <D-[^>]*> with <nop>. – dash-tom-bang Sep 22 '11 at 4:06
@dash-torn-bang Hm, my code above seems to still be working OK with 7.3 snapshot 62 on Lion. I didn't have to edit MacVim's menu.vim. I'm not sure why it's working for me but not for you... – Jo Liss Oct 15 '11 at 20:54
I was able to get it to work without ampersand: macmenu File.Print key=<nop> – romaninsh Oct 12 '12 at 10:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .