Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 14 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>
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.)

share|improve this answer
2  
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
    
I was able to get it to work without ampersand: macmenu File.Print key=<nop> –  romaninsh Oct 12 '12 at 10:08
add comment

Your Answer

 
discard

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.