Tips and Tricks
Organize Your VS Code Extensions by Development Task
NOTE: Because Code Builder is a web-based, these tips are not of relevance if Code Builder is your development environment of choice.
Organizing your VS Code extensions by development task can help you avoid having extensions provide functionality that’s not useful for the task at hand. Having only the extensions that you need helps minimize the VS Code startup time and ensures that shortcut keys don’t interfere with one another. Here’s how to set up VS Code to launch with only the extensions for working with Salesforce.
-
Add a
code-sfdx
alias to your shell’s startup script.-
Windows
- When you install VS Code, install
code
as part of your prompt. See Visual Studio Code on Windows in the Visual Studio Code docs for details. - Open Git Bash. (Git Bash is installed as part of Salesforce CLI.)
- Check whether you have a
.bashrc
file. If you don’t, create it by running:
touch .bashrc
- Add this line to your
.bashrc
file.
alias code-sfdx='code --extensions-dir ~/.sfdx-code'
- When you install VS Code, install
-
macOS or Linux
- Open VS Code.
- To open the Command Palette, press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Linux).
-
Run the command Shell command: Install ‘code’ command in PATH.
This command lets you invoke `code` directly from your favorite terminal.
-
In your favorite terminal, open your shell’s startup script.
If you’re using Bash, the startup script is typically your
.bashrc
or.bash_profile
file. If you’re using Z Shell, it’s typically your.zshrc
file. If you don’t have a file with these names, create a file called.bashrc
in your home directory (for example, inMacintosh HD/users/yourName
). - Add this line to your shell’s startup script.
alias code-sfdx='code --extensions-dir ~/.sfdx-code'
-
-
Either open a new terminal window or run one of the following commands from your current terminal.
source .bashrc
source .bash_profile
source .zshrc
-
From the terminal, run
code-sfdx
to launch an instance of VS Code that has only your extensions.NOTE: The first time you launch
code-sfdx
, it has no extensions because it’s a fresh instance VS Code. -
Select View > Extensions.
-
Install the Salesforce Extension Pack extension (and any other extensions that you use for Salesforce development).
-
The next time you’re working on a Salesforce DX project, you can launch VS Code using
code-sfdx
and all your extensions will be there.
You can have as many aliases as you want, with as many extensions-dir
directories as you need to help organize your extensions.