Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio Code, open current file in External Application

I am trying to write a simple extension in Visual Studio Code, the extension will simply take the current file and launch it in external application. How can we do that?

like image 949
Abhishek Agrawal Avatar asked Sep 16 '25 18:09

Abhishek Agrawal


2 Answers

Found an answer using VS Code Tasks. will appreciate if someone has a solution using extensions.

{
    "version": "0.1.0",

    // we want to run vs
    "command": "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe",

    // the command is a shell script
    "isShellCommand": true,

    "showOutput": "silent",

     "args": ["/edit", "${file}"]

}
like image 175
Abhishek Agrawal Avatar answered Sep 19 '25 11:09

Abhishek Agrawal


You can use anything that is available on node / npm. In your case you can just use spawn https://nodejs.org/api/child_process.html

Alternatively you can use open which I personally love from foreground process launching : https://www.npmjs.com/package/open

like image 42
basarat Avatar answered Sep 19 '25 12:09

basarat