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?


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.)

  • 3
    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
  • 1
    @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
  • 1
    I was able to get it to work without ampersand: macmenu File.Print key=<nop> – romaninsh Oct 12 '12 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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