Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Provides ability to jump into camelCase words using:
* `ctrl-alt-left` - to move cursor(s) left
* `shift-ctrl-alt-left` - to move cursor(s) left with selection
* `shift-ctrl-alt-right` - to move cursor(s) right with selection
* `ctrl-delete` - to delete next sub-word
* `ctrl-backspace` - to delete previous sub-word


In action:
![omgwhoa][gif]
Expand Down
3 changes: 3 additions & 0 deletions keymaps/word-jumper.cson
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@

'ctrl-alt-shift-right': 'word-jumper:select-right'
'ctrl-alt-shift-left': 'word-jumper:select-left'

'ctrl-delete': 'word-jumper:remove-right'
'ctrl-backspace': 'word-jumper:remove-left'
17 changes: 14 additions & 3 deletions lib/word-jumper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ findBreakSymbol = (text, symbols) ->
# @param {atom#workspaceView#Editor#Cursor} cursor - editor's cursor object
# @param {Number} direction - movement direction
# @param {Boolean} select - move cursor with selection
# @param {Boolean} remove - remove selection
# @param {Boolean} selection - selected range object
###
move = (cursor, direction, select, selection=false) ->
move = (cursor, direction, select, remove, selection=false) ->
DEBUG && console.group "Moving cursor #%d", cursor.marker.id

# Getting cursor's line number
Expand Down Expand Up @@ -116,6 +117,9 @@ move = (cursor, direction, select, selection=false) ->
if select
# Move selection
selection.selectToBufferPosition(cursorPoint)
if remove
# remove selection
selection.delete()
else
# Just move cursor to new position
cursor.setBufferPosition(cursorPoint)
Expand All @@ -128,10 +132,11 @@ move = (cursor, direction, select, selection=false) ->
# `stopSymbols` setting variable.
# @param {Number} direction - movement direction
# @param {Boolean} select - move cursor with selection
# @param {Boolean} remove - remove cursor with selection
###
moveCursors = (direction, select) ->
moveCursors = (direction, select, remove) ->
selections = getEditor().getSelections()
move cursor, direction, select, selections[i] for cursor, i in getEditor()?.getCursors()
move cursor, direction, select, remove, selections[i] for cursor, i in getEditor()?.getCursors()

module.exports =
config:
Expand All @@ -152,3 +157,9 @@ module.exports =

'word-jumper:select-left': ->
moveCursors?directions.LEFT, true

'word-jumper:remove-right': ->
moveCursors?directions.RIGHT, true, true

'word-jumper:remove-left': ->
moveCursors?directions.LEFT, true, true