dbalatero / VimMode.spoon

Adds vim keybindings to all OS X inputs
694 stars 33 forks source link

How to exit normal mode with Escape #102

Open himat opened 1 year ago

himat commented 1 year ago

I see that I can press jk to enter normal mode. But it seems like only pressing i can let me go into insert mode - normally that's fine in vim, but I feel like when using vimmode.spoon I actually want the opposite.

Or at least, I'd like to be able to press Escape to leave the vimmode.spoon normal mode and go back to the regular OS. Is there a config I can use for that?

himat commented 1 year ago

@dbalatero

zengtianli commented 1 year ago

Also want this feature or config

zengtianli commented 1 year ago

I see that I can press jk to enter normal mode. But it seems like only pressing i can let me go into insert mode - normally that's fine in vim, but I feel like when using vimmode.spoon I actually want the opposite.

Or at least, I'd like to be able to press Escape to leave the vimmode.spoon normal mode and go back to the regular OS. Is there a config I can use for that?

this is my config snippet in init.lua

-- Enter normal mode by typing a key sequence
-- vim:enterWithSequence('jk')
vim:bindHotKeys({ enter = { {}, 'escape' } })

works for me

Pandoks commented 2 months ago

I think that the function should also have an exit property so something like:

vim:bindHotKeys({ enter = { { "ctrl" }, ";" }, exit = { "escape" })

But besides that, if you go into <your hammerspoon config directory>/Spoons/VimMode.spoon/lib/modal.lua and you find -- Normal mode which is at around line 266, add :bind({}, <your key here>, function() vim:exitAsync() end) under :bind({}, 'i', function() vim:exitAsync() end) and it should work.