How To Open VSCode Files From The Command Line

One thing I always find myself looking to do with VSCode is open files and directories from the terminal or command line.

There are easy ways to do this.

The easiest way is probably navigating to your desired directory.

Once in the directory, you can type:

code .

To open the entire directory in VSCode.

Or you can open a single file from the current directory.

Examples:

code index.html
code style.css

Or you can provide paths to the exact files or directories.

Example using Ubuntu 20.04 from the home directory:

code Desktop/dev/lemz

Will open the entire ‘lemz’ directory.

Or:

code Desktop/dev/lemz/index.html

Will singularly open the index.html file.

These are two things I find myself doing all the time.