18

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?

1 Answer 1

21

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

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

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

4
  • 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>. Sep 22, 2011 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, 2011 at 20:54
  • 1
    I was able to get it to work without ampersand: macmenu File.Print key=<nop>
    – romaninsh
    Oct 12, 2012 at 10:08
  • Thanks! Worked for me. Though with a slight modification: macmenu File.Close key=<nop> Dec 24, 2019 at 11:56

You must log in to answer this question.

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