Skip to content

Instantly share code, notes, and snippets.

@kuroda kuroda/init.coffee
Last active Sep 6, 2018

Embed
What would you like to do?
My keymap.cson for Atom Editor
add_line_markers = (marker) ->
editor = atom.workspace.getActiveTextEditor()
range = editor.getSelectedBufferRange()
editor.moveToBeginningOfLine()
s = range.start.row
e = range.end.row
if e > s && range.end.column == 0
e = e - 1
editor.moveUp()
editor.transact ->
for i in [s..e]
do (i) ->
editor.moveToBeginningOfLine()
editor.insertText(marker + ": ")
if i < e
editor.moveUp()
remove_line_markers = () ->
editor = atom.workspace.getActiveTextEditor()
range = editor.getSelectedBufferRange()
editor.moveToBeginningOfLine()
s = range.start.row
e = range.end.row
if e > s && range.end.column == 0
e = e - 1
editor.moveUp()
editor.transact ->
for i in [s..e]
do (i) ->
editor.moveToBeginningOfLine()
editor.selectRight(6)
editor.backspace()
if i < e
editor.moveUp()
toggle_line_marker = () ->
editor = atom.workspace.getActiveTextEditor()
editor.moveToBeginningOfLine()
editor.selectRight(1)
char = editor.getSelectedText()
switch char
when " " then editor.insertText("+ ")
when " " then editor.insertText("+")
when "+" then editor.insertText("-")
when "-" then editor.insertText(" ")
editor.moveToBeginningOfLine()
atom.commands.add 'atom-text-editor',
'custom:insert-review-tag': ->
editor = atom.workspace.getActiveTextEditor()
selectedText = editor.getSelectedText()
editor?.insertText("@<>{#{selectedText}}")
editor?.moveLeft(selectedText.length + 3)
'custom:insert-review-content-tag': ->
editor = atom.workspace.getActiveTextEditor()
editor?.moveToBeginningOfLine()
editor?.insertText("//{\n\n//}\n")
editor?.moveUp(3)
editor?.moveRight(2)
'custom:add-review-line-markers': ->
add_line_markers(" ")
'custom:add-review-line-markers-plus': ->
add_line_markers("+ ")
'custom:add-review-line-markers-minus': ->
add_line_markers("- ")
'custom:remove-review-line-markers': ->
remove_line_markers()
'custom:toggle-review-line-marker': ->
toggle_line_marker()
'atom-workspace':
'alt-p': 'project-manager:list-projects'
'alt-w': 'tabs:close-all-tabs'
'atom-workspace atom-text-editor:not([mini])':
'ctrl-up': 'core:move-up'
'ctrl-down': 'core:move-down'
'atom-text-editor':
'ctrl-shift-space': 'autocomplete-plus:activate'
'ctrl-i': 'editor:select-word'
'ctrl-n': 'bookmarks:view-all'
'alt-n': 'bookmarks:toggle-bookmark'
'ctrl-alt-n': 'bookmarks:clear-bookmarks'
'alt-up': 'bookmarks:jump-to-previous-bookmark'
'alt-down': 'bookmarks:jump-to-next-bookmark'
'ctrl-alt-i': 'custom:insert-review-tag'
'ctrl-alt-u': 'custom:insert-review-content-tag'
'ctrl-alt-y': 'custom:toggle-review-line-marker'
'ctrl-alt-g': 'custom:remove-review-line-markers'
'ctrl-alt-k': 'custom:add-review-line-markers'
'ctrl-alt-j': 'custom:add-review-line-markers-plus'
'ctrl-alt-m': 'custom:add-review-line-markers-minus'
'.platform-win32 atom-text-editor, .platform-linux atom-text-editor':
'ctrl-d': 'editor:delete-line'
'ctrl-shift-B': 'unset!'
'ctrl-k ctrl-c': 'change-case:camel'
'ctrl-k ctrl-s': 'change-case:snake'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.