Starting VSCode from the command line

Filed under Uncategorized

I do a lot from the command line, so starting VSCode to quickly edit a file I’m looking at can be a big help.

VSCode isn’t automatically added to the path, so it won’t normally be available. Besides, if you’re using the Insiders build, the exe name will be Code – Insiders.exe, which is, um, unwieldy, to the say the least.

I know there are other solutions out that that might make more sense depending on your situation, for me, setting up a simple BAT file to start the editor made the most sense.

I already have a folder full of utilities and BAT files that I always add to my path anyway. Plus, I like having a bit of flexibility that wrapping VSCode in a BAT file gives me.

Anyway, here’s what I’ve ended up with.

ECHO off

REM Starts VSCODE and returns immediately to the console where it was started from
REM Running it a second time just opens the new file in a new tab in the existing VSCode window
start /MIN /B "" "C:\Users\darin\AppData\Local\Programs\Microsoft VS Code Insiders\Code - Insiders.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9 >nul

Using this, I don’t get “leftover” phantom command line windows, I don’t get random debug logging in the terminal window I started it from, and it all “just works”.

Of course, you’ll have to adjust the path if your name’s not “darin” 🙂 , if you’ve installed VSCode in a non-standard place or if you’re using the normal, not Insiders, version.

Post a Comment

Your email is never published nor shared. Required fields are marked *