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. I installed the .deb which puts it into /usr/bin. If you installed it another way, then try to find the binary

$ command -v code

will print the path... more reliably than which code. 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.

  • 3
    yeah!! worked for me. – Avnish alok Jul 30 '17 at 8:08

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.

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