         @countTimes =>
           for selection, i in selections
             @selectionIndex = i
+            @selectionIndex = selections.length - (i + 1) if @direction is 'down'
             @mutate(selection) if @isMovable(selection)
 
   initOverwrittenByEditor: ->
     unless overwrittenByEditor.has(@editor)
       if @isLinewise()
-        rowCount = swrap(@editor.getLastSelection()).getRowCount()
-        overwrittenArea = [1..rowCount].map -> ''
+        overwrittenArea = @editor.getSelections().map (selection) ->
+          _.multiplyString("\n", swrap(selection).getRowCount()-1)
       else
-        width = @editor.getLastSelection().getBufferRange().getExtent().column
         overwrittenArea = @editor.getSelections().map (selection) ->
-          _.multiplyString(' ', width)
+          _.multiplyString(' ', selection.getBufferRange().getExtent().column)
       overwrittenByEditor.set(@editor, overwrittenArea)
 
   getSelectedTexts: ->

_ = require 'underscore-plus'
{CompositeDisposable} = require 'atom'

requireFrom = (pack, path) ->
  packPath = atom.packages.resolvePackagePath(pack)

      @editor.groupChangesSinceCheckpoint(checkpoint)

  getOverwrittenText: (replacedText) ->
    overwrittenArea = overwrittenByEditor.get(@editor)[@selectionIndex]
    replacedText = switch @direction
      when 'up'
        [overwritten, rest...] = overwrittenArea.split("\n")
        overwrittenArea = [rest..., replacedText].join("\n")
        overwritten
      when 'down'
        [rest..., overwritten] = overwrittenArea.split("\n")
        overwrittenArea = [replacedText, rest...].join("\n")
        overwritten
      when 'right'
        [overwritten, rest...] = overwrittenArea
        overwrittenArea = [rest..., replacedText].join("")
        overwritten
      when 'left'
        [rest..., overwritten] = overwrittenArea
        overwrittenArea = [replacedText, rest...].join("")
        overwritten

    overwrittenByEditor.get(@editor)[@selectionIndex] = overwrittenArea
    replacedText

  isLinewise: ->
    switch @vimState.submode
