Skip to content

How to map double keypress of escape to normal-mode #92

@chancez

Description

@chancez

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions