 
     rootView.command 'find-and-replace:use-selection-as-find-pattern', @setSelectionAsFindPattern
 
+    @handleEventsForReplace()
+
+  handleEventsForReplace: ->
+    @replacementsMade = 0
+    @model.on 'replace', (promise) =>
+      # if @model.getPathCount()
+      @replacementsMade = 0
+      @replacmentInfoBlock.show()
+      @replacementProgress.removeAttr('value')
+
+    @model.on 'path-replaced', (result) =>
+      @replacementsMade++
+      @replacementProgress[0].value = @replacementsMade / @model.getPathCount()
+      @replacmentInfo.text("Replaced #{@replacementsMade} of #{_.pluralize(@model.getPathCount(), 'file')}")
+
+    @model.on 'finished-replacing', ({pathsReplaced, replacements}) =>
+      @replacmentInfoBlock.hide()
+      if pathsReplaced
+        @addInfoMessage("Replaced #{_.pluralize(replacements, 'result')} in #{_.pluralize(pathsReplaced, 'file')}")
+      else
+        shell.beep()
+        @addInfoMessage("Nothing replaced")
+
   attach: ->
     if @hasParent()
       el = @lastFocusedElement or @findEditor

    @showResultPane()
    @model.search(@findEditor.getText(), paths)

  showResultPane: ->
    options = null
    options = {split: 'right'} if config.get('find-and-replace.openProjectFindResultsInRightPane')
    rootView.openSingletonSync(ResultsPaneView.URI, options)

  clearMessages: ->
    @errorMessages.hide().empty()
    @infoMessages.hide().empty()



      @ul outlet: 'errorMessages', class: 'error-messages block'
      @ul outlet: 'infoMessages', class: 'info-messages block'
      @div outlet: 'replacmentInfoBlock', class: 'block', =>
        @progress outlet: 'replacementProgress', class: 'inline-block'
        @span outlet: 'replacmentInfo', class: 'inline-block', 'Replaced 2 files of 10 files'

      @div class: 'find-container block', =>
        @label class: 'text-subtle', 'Find'
