Skip to content

Instantly share code, notes, and snippets.

@benwells
Last active April 2, 2016 19:12
Show Gist options
  • Save benwells/60180bac6a27dcb309b28faa98b9c485 to your computer and use it in GitHub Desktop.
Save benwells/60180bac6a27dcb309b28faa98b9c485 to your computer and use it in GitHub Desktop.
Override escape with jk for use with atom's vim-mode
# ~/.atom/init.coffee
atom.commands.add 'atom-text-editor', 'exit-insert-mode-if-preceded-by-j': (e) ->
editor = @getModel()
pos = editor.getCursorBufferPosition()
range = [pos.traverse([0,-1]), pos]
lastChar = editor.getTextInBufferRange(range)
if lastChar != "j"
e.abortKeyBinding()
else
editor.backspace()
atom.commands.dispatch(e.currentTarget, 'vim-mode:activate-normal-mode')
'atom-text-editor.vim-mode.insert-mode':
'k': 'exit-insert-mode-if-preceded-by-j'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment