   # Swap the anchor node/offset and the focus node/offset.
   reverseSelection: ->
     element = document.activeElement
-    if element and DomUtils.isEditable(element) and not element. isContentEditable
+    if element and DomUtils.isEditable(element) and not element.isContentEditable
       # Note(smblott). This implementation is unacceptably inefficient if the selection is large.  We only use
-      # it if we have to.  However, the normal method does not work for input elements.
+      # it if we have to.  However, the normal method (below) does not work for input elements.
       direction = @getDirection()
       length = @selection.toString().length
-      @selection[if direction == forward then "collapseToEnd" else "collapseToStart"]()
-      @selection.modify "extend", @opposite[direction], character for [0...length]
+      @collapseSelectionToFocus()
+      @runMovement @opposite[direction], character for [0...length]
     else
       # Normal method.
       direction = @getDirection()

      "P": -> @pasteClipboard backward
      "v": -> @launchSubMode VisualMode

      "Y": -> @enterVisualModeForMovement runMovement: "Y"
      "x": -> @enterVisualModeForMovement runMovement: "h", deleteFromDocument: true
      "y": -> @enterVisualModeForMovement yYanksLine: true
      "d": -> @enterVisualModeForMovement deleteFromDocument: true, dYanksLine: true
      "c": -> @enterVisualModeForMovement deleteFromDocument: true, onYank: => @enterInsertMode()

      "D": -> @enterVisualModeForMovement runMovement: "$", deleteFromDocument: true
      "C": -> @enterVisualModeForMovement runMovement: "$", deleteFromDocument: true, onYank: => @enterInsertMode()

      # Disabled as potentially confusing.
      # # If the input is empty, then enter insert mode immediately

    # For "yy".
    if @options.yYanksLine
      @commands.y = ->
        if @keypressCount == 1
          @selectLexicalEntity "lineboundary"
          @yank()

    # For "dd".
    if @options.dYanksLine
      @commands.d = ->
        if @keypressCount == 1
          @selectLexicalEntity "lineboundary"
          @yank deleteFromDocument: true

    # For "daw", "das", "dap", "caw", "cas", "cap".
    if @options.oneMovementOnly
      @commands.a = ->
        if @keypressCount == 1
          for entity in [ "word", "sentence", "paragraph" ]
            do (entity) => @movements[entity.charAt 0] = -> @selectLexicalEntity entity

