DEV Community

Saad Irfan for VSCode.pro

Posted on • Edited on

1

VSCode Command Line Interface

Just when I thought VSCode can't surprise me anymore, it came out of the closet with something awesome & shocked me again. Did you folks know VSCode offers a Command Line Interface (CLI) that lets you do a bunch of amazing VSCode stuff right inside your terminal.

Before we go into details, let's first activate this CLI.

⚙️ Setting Up the CLI

Open your VSCode. Press ⌘command + ⇧shift + p to open the Command Palette. Once it's open, search for shell command & then select the option: Shell Command: Install 'code' command in PATH

Activating VSCode CLI

When you are done, you will see a confirmation message at the bottom right corner of your VSCode & that's it. You have activated the CLI. 🙌🏻

🚀 Code CLI

As the name suggests, every Code CLI command will start with code. For instance, if you want to get your VSCode version, you can just type code -v.

Code CLI

You can also open any folder in VSCode by just typing code . in any terminal & then pressing enter

VSCode launch

Code CLI also allows you to open any file of your project from your terminal. Just write code -r filename in the terminal & you are good to go.

Code CLI open file

We have added -r to reuse the existing window instead of opening a new one. You can also use the command code -d filename1 filename2 to compare to files with each other. ⚡️

These are just the tip of the iceberg. You can see all of the options that this CLI provides by writing code --help in the terminal.

Code CLI help

That's it for today's, folks! If you like this piece, please hit the like button, and if you have a question, just drop it down in the comments section below. 🙌🏻

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay