VimMode.spoon icon indicating copy to clipboard operation
VimMode.spoon copied to clipboard

How to map double keypress of escape to normal-mode

Open chancez opened this issue 2 years ago • 2 comments

Hey, I really like VimMode.spoon overall, and I have too much muscle memory to enter normal mode with anything other than escape (I tried jk and a few others). So far using escape hasn't been a big deal, except sometimes I need to use escape to exit from some prompt/modal in the application I'm using.

Here's my config:

local VimMode = hs.loadSpoon('VimMode')
local vim = VimMode:new()

vim
  :disableForApp('Code')
  :disableForApp('MacVim')
  :disableForApp('kitty')
  :disableForApp('iTerm2')
  :disableForApp('zoom.us')
  :enterWithSequence('jk')
  :bindHotKeys({ enter = { {'ctrl'}, ';'} })
  :bindHotKeys({ enter = { {}, 'escape'} })

What I'm wondering is if it's possible to do the following:

  • map escape to insert mode and double escape to leave "vim mode" (and maybe even send the escape keypress after). Ie: I want to use single escape while typing to go into insert mode, but use double escape to send the escape key to the application directly ("not get intercepted by vim mode").

If not, is it possible to adapt enterWithSequence to work of leaving vim-mode? And in general, how might I potentially programmatically send a key press in Hammerspoon (so I can send escape after going to insert mode).

chancez avatar Mar 09 '22 23:03 chancez

I'd also very much love this.

megalithic avatar Aug 09 '22 20:08 megalithic

thx

raymond8825 avatar Aug 10 '22 06:08 raymond8825