For supported files in VSCode we get an option (when you right click on the file editor) to Format Document (ALT+SHIFT+F)
.
But unfortunately for Groovy this option is not available. And according to the VSCode community, there are no plans to implement this feature.
Is there an alternative solution available, specifically for VSCode?
The code formatting is available in Visual Studio Code through the following shortcuts: On Windows Shift + Alt + F. On Mac Shift + Option + F.
To do this, go to File->Preferences->Settings: Under Text Editor, select Format On Save. Now when saving a file, it will be beautified. THANKS FOR READING.
Prettier is an opinionated code formatter which ensures one unified code format. It can be used in VS Code by installing it from the VS Code Marketplace. Once you have integrated it in VS Code, you can configure Prettier to format your files when saving them or committing them to a version control system (e.g. Git).
I don't know how well this works for formatting other than indentation, but I simply changed the file extension from .groovy to .js, right clicked in the file, and selected "Format Document". It fixed the indentation for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With