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?

  • Related: code.visualstudio.com/docs/setup/linux – Elder Geek Nov 21 '16 at 20:53
  • Did you try; gedit newFolder.c; nano newFolder.c; vim newFolder.c ?? – Rahul Nov 21 '16 at 20:54
  • @Rahul none of them work – Giorgi Cercvadze Nov 21 '16 at 21:08
  • If none of those worked, your PATH is likely wacked. What does echo $PATH show you? What you expected? – Michael Sandman Nov 21 '16 at 21:16
  • 1
    Instead of ctrl +shift+P ... install shell ... try going to the same place ctrl+shift+P and typing in install 'Code' command in PATH. This worked for me when none of the other solutions did. I found it here: stackoverflow.com/a/30627956 – Ricky Apr 21 '17 at 17:17

It should be called code and for me, I just have to run it.

$ code
$ code my-file

and that works. If installed the .deb (only available in older Ubuntu versions) the path should be


If you installed it as a snap, e.g.

$ sudo snap install code --classic

Then it's path should be


If you installed it another way, then try to find the binary, e.g.

command -v code

will 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.

  • 4
    yeah!! worked for me. – Avnish alok Jul 30 '17 at 8:08
  • 1
    "code ." will open current directory in vs code – Ali_Hr Feb 9 '20 at 6:55
  • 1
    Important notice: Only worked for me when I installed the debian package. It did NOT work when I installed the snap package - then I could open VS Code via GUI, but I don't know which command to use. – Martin Thoma Mar 6 '20 at 20:27
  • 1
    @NicholasHumphrey, sorry it's not going well for you. If you post your specific problem we might be able to help. – Michael Sandman May 30 '20 at 3:16
  • 1
    @MichaelSandman thanks, I figured it out a while ago actually. My version is the insider version so I need to call code insider instead of just code. Stupid me~~ – Nicholas Humphrey May 30 '20 at 19:55

Correct way is to open Visual Studio Code and press Ctrl+Shift+P then type install shell command. 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.

  • 6
    That option isn't coming up in 1.25.1 – silencedmessage Jul 26 '18 at 22:57
  • 2
    @silencedmessage try typing shell. This is what it looks like for me – Alex Cory Nov 28 '18 at 6:50
  • For mac OS you should use CMD+Shift+P – James Jordan Taylor Jan 27 '19 at 20:28
  • 4
    Instead of install shell command, for me it was Install 'code' command in PATH – tomp Aug 2 '19 at 20:55
  • It seems i cannot find either install shell command or Install 'code' command in PATH in 1.53.2 :/ . Anyone experiencing a similar issue ? – Kaz Mar 14 at 12:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.