I am using Visual Studio Code on MacOS with sfdx (Salesforce Extension Pack) to develop Lightning Web Components on MacOS. I find that the normal command-shift-P SFDX: Deploy This Source to Org randomly fails when run for a single file in the LWC. Instead you need to right-click on the LWC's folder and then select the picklist item SFDX: Deploy Source to Org. Then it succeeds.

This picklist item is immediatly below SFDX: Delete from Project and Org which is stupid and causes endless nerves whenever I need to upload a delta (frequent since this is UI code).

I would like to create a new keyboard shortcut (and maybe toolbar icon) that runs SFDX: Deploy Source to Org, only for the folder enclosing the open file. Not for the entire project, which might include downloaded objects or libraries that I don't really want to update and would also take more time to upload. How can I create a new shortcut? Do I have to research how to create a new extension of my own?

FYI I did try adding a keyboard shortcut in the Preferences > Keyboard Shortcuts screen for SFDX: Deploy Source to Org. But I get these errors, same as I was getting on single file upload:

  • Cannot find Lightning Component Bundle xxx. (where xxx is the folder name)
  • duplicate value found: duplicates value on record with id: I get 2 of the first error. The second error (duplicate value found) is a famous one for deployment errors, and it shows up for a file that actually has only comments in it. Ugh. Also when I try the new shortcut after clicking on the lwc's folder name, I get this nasty error:
  • Error deploying or retrieving source: The file or directory that you tried to deploy or retrieve isn't in a package directory that's specified in your sfdx-project.json file. Add this location to your "packageDirectories" value, or deploy or retrieve a different file or directory. For details about sfdx-project.json, see: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm

Of course adding the lwc's path does not fix the error..

A keyboard shortcut would be best. Ultimately having also a new icon in VSCode would be nice, and for fun one day, hooking up an external button device or custom keypad would be the cherry on top! ;)

The VSCode extensions installed are: Salesforce CLI Integration, Salesforce Diff, Salesforce Extension Pack, Salesforce Package.xml Generator, SLDS Validator.

1 Answer 1


You can enable Deploy On Save to solve this instead of implementing a keyboard shortcut.

The instructions to enable are documented here.

To enable deploy on save, you can:

Add "salesforcedx-vscode-core.push-or-deploy-on-save.enabled": true to the .vscode/settings.json file.

Or update Workspace settings:

Select File > Preferences > Settings (Windows or Linux) or Code > Preferences > Settings (macOS). Under Salesforce Feature Previews, select Push-or-deploy-on-save: Enabled.

enter image description here

  • Already enabled, but does not seem to actually deploy to SFDC when I save a file..
    – skycafe
    Commented Mar 4, 2022 at 11:56
  • @skycafe what is your operating system and also version of your Salesforce Extension pack for vscode. This functionality should work, if it does not that simply means something wrong with how you have set it up in your machine Commented Mar 4, 2022 at 16:10
  • Sorry I missed your comment. MacOS 10.15.7 Catalina, A recent VS Code (my version now is from 3 weeks ago), Salesforce Extension Pack: v54, 6/2/2022. FWIW I also had a bad bug just the other day after renaming a class to upper case, this has been around a while it seems too.
    – skycafe
    Commented Jun 8, 2022 at 10:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .