Blog >> Salesforce >> Why and how to use Visual studio code for Salesforce

Why and how to use Visual studio code for Salesforce

how to use visual studio code for salesforce

What is Visual Studio Code?    

Visual Studio Code is a source-code editor that supports any language, developed by Microsoft for Windows, Linux, and macOS.

Its a free and open source code that runs natively on all platforms. The streamlined code editor is supported for development tasks such as debugging, task running, and version control.

Click here to know about other services and our capabilities

By using VS Code, all Salesforce metadata can be stored in a local machine by using package.xml.

A Scratch org can be created using Salesforce DX commands in Visual Studio Code. This saves time because it is easier and faster for Salesforce Development in Visual Studio Code for sandboxes and Scratch Orgs. Salesforce’s Lightning web component can only be built in Visual Studio Code for better source control management. Deployment can be done in different environments using VS code.– Download and Install Visual Studio Code for Windows, Mac, Linux.

Prerequisite for VS code

Salesforce CLI

CLI processes commands to a computer program in the form of lines of text. The program that handles the interface is called a command-line interpreter, or command-line processor.

Salesforce uses the CLI commands to create environments for development and testing, synchronizing source codes between the scratch orgs and the version control system, and the execute test suites.

At this point, you can aggregate all the tools you need to develop with and to perform commands against your Salesforce org.

Install Salesforce CLI

Before installing the Visual Studio Code, install Salesforce CLI to prevent future coding issues.

Next, download and Install Salesforce CLI for Windows, Mac, Linux. (See Figure 1)

Figure 1

After installing Salesforce CLI, the SFDX Commands will be available in the Visual Studio Code command palette (shift+ctrl+p). (See Figure 2)

Figure 2

By using the Salesforce DX commands, Visual Studio Code will make connections to the Salesforce platform and perform actions such as Create, Retrieve, and Deploy code to and from Salesforce orgs.

How To Use Visual Studio Code:

Install Extensions in Visual Studio Code.

  1. Salesforce CLI Integration
  2. Salesforce Extension pack

Salesforce Extension pack consists of several extensions, all of which are published by Salesforce. The extension pack has the following extensions, as of now, which will be activated automatically when you install this pack.

The Salesforce CLI Integration Extension Pack

  • Apex
  • Visualforce
  • Aura Components
  • Apex Interactive Debugger
  • Apex Replay Debugger
  • Lightning Web Components

(See Figure 3)

Figure 3

Connecting a Salesforce Org:

After installing Salesforce CLI, Visual Studio Code and related extensions are now ready to connect to Salesforce org. Go to command palette (ctrl+shift+p to open) and type “create project with manifest”. The SFDX command will pop up. Click on it to create a folder and give it a project name. Then create a folder on your local machine. (See Figure 4)

Figure 4

After creating a folder, it will show as in Figure 5.

Figure 5

Authorize an Org

Type “Authorize an Org” in the command palette and click on the SFDX command: Authorize an Org. (See Figure 6)

Figure 6

Choose the environment for which Salesforce org is to be connected with Visual Studio Code to retrieve and deploy the code. Enter the Salesforce credentials and allow access for Salesforce CLI to connect to the org. (See Figure 7)

Figure 7

After successful authorization of the Salesforce org, go to the folder and add the list of components in package.xml to retrieve it from org. After adding the components list, right click and choose SFDX: Retrieve Source in Manifest from Org. All the components mentioned in package.xml will be retrieved and stored in folder (local machine). (See Figure 8)

Figure 8

Retrieved components will be stored in force-app\main\default in their respective subfolders. Any classes can be opened in VS code editor and can be modified and saved in VS code. (See Figure 9)

Figure 9

Once the modification is done in VS code, a user can deploy it to any authorized environment from VS code. Then specify the list of components in Package.xml and choose the SFDX: Deploy source in manifest to org command to deploy as shown in Figure 10. (See Figure 10)

Figure 10

Best Practices for CloudQ

Now that you have the basics of how to use Visual Studio Code, you understand the best practices we, here at CloudQ, follow. We use them in everything from development, to implementation and integration, to managed services. Click here to see how else we use best practices to help business executives solve their business challenges.


Your business deserves the best, and as a leading Salesforce development company in the USA, CloudQ can help you get there.

Why break the bank with more expensive options that give you the same results?

Contact us for a consultation with our Salesforce experts today

Tell us a bit about yourself, and we’ll tell you a lot more about us.


Venvas Emmanuvel

Pin It on Pinterest