There are many VS Code Extensions that make our lives as developers easier. If I think of the AL programming language, for example, they help us with the following things:
- Replace missing brackets
- Correct the casing of words
- Sort fields in tables
- …and the list could go on forever.
That’s why I thought a while back that it would actually be cool to automatically execute a few of these commands when I save a file in Visual Studio Code. The VS Code Extension AZ AL Dev Tools for example has a setting “alOutline.codeActionsOnSave” which allows us to define a few commands.
That was a good start, but I wanted to be able to use similar functionality for other extensions. So I went searching and found a cool VS Code extension that helped me do that: Run It On
After installing the extension, open your “User Settings” via the Command Palette:
And enter this code here:
Match defines for which files in Visual Studio Code the command should be executed. The command at “cmd” is interesting for you here. There you enter the command of the extension that should be executed. You can find the command by looking in the “Feature Contributions” of the extension:
In the example I have chosen the RunEditorCodeCleanup command of the AZ Al Dev Tools Extension, which in turn executes these commands:
Maybe it is also useful for one of you. Have fun with it 😉