I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
I'm pretty sure VS Code installs itself into the path anyway, doesn't it? I've never had to do anything and it works using code even on Windows.
A hot tip though using open is that you can pass anything to it and it'll behave like you clicked that thing in the GUI, even URLs. So on a Mac, you could do open https://dev.to and it'd open in your default browser. Since VS Code registers itself as the handler for vscode schemes, you can also do this:
open 'vscode://file//Users/myusername/projects/myfile.txt:123:45'
And it'll open VS Code with the file /Users/myusername/projects/myfile.txt and your cursor already on line 123 and column 45. This is how those error messages that say things like "syntax error at line 20" get to magically work in some cases.
If you use VSCodium, change the appropriate bit to vscodium://, if you use Gnome or any derivatives, change open to gnome-open. Other Linux systems have other syntaxes, but generally one of those two will get you by.
I'm a fan of Open Source and have a growing interest in serverless and edge computing. I'm not a big fan of spiders, but they're doing good work eating bugs. I also stream on Twitch.
I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
A hot tip though using open is that you can pass anything to it and it'll behave like you clicked that thing in the GUI, even URLs. So on a Mac, you could do open dev.to and it'd open in your default browser. Since VS Code registers itself as the handler for vscode schemes, you can also do this:
open 'vscode://file//Users/myusername/projects/myfile.txt:123:45'
And it'll open VS Code with the file /Users/myusername/projects/myfile.txt and your cursor already on line 123 and column 45. This is how those error messages that say things like "syntax error at line 20" get to magically work in some cases.
Whooooooooa I did not know you could get this specific with open .. This should be it's own blog post.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I'm pretty sure VS Code installs itself into the path anyway, doesn't it? I've never had to do anything and it works using
code
even on Windows.A hot tip though using
open
is that you can pass anything to it and it'll behave like you clicked that thing in the GUI, even URLs. So on a Mac, you could doopen https://dev.to
and it'd open in your default browser. Since VS Code registers itself as the handler forvscode
schemes, you can also do this:And it'll open VS Code with the file
/Users/myusername/projects/myfile.txt
and your cursor already on line 123 and column 45. This is how those error messages that say things like "syntax error at line 20" get to magically work in some cases.If you use VSCodium, change the appropriate bit to
vscodium://
, if you use Gnome or any derivatives, changeopen
tognome-open
. Other Linux systems have other syntaxes, but generally one of those two will get you by.It doesn't from what I've understood. You have to do it explicitly. I typically do it via the command palette like Shannon did.
Have you tried it without? What OS are you using?
Yep; I'm on Ventura OS ~ it might depend on how VS code was installed, but I've had to follow Shannon's approach.
Whooooooooa I did not know you could get this specific with
open .
. This should be it's own blog post.