How To Open A File In Visual Studio Code From A Command Prompt

Being productive as a developer comes in many forms. One such form being the ability to navigate the command line just as proficiently as you can a full blown GUI.

Often I find myself at a command line gearing up to run a number of processes...

npm install <package>
bower install <package>
dotnet restore
vagrant up

All of which have a corresponding script or config file(s) associated with it. Meaning, these commands are run more often than not in the same directory as the script resides.

When a script bombs, what do you do?

It pains me to watch a counterpart of my mind navigate to a directory, run a command, watch the command fail and open an editor to then again navigate to that script before opening it up in said editor. A process that usually takes over a minute.

The idea of opening files directly from a command-line is nothing new. We all should be familiar with the following.

notepad some-text-file.txt

Luckily for those of use who have taken a liking to Visual Studio Code for quick edits, the same extremely efficient command is available. Use it and use it often!

code . some-config-file.json
Open a file in visual studio code from the command line

Be sure to let us know how you gain more productivity through the command line in the comments below.