Recently I downloaded visual studio code which operates as text editor but I can't figure out how to open code file from terminal.
When I use Sublime Text the command is subl, so when I run subl newFolder.c it would automatically open Sublime Text with a file named newFolder.c.
What can I type to create/open a file in Visual Studio Code?
62 Answers
It should be called code and for me, I just have to run it.
$ code
$ code my-fileand that works. If installed the .deb (only available in older Ubuntu versions) the path should be
`/usr/bin/code`If you installed it as a snap, e.g.
$ sudo snap install code --classicThen it's path should be
`/snap/bin/code`If you installed it another way, then try to find the binary, e.g.
command -v codewill print the path. command is a bit more reliable than which. VS Code is an Electron application (i.e. Chrome/node) and the launcher is a little wonky. For example, xdg-open does not work well for me.
NOTE ABOUT INSIDERS VERSION:
As Nicholas Humphrey points out in the comments, it could also be called code-insiders if you installed the insiders version. This allows you to have side-by-side installations of regular and insider versions.
Correct way is to open Visual Studio Code and press Ctrl+Shift+P on Windows (or Cmd+Shift+P on Mac) then type Install 'code' command in PATH . At some point you should see an option come up that lets you install shell command, click it. Then open a new terminal window and type code.