问题
Is there a way to launch Microsoft Visual Studio Code from the command line in windows? I can't even seem to find the directory for code on my computer. It didn't even ask me where to download it.
回答1:
Navigate to the directory that you want to open and type code .
to launch VS Code.
回答2:
As many folks already suggested ways to open code from command prompt using code .
command. This will only open Visual Studio Code Stable build. But If you have downloaded Visual Studio Code Insider build/version (Which has all latest build/features but unstable version) then you need to follow below instructions in windows :
- Go to Control Panel\System and Security\System. Click on Advanced System Settings
- Click on Environment Variables
- Under System Variables tab, Click on Edit for Path Variable
- Add a new path
C:\Users\tsabu\AppData\Local\Programs\Microsoft VS Code Insiders\bin
(or)C:\Program Files\Microsoft VS Code Insiders\bin
based on location at which you have installed vscode insider in your machine.
Open a new command prompt and typecode-insiders .
to open vscode-insider build/version
回答3:
Short answer:
code your_path your_filename
Long answer:
Here your_path
can simply be .
if you want to use the current directory as your working path. Or ..
for 1 level up, etc.
code
is the name of the executable of Visual Studio Code (code.exe). If it doesn't launch, perhaps your VSC path hasn't been added to the path environment variable. Run this command to add it:
set PATH=";C:\Program Files\Microsoft VS Code\bin"
Of course you'll need to specify a different path if your VSC is installed somewhere else.
How can you find out the installation path? (click for screenshot) Go to "Start" menu, type in "Visual Studio Code", right click on the found program, "Properties", check "Target". Now you'll see!
回答4:
It may come already added to your path when installed. Try using code <filename>
in your command line. If it's not you can add the command line script's directory to your path. The command line script's directory is downloaded by default in the following location
C:\Users\<username>\AppData\Local\Code\bin
回答5:
Point your command prompt to the specific folder that has the file that you want to open. Let's say you want to open the file titled main.scss. Simply run this command:
start code main.scss
If Visual Studio Code is already open, you can simply do:
code main.scss
来源:https://stackoverflow.com/questions/29955785/opening-microsoft-visual-studio-code-from-command-prompt-windows