How to launch Visual Studio Code from macOS terminal?

Today, let us see how to run or launch Visual Studio Code from the macOS terminal. This tip will be helpful for people who are frequently using the terminal in macOS. Follow these steps to launch VS Code from the macOS command line and start editing files in the folder you are currently in the terminal.

  1. Install Visual Studio Code in macOS and make sure the app file Visual Studio Code.app is placed in the Applications folder.
  2. Launch VS Code and open the Command Palette by pressing Shift, Command and P keys.
  3. In the command palette type in ‘shell command’. From the list select the command Shell Command: Install ‘code’ command in PATH.
    Install VS code in path of macOS
  4. Once installed, you will see a message Shell command ‘code’ successfully installed in PATH.
    Launch Visual Studio Code from macOS terminal
  5. Launch the terminal window. If it’s already open then close it and launch it again.
  6. Type in “code .” to launch visual studio code and start editing files in the folder you have selected in the terminal.

Note

The dot ‘.‘ at the end of the command “code .” is used to specify the current directory. If you want to open a directory other than the current directory, replace the '.' with the path to that directory. For example:

code ~/Projects/OurProject

Hope this helps.

Tools used

  • Visual Studio Code (1.75.0).
  • macOS Big Sur (11.7.2) intel.

Reference

  • More about running Visual Studio Code on macOS at VS Code Docs.


1 thought on “How to launch Visual Studio Code from macOS terminal?”

Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.