dd deletes an entire line

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-01-13 17:38:33 -08:00
parent 712475569d
commit b2648723de
4 changed files with 33 additions and 0 deletions

View File

@@ -64,6 +64,9 @@ class Editor extends Template
deleteChar: ->
@aceEditor.remove 'right'
deleteLine: ->
@aceEditor.removeLines()
moveLeft: ->
@aceEditor.navigateLeft()

View File

@@ -20,6 +20,14 @@ module.exports =
execute: (editor) ->
_.times @count, => @operatorToRepeat.execute(editor)
Delete: class
complete: null
execute: (editor) ->
editor.deleteLine()
isComplete: -> @complete
DeleteChar: class
execute: (editor) ->
editor.deleteChar()

View File

@@ -25,12 +25,14 @@ class VimMode
@bindCommandModeKeys
'i': 'insert'
'd': 'delete'
'x': 'delete-char'
'h': 'move-left'
'j': 'move-up'
@handleCommands
'insert': => @activateInsertMode()
'delete': => @delete()
'delete-char': => new op.DeleteChar
'move-left': => new op.MoveLeft
'move-up': => new op.MoveUp
@@ -65,6 +67,13 @@ class VimMode
else
@pushOperator(new op.NumericPrefix(num))
delete: () ->
if @topOperator() instanceof op.Delete
@topOperator().complete = true
@processOpStack()
else
@pushOperator new op.Delete()
pushOperator: (op) ->
@opStack.push(op)
@processOpStack()