 
       editor.getBuffer().setText("abc\n  012\n")
       editor.setCursorScreenPosition([1, 2])
+      keydown('o')
 
     it "switches to insert and adds a newline above the current one", ->
-      keydown('o')
-
       expect(editor.getText()).toBe "abc\n  012\n  \n"
       expect(editor).toHaveClass 'insert-mode'
       expect(editor.getCursorScreenPosition()).toEqual [2, 2]

        expect(editor).not.toHaveClass 'command-mode'
        expect(editor).toHaveClass 'insert-mode'

    describe "when the second c is prefixed by a count", ->
      it "deletes n lines, starting from the current, and enters insert mode", ->
        editor.setText("12345\nabcde\nABCDE\nQWERT")
        editor.setCursorScreenPosition([1, 1])

        keydown('c')
        keydown('2')
        keydown('c')

        expect(editor.getText()).toBe "12345\nQWERT"
        expect(editor.getCursorScreenPosition()).toEqual [1, 0]
        expect(editor).not.toHaveClass 'command-mode'
        expect(editor).toHaveClass 'insert-mode'

    describe "when followed by an h", ->
      it "deletes the previous letter on the current line and enters insert mode", ->
        editor.setText("abcd\n01234")
        editor.setCursorScreenPosition([1, 1])

        keydown('c')
        keydown('h')

        expect(editor.getText()).toBe "abcd\n1234"
        expect(editor.getCursorScreenPosition()).toEqual [1, 0]
        expect(editor).not.toHaveClass 'command-mode'
        expect(editor).toHaveClass 'insert-mode'

    describe "when followed by a w", ->
      it "deletes to the beginning of the next word and enters insert mode", ->
        editor.setText('abcd efg')
        editor.setCursorScreenPosition([0, 2])

        keydown('c')
        keydown('w')

        expect(editor.getText()).toBe 'ab efg'
        expect(editor.getCursorScreenPosition()).toEqual [0, 2]
        expect(editor).not.toHaveClass 'command-mode'
        expect(editor).toHaveClass 'insert-mode'

        keydown('escape')

        editor.setText('one two three four')
        editor.setCursorScreenPosition([0, 0])

        keydown('c')
        keydown('3')
        keydown('w')

        expect(editor.getText()).toBe 'four'
        expect(editor.getCursorScreenPosition()).toEqual [0, 0]
        expect(editor).not.toHaveClass 'command-mode'
        expect(editor).toHaveClass 'insert-mode'

    describe "when followed by a b", ->
      it "deletes to the beginning of the previous word and enters insert mode", ->
        editor.setText('abcd efg')
        editor.setCursorScreenPosition [0, 2]

        keydown('c')
        keydown('b')

        expect(editor.getText()).toBe 'cd efg'
        expect(editor.getCursorScreenPosition()).toEqual [0,0]
        expect(editor).not.toHaveClass 'command-mode'
        expect(editor).toHaveClass 'insert-mode'

        keydown('escape')

        editor.setText('one two three four')
        editor.setCursorScreenPosition([0, 11])

        keydown('c')
        keydown('3')
        keydown('b')

        expect(editor.getText()).toBe 'ee four'
        expect(editor.getCursorScreenPosition()).toEqual [0, 0]
        expect(editor).not.toHaveClass 'command-mode'
        expect(editor).toHaveClass 'insert-mode'

  describe "the C keybinding", ->
    beforeEach ->
      editor.getBuffer().setText("012\n")
      editor.setCursorScreenPosition([0, 1])

    it "deletes the contents until the end of the line and enters insert mode", ->
      keydown('C', shift: true)

      expect(editor.getText()).toBe "0\n"
      expect(editor.getCursorScreenPosition()).toEqual [0, 1]
      expect(editor).not.toHaveClass 'command-mode'

        expect(editor.getText()).toBe "12345\nabcde"
        expect(editor.getCursorScreenPosition()).toEqual [1, 0]

    describe "undo behavior", ->
      beforeEach ->
        editor.setText("12345\nabcde\nABCDE\nQWERT")
        editor.setCursorScreenPosition([1,1])
