Can I use the `<cmd>` key in terminal Vim at all?

<D-> only works in MacVim.

A quick google will return a bunch of hacks and third party solutions. All the solutions I know either work system-wide or are application-specific: if you remap Cmd in iTerm2 only, how are you going to open a new window or a new tab? With… with… the… MOUSE?

I can't imagine a good reason to remap the Cmd key to anything on a Mac. That would be insane.

Vim is not TextMate or whatever other editor you have used before. There is no way to transfer all your old habits seamlessly, point blank.

Instead of wasting your time trying to make Vim and your terminal into something that it's not and can't be you should learn how to use and customize Vim wisely. All your Cmd+Shift+Ctrl+Alt combos won't lead you anywhere. Especially in a terminal where Alt is often problematic and Cmd unusable.

Consider using <leader> (:help leader):

  • it's portable on every platform
  • it's less prone to conflicts with your OS or terminal emulator
  • it opens a lot of easy to remember possibilities

I found that iterm2 has an option in the keyboard settings to do this kind of thing. For ex below I mapped command-enter to be :wq

enter image description hereenter image description here


For simple commands there is a solution via sending the appropriate hex code to the terminal. For instance, I wanted to save in vim by pressing cmd-s. I mapped cmd-s in iterm2 to send the hex code 0x13 which is the code for ctrl-s, then I mapped ctrl-s to :wq in vim.