VS Code Command Line Tips and Tricks

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 3 years ago

VS Code allows you to install a code command into your PATH so you can launch code a few different ways. You can open projects, create files in memory, or even pipe the results of other commands into code.

Instructor: [00:00] Go into your command palette. The default shortcut is Command+Shift+P, but I changed it to Command+T instead. Type out "Show command, install code command in path." Then, you should get a notification saying that that worked.

[00:17] Then in your terminal, you can type code, and then a path, so projects, proxy lessons, so a path to a project, hit enter, and then code'll pop up that project with that directory opened. That's very handy after you get clone or create any new project from a command line tool.

[00:37] You can also tell code to create some files somewhere. I'll try fu/bar/somefile.js. This will pop open code in whatever project is currently open. You see my proxy lessons project is open. I can type in some JavaScript here and all the highlighting will work.

[00:56] Back to my terminal, if I try to cd into fu, you can see that fu doesn't exist. As soon as I save this file in code and go back, I can cd into fu, cd into bar, and then check this directory. You'll see some file is there. You can also pipe content into code. If I go, "Hello," and then pipe code and add a dash, hit enter there. Code will open up with "Hello" as the output.

[01:28] For example, if I were to list and then pipe that into code, you can see it'll list some file that we created or if I were to curl the GitHub API, so GitHub.com, then pipe that into code, hit enter, you can see it'll download that file and pop it open inside of code.

[01:56] If you're not seeing the proper highlighting, if you open your command palette and type in "Language," you should see change language mode as an option. I'm going to type "JSON," for this file. Hit enter, and then you'll get the proper JSON highlighting and tools.

egghead
egghead
~ 28 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today