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, 2016 at 20:53
  • Did you try; gedit newFolder.c; nano newFolder.c; vim newFolder.c ??
    – Rahul
    Nov 21, 2016 at 20:54
  • @Rahul none of them work Nov 21, 2016 at 21:08
  • If none of those worked, your PATH is likely wacked. What does echo $PATH show you? What you expected? Nov 21, 2016 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, 2017 at 17:17

2 Answers 2


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. Jul 30, 2017 at 8:08
  • 1
    "code ." will open current directory in vs code
    – Ali_Hr
    Feb 9, 2020 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. Mar 6, 2020 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. May 30, 2020 at 3:16
  • 2
    @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~~ May 30, 2020 at 19:55

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.

  • 6
    That option isn't coming up in 1.25.1 Jul 26, 2018 at 22:57
  • 2
    @silencedmessage try typing shell. This is what it looks like for me
    – Alex Cory
    Nov 28, 2018 at 6:50
  • For mac OS you should use CMD+Shift+P Jan 27, 2019 at 20:28
  • 5
    Instead of install shell command, for me it was Install 'code' command in PATH
    – tomp
    Aug 2, 2019 at 20:55
  • 1
    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, 2021 at 12:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .