     @is_user_command = true
 
   kill: ->
+    editor = @getEditor()
+    return unless editor
     @is_user_command = false
-    editor = atom.workspace.getActiveTextEditor()
     editor.transact =>
       editor.selectToEndOfLine()
       texts = (s.getText() or '\n' for s in editor.getSelections())

    @is_user_command = true

  yank: ->
    editor = atom.workspace.getActiveTextEditor()
    editor.transact =>
      cursors = editor.getCursors()
      top = @killring.top()

    false

  set_mark: ->
    editor = @getEditor()
    return unless editor
    editorView = atom.views.getView editor
    $(editorView).toggleClass "transient-marked"
    cursor.clearSelection() for cursor in editor.getCursors()

  kill_region_or_backward_word: ->
    editor = @getEditor()
    return unless editor
    if editor.getLastSelection().isEmpty()
      @kill_backward_word()
    else
