Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crendking/code-action-from-commands
Create Code Action that executes sequence of commands.
https://github.com/crendking/code-action-from-commands
code-action vscode vscode-extension
Last synced: 17 days ago
JSON representation
Create Code Action that executes sequence of commands.
- Host: GitHub
- URL: https://github.com/crendking/code-action-from-commands
- Owner: CrendKing
- License: mit
- Created: 2024-07-05T00:09:55.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-11-04T01:41:02.000Z (3 months ago)
- Last Synced: 2024-11-10T08:37:56.500Z (3 months ago)
- Topics: code-action, vscode, vscode-extension
- Language: TypeScript
- Homepage: https://marketplace.visualstudio.com/items?itemName=crendking.code-action-from-commands
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Create Code Action that executes sequence of commands, customizable via configuration.
Unlike the general, ubiquitous commands, [Code Action](https://code.visualstudio.com/docs/editor/refactoring) 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](https://code.visualstudio.com/api/ux-guidelines/command-palette), one unique feature that's only available through Code Action is [Code Actions on Save](https://code.visualstudio.com/docs/typescript/typescript-refactoring#_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
```jsonc
"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](https://www.flaticon.com/free-icons/action-figure)