title: Stop Node server in terminal and return to file in vim
body: <p>I am new to Node and vim. </p>
  
  <p>I have the following code file, server.js open in vim:</p>
  
  <pre><code>var http = require("http");
  
  function onRequest(request, response) {
      console.log("Request received");
      response.writeHead(200, {"Content-Type": "text/plain"});
      response.write("Hello World");
      response.end();
  }
  
  http.createServer(onRequest).listen(8888);
  
  console.log("Server has started");
  </code></pre>
  
  <p>When I enter vim "command" mode and type:</p>
  
  <pre><code>:!node server.js
  </code></pre>
  
  <p>Things work as expected (I think). The window changes to the standard terminal window, and if I open a browser and navigate to localhost on port 8888, the silly "Hello World" text is displayed. </p>
  
  <p>The terminal displays the "Server has started" text, and the output that the request was received. All is well. </p>
  
  <p>When I close the browser window, and type <code>Ctrl-z to</code> stop the Node server, the terminal displays <code>[1}+ stopped vim server.js</code>, but does not return me to my code file in vim. </p>
  
  <p>If I return to vim by typing <code>vim</code>, vim opens into the same directory, but my file is not open. If I try to open the file, vim complains about a duplicate swap file. Obviously I can use the [R]ecover option, but it seems like I am missing a step.</p>
  
  <p>What am I missing here?</p>
  
  <p>I have googled, and searched SO, but I am not sure what I am asking for beyond the title of this question (which has not produced the answer I am looking for, or if it did, I didn;t recognize it). I am just new enough that I am unsure if I am missing something about the terminal, or vim, or *nix. </p>
  
  <p>Thanks in advance . . .</p>
  
  <p><em>UPDATE: It occurs to me I never clearly state what I am after - I am wanting to stop the server in the terminal and return to the open file in vim. As Tadman mentions below, I knew I was probably attempting to open an additional editor instance. What I was unclear on was how to return to the existing instance. Trying Tadman's suggestion now.</em> </p>