       @panel.show()
       @hostEditor.focus()
 
+      nreplPortPath = atom.project.getPaths().find (path) -> fs.existsSync("#{path}/.nrepl-port")
+      defaultPort = if nreplPortPath
+        fs.readFileSync("#{nreplPortPath}/.nrepl-port").toString()
+      else
+        ""
+      @portEditor.getModel().setPlaceholderText(defaultPort)
+
     onConfirm: ->
-      @confirmCallback? port: parseInt(@portEditor.getText()), host: @hostEditor.getText() || defaultHost
+      host = @hostEditor.getText() || defaultHost
+      port = @portEditor.getText() || defaultPort
+      @confirmCallback? port: parseInt(port), host: host
       @panel?.hide()
 
     onCancel: ->

{$, View, TextEditorView} = require 'atom-space-pen-views'

defaultHost = "localhost"

module.exports =
  class NReplConnectionView extends View

          @subview "hostEditor", new TextEditorView(mini: true, placeholderText: defaultHost, attributes: tabindex: 1)
        @div class: "block", =>
          @label "Port"
          @subview "portEditor", new TextEditorView(mini: true, placeholderText: defaultPort, attributes: tabindex: 2)

    # * `confirmCallback` The {Function} execute on confirm. An {Object} will
    #   be passed to callback function with following keys:
