The question says it all.
How can I call VS Code editor from
- windows cmd
- linux and mac terminal
e.g. for notepad++ I write
> start notepad++ test.txt
By the way, the editor is awesome (cross-platform)! Thank you Nadella!
You can download it from microsoft
You can also run VS Code from the terminal by typing
code
after adding it to the path:Launch VS Code. Open the Command Palette
(⇧⌘P)
and typeshell command
to find the Shell Command: Installcode
command in PATH command. Mac shell commandsRestart the terminal for the new
$PATH
value to take effect. You'll be able to typecode .
in any folder to start editing files in that folder.Sometimes setting path from VS Code command palette does not work
Instead manually add your VS Code to your path:
Run in terminal
sudo nano /etc/paths
echo $PATH
. You should something similar~ echo $PATH /Users/shashank/.nvm/versions/node/v8.9.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin
Next time, you navigate to your project folder from terminal
Enter:
code .
or
code /path/to/project
Source
This will work
In linux if you use
code .
it will open VS Code in the folder the terminal was in. Usingcode . Filename.cs
it will open in folder and open said file.For VS Code Insiders Windows users (vs code doc):
Add the directory
"C:\Program Files (x86)\Microsoft VS Code Insiders\bin"
at %PATH% environmental variable.then go to the folder that you want to open with vs code and type:
code-insders .
When installing on Windows, you will be prompted to add VS Code to your PATH.
I was trying to figure out how to open files with VS Code from the command line and I already had the capability - I just forgot I had already added it. You might already have it installed - check by navigating to a folder you want to open and running the command
code .
to open that folder.