How do I use the command key in MacVim? For example I would like to be able to press Cmdt to open CtrlP or Cmdn to open NerdTree.
Asked
Active
Viewed 1.4k times
17
-
there is another same question here: http://superuser.com/questions/249448/macvim-re-map-command-key-combinations-like-d-f check it out ;) – Ya Zhuang Nov 17 '14 at 04:18
-
You can browse a list of keys available in the vim via `:help key-notation` – Alan Dong Mar 03 '15 at 02:13
2 Answers
16
See :help <D-
. Use <D-t>
to map to ⌘-T; however, ⌘-T is already mapped to "New Tab" within MacVim's menu. You'll have to remove that to be able to use it in a Vim map.
Some keys are OS-bound and you just can't access them, but ⌘-T can be made available and is actually the example they use in the help file (see :help Actions.plist
and scroll up a few lines to 4.
). You'll need to unset the "New Tab" binding with
:macmenu File.New\ Tab key=<nop>
and then map ⌘-T with nnoremap <D-t> whatever
.

Wilbur Vandrsmith
- 5,040
- 31
- 32

Conner
- 30,144
- 8
- 52
- 73
6
The command key on OS X is known as the Super key in Vim, so you can do the following:
map <D-t> :CtrlP<CR>
map <D-n> :NERDtree<CR>
You can read more about the different key mappings in :help key-notation
. You can't use the command key as a leader because it doesn't lead off a command, but is instead a modifier.

mcandre
- 22,868
- 20
- 88
- 147

Andrew Marshall
- 95,083
- 20
- 220
- 214
-
⌘ may be `M-` in other Vims, but in MacVim it's `D-`. If `'macmeta'` is set, `M-` is trigged by Option/Alt. – Wilbur Vandrsmith Aug 16 '12 at 03:54
-
@WilburVandrsmith Ah you're correct, I was looking at a `
` mapping in my config and picked the wrong one. Thanks! – Andrew Marshall Aug 16 '12 at 03:59 -
3I just tried mapping `D-`, `A-` and `M-` and they all doesn't work. I'm trying to accomplish the same thing as you which is to create aliases for `CtrlP` and `NERDTree`. How did you make it work? – Jun 23 '14 at 01:24