Last active
August 29, 2015 14:25
-
-
Save drbraden/d4a3a1caf09429d0b842 to your computer and use it in GitHub Desktop.
Allow "jj" to exit insert mode in Atom (working as of 1.0.2)
This file contains 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
# Slightly modified version created by rdlugosz at https://github.com/atom/vim-mode/issues/334#issuecomment-85603175 | |
#keymap.cson | |
'atom-text-editor.vim-mode.insert-mode': | |
'j': 'exit-insert-mode-if-preceded-by-j' | |
#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-command-mode') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment