Some key mappings not working in MacVim

I recently switched to using a Mac at work due to the use of Linux. I found out about MacVim (from http://code.google.com/p/macvim/ ) and tried to wrap my previous key mappings.

The mappings I used are as follows:

  • Ctrl-T : new tab
  • Ctrl-W : close tab / window
  • Ctrl-1 ... Ctrl-0 : go to the tab with numbers
  • Alt-Up : new tab (same as Ctrl-T )
  • Alt-Left / Alt-Right : go to previous / next tab
  • Ctrl-Alt-E : Open FuzzyFinder in File Mode
  • Ctrl-Alt-B : Open FuzzyFinder in Buffer Mode
  • Ctrl-Alt-W : clear whitespace from buffer

Now, to make these mappings more “Mac-like,” I decided to switch the first two to use the option key (ie the Apple logo), and the rest to use the command key instead of Alt (ie Ctrl-Alt-E becomes Ctrl-Command-E ). I read http://macvim.org/OSX/index.php that this key can be mapped to D (i.e.). The new contents of my .vimrc are as follows:

nmap <Dt> :tabnew<cr> nmap <Dw> :close<cr> nmap <D-1> 1gt nmap <D-2> 2gt nmap <D-3> 3gt nmap <D-4> 4gt nmap <D-5> 5gt nmap <D-6> 6gt nmap <D-7> 7gt nmap <D-8> 8gt nmap <D-9> 9gt nmap <D-0> 10gt nmap <D-Up> :tabnew<CR> nmap <D-Right> :tabnext<CR> nmap <D-Left> :tabprevious<CR> "FuzzyFinder nmap <CDe> :FufFileWithFullCwd<CR> nmap <CDb> :FufBuffer<CR> "Whitespace remover nmap <CDw> :%s/\s\+$//<CR> 

So, after re-matching the keys, some of them work, while others do not, without a clear logic of why.

What works:

  • Cmd-T and Cmd-W work successfully to open and close tabs.
  • Cmd-1 ... Cmd-0 successfully works for switching tabs.

What does not work:

  • Cmd-Up to open a tab does not work.
  • Cmd-Left and Cmd-Right to switch tabs does not work.
  • Ctrl-Cmd-E and Ctrl-Cmd-B to open FuzzyFinder do not work.
  • Ctrl-Cmd-W to clear spaces does not work (but also does not close the tab, as it would without ctrl .
+7
source share
2 answers

So it turns out that there is an error in Macvim (http://code.google.com/p/macvim/issues/detail?id=317), which means that it is not possible to match the ctrl key. Instead, I matched the leader key (aka backslash), and now it all works.

+5
source

Examine the reason by doing

 :verbose map <D-Up> 

Also, try selectively enabling your other plugins to see if the mappings are cleared somehow

+7
source

All Articles