Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Code Action from CommandsNew to Visual Studio Code? Get it now.
Code Action from Commands

Code Action from Commands

Crend King

|
44 installs
| (0) | Free
Create Code Action that executes sequence of commands
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Create Code Action that executes sequence of commands, customizable via configuration.

Unlike the general, ubiquitous commands, Code Action is a different kind of function that are more contextual to the specific content and language of the document.

While you can't execute a Code Action from the Command Palette, one unique feature that's only available through Code Action is Code Actions on Save. You can use it to execute a Code Action whenever a document is saved.

With this extension, you can create Code Action that executes sequence of commands. Then you can use it in the editor.codeActionsOnSave setting.

One way to know the ID of a command through the Command Palette is to click the gear icon to the right, then check the input box in the "Keyboard Shortcuts" page.

Example configuration

"codeActionFromCommands.codeActions.definitions": {
    // Convert tab to spaces for ALL languages
    "tabToSpaces": {
        "commands": [
            "editor.action.indentationToSpaces"
        ]
    },

    // Preview the Markdown file on save
    "previewMarkdown": {
        "commands": [
            "markdown.showPreview"
        ],
        "languages": ["markdown"]
    },

    // No-op due to empty "languages" array
    "memo": {
        "commands": [
            "workbench.action.editor.changeEOL"
        ],
        "languages": []
    }
}

// enable Code Actions on Save
"editor.codeActionsOnSave": {
    "source.codeActionFromCommands.tabToSpaces": "always",
    "source.codeActionFromCommands.previewMarkdown": "explicit"
}

Attribution

Extension icon: Action figure icons created by Freepik - Flaticon

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft