Skip to content

Instantly share code, notes, and snippets.

@vikbert
Last active April 2, 2018 17:07
Show Gist options
  • Save vikbert/352985fffb53c06674ea7e21cce48398 to your computer and use it in GitHub Desktop.
Save vikbert/352985fffb53c06674ea7e21cce48398 to your computer and use it in GitHub Desktop.
[atom] atom editor configuration #atom, #editor

Customize vim editor and keymap

I use commonly key combination jk to do quick switch between INSERT/COMMAND mode in vim. The followings are the configurations for the favorite editors.

to allow quick switch INSERT/COMMAND mode in atom with keys jk, two files need to be configured

content in ~/.atom/init.coffee

atom.commands.add 'atom-text-editor', 'exit-insert-mode-if-proceeded-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')

content in ~/.atom/keymap.cson

'.platform-darwin':
  'cmd-1': 'tree-view:toggle'

'atom-text-editor.vim-mode.insert-mode':
  'k': 'exit-insert-mode-if-proceeded-by-j'

customize the theme

open the stylesheet of current used theme, and added the following CSS:

.editor .gutter .line-number {
    &[class*="git"] {
        padding-left: 0 !important;
        border-left: none !important;
        color: #ffffff;
        opacity: 1;
    }

    &.git-line-added {
        background-color: #73c990;
    }

    &.git-line-modified {
        background-color: #e2c08d;
    }

    &.git-line-removed {
        background-color: rgba(204, 102, 102, 0.6);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment