How to open Visual Studio Code with a code command in the terminal?

Josh Tsai
2 min readSep 16, 2022

--

open a side project

Before I knew this method, every time I wanted to open a file or a project with Visual Studio code, I had a hard time to efficiently find the correct one among the all the directories and files. Sometimes my dumb finger even clicked a wrong file which was narrowly next to the right one I should’ve opened.

Install the code command:

  1. Open your Visual Studio Code IDE.
  2. Open the Command Palette (⌘ + ⇧ + P on Mac).
  3. Type codeor shell command to find the Shell Command: Install 'code' command in PATH command.
click it to install the command
open a side project with code command!

Fix the issue that command is not found after restarting your PC.

I needed to reinstall the command after restarting my laptop. I was very annoyed, so I googled and wondered if anyone else had the same issue. It turned out that I didn’t put Visual Studio Code in Applications directory. I used the IDE directly after I downloaded it. So it had always been opened from the Download directory. After I moved Visual Studio Code from Download to Applications and reinstalled the command, the problem was resolved!

command not found
Move Visual Studio Code from Download to Applications.
Before installing again, you should uninstall it.

--

--