Certain key mappings not working in MacVim

放肆的年华 提交于 2019-12-01 02:29:57

问题


I've recently switched to using a Mac at work from previously using Linux. I found out about MacVim (from http://code.google.com/p/macvim/) and have been trying to port over my previous keymappings.

The mappings I used to have are as follows:

  • Ctrl-T: New tab
  • Ctrl-W: Close tab/window
  • Ctrl-1 ... Ctrl-0: Switch to numbered tab
  • Alt-Up: New tab (same as Ctrl-T)
  • Alt-Left/Alt-Right: Switch to the previous/next tab
  • Ctrl-Alt-E: Open FuzzyFinder in file mode
  • Ctrl-Alt-B: Open FuzzyFinder in buffer mode
  • Ctrl-Alt-W: Clear trailing whitespace from the buffer

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

nmap <D-t> :tabnew<cr>
nmap <D-w> :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 <C-D-e> :FufFileWithFullCwd<CR>
nmap <C-D-b> :FufBuffer<CR>

"Whitespace remover
nmap <C-D-w> :%s/\s\+$//<CR>

So, after re-mapping the keys, some now work and others don't, with no clear logic as to why.

What works:

  • Cmd-T and Cmd-W successfully work for opening and closing tabs.
  • Cmd-1 ... Cmd-0 successfully work for switching tabs.

What doesn't work:

  • Cmd-Up for opening a tab does not work.
  • Cmd-Left and Cmd-Right for switching tabs does not work.
  • Ctrl-Cmd-E and Ctrl-Cmd-B for opening FuzzyFinder do not work.
  • Ctrl-Cmd-W for clearing whitespace does not work (but neither does it close the tab, as it would without ctrl.

回答1:


Investigate the cause by doing

:verbose map <D-Up>

Additionally try selectively enabling your other plugins to see whether mappings are being cleared somehow




回答2:


So it turns out that there is a bug in Macvim (http://code.google.com/p/macvim/issues/detail?id=317) which means it's not possible to map the ctrl key. Instead I mapped the leader key (a.k.a. the backslash), and it all seems to work now.



来源:https://stackoverflow.com/questions/8078333/certain-key-mappings-not-working-in-macvim

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!