How to open Visual Studio Code with a code command in the terminal?
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:
- Open your Visual Studio Code IDE.
- Open the Command Palette (⌘ + ⇧ + P on Mac).
- Type
code
orshell command
to find theShell Command: Install 'code' command in PATH
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!