diff --git a/README.md b/README.md index ece5069..0b3dd1d 100644 --- a/README.md +++ b/README.md @@ -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] diff --git a/keymaps/word-jumper.cson b/keymaps/word-jumper.cson index e29067e..f0c269e 100644 --- a/keymaps/word-jumper.cson +++ b/keymaps/word-jumper.cson @@ -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' diff --git a/lib/word-jumper.coffee b/lib/word-jumper.coffee index b1db396..4d0d872 100644 --- a/lib/word-jumper.coffee +++ b/lib/word-jumper.coffee @@ -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 @@ -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) @@ -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: @@ -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