How to open Visual Studio code from Command Line

Visual Studio code (VS code) is an open source code editor developed by Microsoft and operating on Windows, Linux and Mac OS. It is written in TypeScript, JavaScript and CSS, so it offers deep built-in support for Node.js and also supports many languages like C++, Java, TypeScript, JavaScript, JSON and more, what makes Visual Studio code one of the best free Code Editors in 2020.

Related Articles:

Visual Studio code Features

Visual Studio code is known for its :

  • Code refactoring & debugging
  • Easy extensibility and customizability
  • Variety of plugins and themes
  • Integrated Terminal (Command Line Interface)

You can download VS code for free here: https://code.visualstudio.com/

devdotcode-VScode

Open Visual Studio code from your Command Line Interface

To follow the rest of this article you need to have Command Line application setup (you can check here how to setup Command Line ) and Visual Studio code installed.

Windows users

When you install VS code in your computer, it is added automatically to the environment path. As a result you can open VS code from the the command line by just typing code then press enter, this will open an instance of VS code in the current directory and wright where you left in the last session.

 code

To start a brand new project in VS code you can use the command code with -n option for new.

 code -n

To open Vs code in the current directory you run code command followed by a dot.

 code .

If you want to open a specific file in the current directory (lets say you want to open package.json) you can use this command:

 code --goto package.json

to get more options run:

 code --help

Mac OS users

For the mac OS users, you need first to add VS code to the environment path, for that follow this steps:

  • First, in your Terminal open file .bash_profile or .zshrc
 open ~/.bash_profile

OR

 open ~/.zshrc
  • Then add to it this line of code
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
bash_profile
.bash_profile after adding the code
  • Finally, save (command + S) .bash_profile file, and run :
 code .

this will open an instance of VS code in the current directory. Now you can use the same commands above.

To start a brand new project in VS code you can use the command code with -n option for new.

 code -n

If you want to open a specific file in the current directory (lets say you want to open package.json) you can use this command:

 code --goto package.json

to get more options run:

 code --help

You might also like:

3 easy steps to create React application.

How to create React Web App with a Node.js API Backend.

How to make Axios Requests in React to a nodejs API.

How to use React Hooks in Functional Components.

5 Steps to Set up React Development Environment.

How to clone GitHub repository and branches.

What are Component Lifecycle Methods in React.

How to open Visual Studio code from Command Line.

How to deploy React app to Heroku.

Complete Guide on how to use Git and GitHub.

How to get Request Origin in Express.js?

How to get the Request Host in express.js?

How to Get Current Date and Time in JavaScript.

How to add Custom Error Handler Middleware to your Node.js/Express API.

Complete JWT Authentication and Authorization System for MySQL/Node.js API.

How to Build a Complete API for User Login and Authentication using MySQL and Node.js.

Node.js + MySQL : Add Forgot/Reset Password to Login-Authentication System.

Nodemailer + Gmail: How to Send Emails from Node.js API using Gmail.

How to store Session in MySQL Database using express-mysql-session.

How to interact with MySQL database using async/await promises in node.js ?

How to use Sequelize async/await to interact with MySQL database in Node.js.

MANY-TO-MANY Association in MYSQL Database using Sequelize async/await with Node.js.

ONE-TO-ONE Association in MYSQL Database using Sequelize async/await with Node.js

ONE-TO-ONE Association in MYSQL Database using Sequelize async/await with Node.js.

How to add Routes to insert data into MySQL database-related tables in Node.js API?

Example How to use initialize() Function in Node.js/Express API .

Why is Connection Pooling better than Single Connection?.

How to create MySQL database using node.js.

Translate »