Created
September 28, 2016 16:51
-
-
Save cicloid/5ff16f21c447b503bf1b6dc60367e98b to your computer and use it in GitHub Desktop.
Universal ViM mode using hammerspoon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Modal ViM | |
local function keyCode(key) | |
return function() hs.eventtap.keyStroke({}, key) end | |
end | |
hs.hotkey.bind({"cmd", "alt"}, 'h', keyCode('left') , nil, keyCode('left')) | |
hs.hotkey.bind({"cmd", "alt"}, 'j', keyCode('down') , nil, keyCode('down') ) | |
hs.hotkey.bind({"cmd", "alt"}, 'k', keyCode('up') , nil, keyCode('up') ) | |
hs.hotkey.bind({"cmd", "alt"}, 'l', keyCode('right'), nil, keyCode('right') ) | |
modalVimMode = hs.hotkey.modal.new({"cmd", "alt"}, '\\', "Vimificating") | |
modalVimMode:bind({}, 'h', keyCode('left') , nil, keyCode('left') ) | |
modalVimMode:bind({}, 'j', keyCode('down') , nil, keyCode('down') ) | |
modalVimMode:bind({}, 'k', keyCode('up') , nil, keyCode('up') ) | |
modalVimMode:bind({}, 'l', keyCode('right'), nil, keyCode('right') ) | |
function modalVimMode:exited() | |
-- hs.screen.primaryScreen():setGamma({alpha=1.0,red=0.0,green=0.0,blue=0.0},{blue=1.0,green=1.0,red=1.0}) | |
hs.alert.show("No ViM mode") | |
end | |
modalVimMode:bind({}, 'escape', function() modalVimMode:exit() end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment