What extension can be used in Visual Studio Code to format .cls
files?
2 Answers
There isn't an official Apex code formatter available right now. The GitHub repository for the Salesforce Visual Studio Code extension package has an open issue for this, and they've solicited feedback on Twitter about their open issues and proposed improvements.
Java formatters often kind of work, but don't yield results that look like idiomatic Apex in some cases. I've seen Uncrustify recommended, although I haven't used it myself - it formats Apex as it if were Java.
Here you can find a guide to how to indent Apex in Visual Studio Code https://mrwolf.altervista.org/how-to-indent-apex-code-in-visual-studio-code/
Simply, it's needed to install uncrustify plugin on visual studio code that give you the possibility to indent apex code using the shortcut CTRL + ALT + F . The linked guide explains how to proceed step by step
-
Welcome to Salesforce SE! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Sep 11, 2019 at 0:20
-
-