0

I've asked this question over on AskDifferent without any luck.

I'm using neovim to edit code and am needing to create a mapping to bind to <cmd-w> to <C-w>.

How would I go about this on macOS?

In fact I am unable to bind anything to <cmd-...> as my terminal seems to be intercepting the instruction for an OS-level key binding.

The only way I've thought to get around this is to use Karabiner-Elements; yet, I am not competent enough to write an application-specific key binding just for neovim.

  • macOS: Catalina 10.15.7

  • Terminal: Alacritty@latest

  • neovim: v0.4.4

  • karabiner-elements-@latest

11
  • I think you should give more details on what you actually want to do with your mapping (because that might be a XY problem. You can't map only a modifier key in vim/neovim so you can't only map ctrl -> Cmd but maybe you want to map a specific command? You could write nnoremap <C-a> <M-a this way when you press ctrl+a neovim with interpret it as cmd+a, M being the key code for Cmd on Mac :h keycodes
    – statox
    Mar 19 at 17:03
  • @statox the only functionality I require with the command key would be binding it to <C-w> in order to provide window navigation support to my thumb. Which, is currently missing.
    – Bdyce
    Mar 19 at 17:07
  • You want only the command key? I don't think modifier keys can be used alone. vi.stackexchange.com/questions/2380/…
    – B Layer
    Mar 19 at 17:07
  • @BLayer how about <cmd-w> <C-w>?
    – Bdyce
    Mar 19 at 17:09
  • 2
    @BLayer all good, thank you. I'll have to solve it by reading the karabiner docs... was hoping someone with sore pinkies had an easy plug-and-play mapping. The whole thing is in JSON so not too bad; I'll post the answer here when I figure it out. Adn thanks! Don't know how I survived without vim before.
    – Bdyce
    Mar 19 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.