28

I want to map my NERDTREE toggle to Cmd + space but I don't know what character represents Mac's command key in .vimrc. I searched and found that we can use 'D' to represent cmd key from this link, but it doesn't work. BTW I am using vim from the terminal not MacVim.

UtkarshPramodGupta
  • 6,416
  • 6
  • 25
  • 49

3 Answers3

27

iTerm2 can do this - here I mapped command enter to :wq

enter image description here

Goblinhack
  • 2,523
  • 1
  • 23
  • 26
  • 3
    finally `cmd+/` can comment-out stuff! – Paschalis Oct 31 '19 at 19:03
  • 1
    Send text with "vim" special Chars will also take vim key map style syntax, ie. "\". The leading backslash is required, see https://iterm2-discuss.narkive.com/2T4MenGn/send-text-with-vim-special-chars-sends-literal-chars – Parker Ault Jul 21 '21 at 17:15
26

It is true that <D- maps to command key. You can see it by :help <D-.

However, this will not work in your vim+terminal. It only works in MacVim. See here

The best shot for your intention is to map the combination as hex code, sending to terminal.

Still I will not recommend doing this. command is too important for mac os environment. For example, anyone uses an input method can't map it to command+space.\

Please consider using the usual method here: <leader>.

Community
  • 1
  • 1
halfelf
  • 8,964
  • 13
  • 49
  • 61
1

With IdeaVim you can use: <M-*>

Ed Kolosovsky
  • 1,098
  • 10
  • 17