Binding SFDX Commands to VS Code

There are SFDX commands that I would like to bind to a key combo in VS Command but I’m unsure how I would do this. For example, rather then using the CMD+SHFT+P to run SFDX: Execute Anonymous Apex with Editor Contents I would rather bind it to a chord like CMD+ALT+E,A. I can see from the console that running that outputs this command:

sfdx force:apex:execute --apexcodefile /~/.sfdx/tools/tempApex.input

Is there a way to bind this to a key command/chord?


I just looked this up in the documentation, it’s pretty easy.

First, open the Command Palette and choose Preferences: Open Keyboard Shortcuts, or use the menu File > Preferences > Keyboard Shortcuts.

In the search bar, type sfdx execute, and from there, choose the one you’d like to use, click the “+” icon to add a new key binding, and type in the command (e.g. Cmd+Alt+E A), and press Enter. The effect takes place immediately.

You can also add a When filter to make sure you don’t “accidentally” fire off this command when you’re in an invalid context (e.g. editorTextFocus).

Source : Link , Question Author : Xtremefaith , Answer Author : sfdcfox

Leave a Comment