Vscode Command Line Interface Tips & Tricks

  • Post author:
  • Post category:Tech
  • Post comments:0 Comments
  • Post last modified:13th December 2019
  • Reading time:5 mins read

Operating our laptop or desktop with the help of a command-line is a different fun. Many people like CLI rather than GUI. In my point of you, the reason of liking is speed. CLI definitely increases the speed to operate your computer.

Visual Studio Code has a powerful command-line interface built-in that lets you control how you launch the editor. You can open files, install extensions, change the display language, and output diagnostics through command-line options (switches). Therefore Today I will share you that command-line which help you become a pro of vscode editor

TIP #1: Launching from the command line

You can launch the VS Code from the command line to quickly open a file, folder, or project. Typically, you open VS Code within the context of a folder. To do this, from an open terminal or command prompt, navigate to your project folder and type code .:

launch vscode using command line
.command-line launch-vscode.png

TIP #2 Core CLI options

Here are optional arguments you can use when starting VS Code at the command line via code:

Argument Description
-h or --help Print usage
-v or --version Print VS Code version (for example, 1.22.2), GitHub commit id, and architecture (for example, x64).
-d or --diff Open a file difference editor. It requires two file paths as arguments.

Tips #3 Opening Files and Folders:

Sometimes you will want to open or create a file. If the specified file does not exist, VS Code will create them for you along with any new intermediate folders:

code index.html style.css documentation\readme.md

example to open any file or multiple in visual code editor using command line

If you specify more than one file at the command line, VS Code will open only a single instance.
If you specify more than one folder at the command line, VS Code will create a Multi-root Workspace including each folder.

Argument Description
file Name of a file to open. If the file doesn’t exist, it will be created and marked as edited. You can specify multiple files by separating each file name with a space.
file:line[:character] Used with the -g argument. Name of a file to open at the specified line and optional character position. You can specify multiple files in this manner, but you must use the -g argument (once) before using the file:line[:character] specifier
folder Name of a folder to open. You can specify multiple folders and a new Multi-root Workspace is created
open a file at specific line number
open a file at the specified line

References : https://code.visualstudio.com/

Leave a Reply