This article shows you how to add
code to the path in Windows and macOS so that you can launch the VS Code (Visual Studio Code) in any directory just by running the following command in a terminal window:
You can also open a file with VS Code by executing this:
How to add “code” to the path?
Note: On Windows, Visual Studio Code is automatically added to your PATH. If it doesn’t work as expected or you’re using macOS, try the steps listed below.
Firstly, launch your VS Code and go to
Command Palette (hotkeys:
P), search for
command and click on
Shell Command: Install 'code' command in PATH:
A message will show up like this:
You may be asked to provide your administrator password. If this is the case, just enter your administrator password and the job will be done.
That’s it. Further reading:
- VS Code: How to Pin/Unpin a File (2 Approaches)
- VS Code: How to Render Whitespace Characters
- How to Change File Encoding in VS Code
- VS Code: Opening Multiple Windows/Projects Simultaneously
- VS Code: Prevent Single-Child Folders from Being Merged
You can also check out our Visual Studio Code topic page for more tips and tricks to improve your producibility and coding experience.