In a way I am reticent to add to the long list of answers. However, I searched this page for the word "portable" and came up empty. (And I did a full Stack Overflow search and also found nothing.) So I want to add this very specific answer for potential future searchers.
This answer is for if you installed VS Code in Portable Mode on Windows 10.
"Portable Mode" refers to what is described on the official VS Code web pages, which as of 21 January 2021 are found here: https://code.visualstudio.com. It does not mean the Visual Studio Code Portable project started/run by Gareth Flowers, or any similar project. (I am not saying anything bad about this or other projects - I have neither used nor evaluated.) If you are using one of those projects, you need to check with that project documentation/community - although this might work.
"Installing" VS Code in Portable Mode is downloading a .zip archive and extracting it locally wherever you want your VS Code "installation" to live. There is no actual installation or setup that is run, so there is no automatic adding of the code
command to your PATH
.
Answer
After extracting the Portable Mode VS Code files to the location of your choice, there should be a bin
folder in that location. Copy the full path of that bin
folder and add it to your System or User (your choice) PATH
variable.
You should then be able to use the code
command from PowerShell or CMD.
code -n "D:\myTextFile.txt"
and get going. – Hypercorrectcode ./search.pl
worked for me on windows 7 in visual studios own terminal – Restrictcode -n filename
-- Opens file in NEW window.code -r filename
-- Opens file in already opened window (this is what I wanted and why I'm commenting. It works great from the terminal window of VSCode).code -g filename
-- Handy! As you can see from runningcode --help
, the -g flag is short for--goto
and it is my favorite command to use when debugging. You can use just the file name and it acts just like-r
OR, you can use<file:line[:character]>
to go straight to a line, or even char on a line! – Atonsah