The Apex Master Class

Set Up VS Code for Salesforce Development (Master Class Ep. 5)

3 min read

Subscribe on YouTube

Why Visual Studio Code?

In the last episode I tried to convince you that you need an IDE. Now let’s get one installed.

We’re starting with Visual Studio Code, for one very good reason: it’s the only IDE whose Salesforce plugins are maintained by Salesforce themselves. There’s a full team keeping the Salesforce Extension Pack current and useful. Nobody else can say that.

It’s also free, which is hard to argue with.

The other serious contenders are IntelliJ with Illuminated Cloud 2 (my personal favourite, and we set that up in the next episode) and The Welkin Suite. Both cost money. Both are good. But if you’re just starting out, start here.


What To Install

Three things, in this order:

1. Visual Studio Code
2. The Salesforce CLI
3. Optionally, Node.js and npm. You don’t need it today, but there are a lot of genuinely useful packages out there and it’ll come in handy down the line.

Once VS Code and the CLI are both installed, open VS Code, click the Extensions icon in the left sidebar, search for Salesforce Extension Pack, and install it.

That’s the setup. Now the important part.


The One Hotkey You Must Remember

There is one VERY IMPORTANT HOTKEY in VS Code and it is the one that brings up the command palette:

Ctrl+Shift+P (or Cmd+Shift+P on a Mac)

Remember it, love it, appreciate it, don’t forget it. Or do forget it and just come back to this article. Practically everything Salesforce-related in VS Code happens through that palette, so it’s the first thing to commit to muscle memory.


Setting Up Your Project

We’re going to use the org based development model here. That means your source of truth is still your org rather than a Git repository.

Now, is a repo based model better? Yes, generally. But having been involved in a couple of dozen orgs at this point, I can tell you the majority of clients are still on the org based model, so that’s where we’ll start. We cover the repo based approach later.

The steps:

1. Bring up the command palette and run SFDX: Create Project with Manifest.
2. Pick the standard template and give the project a name and a folder.
3. Bring up the command palette again and run SFDX: Authorize an Org.
4. Choose your login URL. Use Production for a Developer Edition org (yes, really, that’s the right one for the free org we made in episode 2). Use Sandbox only for actual sandboxes.
5. A browser window opens. Log in and click Allow.
6. Open manifest/package.xml and edit it to list the metadata you want. Then right click it and choose SFDX: Retrieve Source in Manifest from Org.

Your org’s code lands in the force-app folder and you’re ready to work. From now on, Ctrl+S saves to disk, and right clicking a file gives you SFDX: Deploy This Source to Org.


Want The Long Version?

This is the condensed, get-you-moving version for the Master Class. I’ve written a much more detailed walkthrough of this exact setup, with every step broken out and screenshots along the way:

Salesforce Development Tutorial: How to Setup Visual Studio Code for Salesforce Development

If any step above didn’t land, go read that one. It’s the same video, covered slowly.

A couple of others worth bookmarking once you’re up and running:

Setting up Uncrustify to auto-format your Apex
Using the SFDX Scanner for static code analysis


What’s Next

You’ve got a working IDE wired up to your org. That’s the toolchain sorted.

In the next episode I’ll show you the IntelliJ and Illuminated Cloud 2 setup, which is what I personally use. You absolutely don’t need both, so if you’re happy with VS Code feel free to skip ahead to episode 7, where we finally start writing code.

See you next time!


Get Coding With The Force Merch!!

We now have a redbubble store setup so you can buy cool Coding With The Force merchandise! Please check it out! Every purchase goes to supporting the blog and YouTube channel.

Get Shirts Here!
Get Cups, Artwork, Coffee Cups, Bags, Masks and more here!


Check Out More Coding With The Force Stuff!

If you liked this post make sure to follow us on all our social media outlets to stay as up to date as possible with everything!

Youtube
Patreon
Github
Facebook
Twitter
Instagram


Salesforce Development Books I Recommend

Advanced Apex Programming
Salesforce Lightning Platform Enterprise Architecture
Mastering Salesforce DevOps

Good Non-SF Specific Development Books:

Clean Code
Clean Architecture