function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pooja ShahPooja Shah 

Formatting code in Eclipse

To use the built in formatter of Eclipse we can ideally use the ctrl+shift+F key. However this doesnt seem to work when I try formatting my apex classes.
Can anyone tell me if I need to change some settings to format the code?

In Summer '08, the IDE does not support Apex code formatting.

Here it is written, that you can use the java editor to indent your code..

for me, this works fine!

Chirag MehtaChirag Mehta

As Alexander pointed out use JAVA editor and JAVA formatting option to format Apex Code


Apex classes and triggers use a different editor than Java. The auto formatter (or code alignment) does not work with Apex Code (or the Apex Code Editor). I couldn't get CTRL-SHIFT+F to work in the most recent version of Eclipse with the IDE, either.

I believe this is because the auto formatter is designed to work with Java only.
However, if you switch to the Java perspective and open your Apex class with the Java Editor, CTRL+I does correct indentation properly.

Source :