coolwanglu / neovim-e

Electron UI for Neovim
MIT License
271 stars 29 forks source link

cmd -> ctrl option in OS X #58

Open trusktr opened 8 years ago

trusktr commented 8 years ago

Would be super nice if you could make command send ctrl key in OS X so it's easy to use command key as ctrl key (similar to the popular iTerm2 app for OS X).

expipiplus1 commented 8 years ago

Neovim supports the GUI passing the command key already: https://github.com/neovim/neovim/commit/99d4c8c29c4a9371c268cc20e4805709d86fb686

trusktr commented 8 years ago

@expipiplus1 So, do I have to map everything? As in

map <d-a> <c-a>
map <d-b> <c-b>
map <d-c> <c-c>
map <d-d> <c-d>
map <d-e> <c-e>
" ...

I'd like just a global option that makes command behave as control (like iTerm), so that those mappings aren't even required. So, for example, I would like to only have to do

noremap <c-s> :w<cr>

instead of

map <d-s> <c-s>
noremap <c-s> :w<cr>

then pressing command+s would trigger <c-s>, not <d-s>.

The thing is, my caps lock key in OS X sends command. In iTerm, it converts all command to control, so I can press capslock+c and the terminal sees it as control+c. The idea here would be similar to that. Making a mapping for every single key is possible (and I'll do that if it's my only option), but a global setting would be nicer. This would need to be done on the app level (electron) probably.

trusktr commented 8 years ago

Well, it works!

            map <d-a> <c-a>
            map <d-b> <c-b>
            map <d-c> <c-c>
            map <d-d> <c-d>
            map <d-e> <c-e>
            map <d-f> <c-f>
            map <d-g> <c-g>
            map <d-h> <c-h>
            map <d-i> <c-i>
            map <d-j> <c-j>
            map <d-k> <c-k>
            map <d-l> <c-l>
            map <d-m> <c-m>
            map <d-n> <c-n>
            map <d-o> <c-o>
            map <d-p> <c-p>
            map <d-q> <c-q>
            map <d-r> <c-r>
            map <d-s> <c-s>
            map <d-t> <c-t>
            map <d-u> <c-u>
            map <d-v> <c-v>
            map <d-w> <c-w>
            map <d-x> <c-x>
            map <d-y> <c-y>
            map <d-z> <c-z>

            " rest of mappings as normal...

LOL 😆

trusktr commented 8 years ago

Wait, nevermind, it only works in terminal neovim (iTerm). Electron still intercepts things like command+c and invokes the edit->copy menu item, etc, etc.

If I try command+w (or capslock+w in my case) to do a window command, the electron closes the window! So, those mappings aren't the solution. It would have to be an electron setting to send command as control.

trusktr commented 8 years ago

Hmmm, and I tried one that isn't intercepted by electron, but that doesn't even work:

map <d-s> <c-s>
noremap <c-s> :echo "hello"<cr>

but pressing command+s doesn't do anything.

expipiplus1 commented 8 years ago

neovim-e will have to implement this functionality, it looks as though iterm does it already.

Apologies for not being more clear in my earlier message, I was in a bit of a hurry.

trusktr commented 8 years ago

@expipiplus1 It's all good! Asked at electron/electron: https://github.com/electron/electron/issues/5261