Issue #57 (VS Code CLI)05/24/23
When you install VS Code on your machine, you can access VS Code's built in CLI through any terminal you open locally. For example, on my Windows machine I can open either my default Windows Command Prompt or Git Bash and have access to VS Code's CLI.
In the screenshot below, I'm in the Windows Command Prompt checking the version of VS Code installed, using the command code --version:
You can see the full range of commands available by typing
code --help. The list of commands is also available
in the VS Code docs, as shown below.
One common command you might want to know is the one to launch VS Code from your terminal. You can do this using the command
code . (that is the word "code" followed by a space then a dot). This will open the current folder in VS Code.
If you've installed VS Code Insiders on your system (which is like the "Chrome Canary" of VS Code), you can launch it using
code-insiders . as the command (again with a dot following a space).
You can also use a command like code index.html style.css to open a specific set of files in the instance of VS Code that will launch. If the files don't exist, they will be created. If you use multiple folder names, VS Code will open a Multi-root Workspace where multiple projects are opened at the same time.
The basic command to open VS Code will open a new window each time the command is used. If you want to open the current folder in the previously active VS Code instance, you can use the
--reuse-window argument (or flag). There's even an argument called
--goto that allows you to open a file at a specified line number!
So if you often work in the terminal outside of VS Code, some of these commands might help when switching back to the editor in a specific context.
Now on to this week's hand-picked links!