Is there a way to exit Node.js and run VIM in a file?

I am creating a simple terminal file manager on Node.js. Is there any way my program works on the terminal, exit it and open the file using VIM?

+4
source share
1 answer

Just:

require('child_process').spawn('vim', ['test.txt'], {stdio: 'inherit'}); 

If there is nothing left in the Node.js event loop when vim exits, then node also exits automatically. Or, if you need to ensure that node exits when vim does:

 var vim = require('child_process').spawn('vim', ['test.txt'], {stdio: 'inherit'}); vim.on('exit', process.exit); 

As for closing the node application before vim exits, this is not entirely possible, because vim inherits the standard input / output / error streams from the spawning process (node), which are destroyed when the node exits.

+7
source

All Articles