vimcmdmappingkey-bindingsnerdtree

How do I map CMD (Command ⌘) to shift MacVim window


I know that I can use ctrl+w to shift between different Vim windows. But how do I remap the CMD-key to replace ctrl+w in various way? I'm specifically looking to bind cmd with the arrow keys, so that I can shift to NERDTree easily with CMD+LeftArrow. Appreciate the assistance.

I've tried to add the following to $MYVIMRC...

nmap <silent> <D-h> :wincmd h<CR>   // For going to NERDTree 
nmap <silent> <D-l> :wincmd l<CR>   // For going back to file I'm working on.

Solution

  • In the left-hand side of a mapping, Command+Left is written <D-Left>. With this and other issues fixed (see below), your mappings should look like this:

    nnoremap <D-Left> <Cmd>wincmd h<CR>
    nnoremap <D-Right> <Cmd>wincmd l<CR>
    

    or, simply, like this:

    nnoremap <D-Left> <C-w>h
    nnoremap <D-Right> <C-w>l
    

    Other issues:

    Note that these mappings only work in the MacVim GUI.