/

How to Open VS Code from the Command Line

How to Open VS Code from the Command Line

In this blog post, I will guide you through the process of setting up the command line tools for VS Code. This is especially useful if you are using a new Mac and find that some features are not available by default upon installing VS Code.

One of the features I frequently use is opening folders or files in VS Code directly from the terminal. I simply type code foldername to open a folder or code filename to open a specific file. However, after installing VS Code on my new Mac, I realized that these commands were not recognized.

To fix this issue, I found a simple solution within VS Code. Here are the steps to follow:

  1. Open VS Code.
  2. Press cmd-option-P (or go to View -> Command Palette in the menu).
  3. In the command palette, type “command” to search for the command we need.
  4. Look for “Shell Command: Install ‘code’ command in PATH” and select it.
  5. Press enter to execute the command.

After completing these steps, the code command will be recognized in the terminal, allowing you to open folders and files in VS Code seamlessly.

Now, you can enjoy coding with VS Code from the comfort of your command line!

Tags: VS Code, command line, Mac, terminal