Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command key in MacVim

Tags:

vim

macvim

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.

like image 548
Andy Avatar asked Aug 16 '12 00:08

Andy


People also ask

How to use command key in Vim?

Click the box next to "Keyboard Shortcut" and then press ⌘P – you should see it appear in the box. Then, choose the "Send Text with 'Vim' Special Characters" option from the "Action" dropdown. Then, simply type the Vim binding you want to map this key to, like \<C-p> or \<C-s> .

What is MVIM?

Acronym. Definition. MVIM. Move to Memory Immediate. Copyright 1988-2018 AcronymFinder.com, All rights reserved.


2 Answers

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.

like image 53
Conner Avatar answered Sep 18 '22 18:09

Conner


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.

like image 35
Andrew Marshall Avatar answered Sep 17 '22 18:09

Andrew Marshall