Skip to content

Instantly share code, notes, and snippets.

@jimmerricks
Created July 11, 2018 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimmerricks/566ccfb0f538cb0245f9d7e1894b1e83 to your computer and use it in GitHub Desktop.
Save jimmerricks/566ccfb0f538cb0245f9d7e1894b1e83 to your computer and use it in GitHub Desktop.
# Command for alt-up
atom.commands.add 'atom-text-editor', 'custom:move-up': ->
editor = atom.workspace.getActiveTextEditor()
for cursor in editor.getCursors()
if not cursor.isAtBeginningOfLine()
cursor.moveToBeginningOfLine()
else
cursor.moveLeft()
cursor.moveToBeginningOfLine()
# Command for alt-down
atom.commands.add 'atom-text-editor', 'custom:move-down': ->
editor = atom.workspace.getActiveTextEditor()
for cursor in editor.getCursors()
if not cursor.isAtEndOfLine()
cursor.moveToEndOfLine()
else
cursor.moveRight()
cursor.moveToEndOfLine()
# Command for alt-shift-up
atom.commands.add 'atom-text-editor', 'custom:select-up': ->
editor = atom.workspace.getActiveTextEditor()
for cursor in editor.getCursors()
if not cursor.isAtBeginningOfLine()
cursor.selection.selectToBeginningOfLine()
else
cursor.selection.selectLeft()
cursor.selection.selectToBeginningOfLine()
# Command for alt-shift-down
atom.commands.add 'atom-text-editor', 'custom:select-down': ->
editor = atom.workspace.getActiveTextEditor()
for cursor in editor.getCursors()
if not cursor.isAtEndOfLine()
cursor.selection.selectToEndOfLine()
while not cursor.isAtEndOfLine()
cursor.selection.selectRight()
cursor.selection.selectToEndOfLine()
else
cursor.selection.selectRight()
cursor.selection.selectToEndOfLine()
while not cursor.isAtEndOfLine()
cursor.selection.selectRight()
cursor.selection.selectToEndOfLine()
# Command for alt-left
# This is not the same as native mac behaviour and may need tweaking
# atom.commands.add 'atom-text-editor', 'custom:move-left': ->
# editor = atom.workspace.getActiveTextEditor()
# for cursor in editor.getCursors()
# {row, column} = cursor.getScreenPosition()
# range = [[row, column - 1], [row, column]]
# text = editor.getTextInBufferRange(range)
# if cursor.isAtBeginningOfLine()
# cursor.moveLeft()
# else if /\W/.test(text)
# cursor.moveLeft()
# cursor.moveToPreviousSubwordBoundary()
# else
# cursor.moveToPreviousSubwordBoundary()
# Command for alt-right
# This is not the same as native mac behaviour and may need tweaking
# atom.commands.add 'atom-text-editor', 'custom:move-right': ->
# editor = atom.workspace.getActiveTextEditor()
# for cursor in editor.getCursors()
# {row, column} = cursor.getScreenPosition()
# range = [[row, column], [row, column + 1]]
# text = editor.getTextInBufferRange(range)
# if cursor.isAtEndOfLine()
# cursor.moveRight()
# else if /\W/.test(text)
# cursor.moveRight()
# cursor.moveToNextSubwordBoundary()
# else
# cursor.moveToNextSubwordBoundary()
# Command for alt-shift-left
# This is not the same as native mac behaviour and may need tweaking
# atom.commands.add 'atom-text-editor', 'custom:select-left': ->
# editor = atom.workspace.getActiveTextEditor()
# for cursor in editor.getCursors()
# {row, column} = cursor.getScreenPosition()
# range = [[row, column - 1], [row, column]]
# text = editor.getTextInBufferRange(range)
# if cursor.isAtBeginningOfLine()
# cursor.selection.selectLeft()
# else if /\W/.test(text)
# cursor.selection.selectLeft()
# cursor.selection.selectToPreviousSubwordBoundary()
# else
# cursor.selection.selectToPreviousSubwordBoundary()
# Command for alt-shift-right
# This is not the same as native mac behaviour and may need tweaking
# atom.commands.add 'atom-text-editor', 'custom:select-right': ->
# editor = atom.workspace.getActiveTextEditor()
# for cursor in editor.getCursors()
# {row, column} = cursor.getScreenPosition()
# range = [[row, column], [row, column + 1]]
# text = editor.getTextInBufferRange(range)
# if cursor.isAtEndOfLine()
# cursor.selection.selectRight()
# else if /\W/.test(text)
# cursor.selection.selectRight()
# cursor.selection.selectToNextSubwordBoundary()
# else
# cursor.selection.selectToNextSubwordBoundary()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment