2

What extension can be used in Visual Studio Code to format .cls files?

2 Answers 2

3

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.

1
  • Thats very unfortunate. Was afraid this was the ans. thanks.
    – rynop
    Jul 11, 2018 at 18:14
1

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

3
  • 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.
    – identigral
    Sep 11, 2019 at 0:20
  • Hi @identigral, do you think now Is Better? Sep 13, 2019 at 21:48
  • Better, thank you
    – identigral
    Sep 13, 2019 at 21:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .