How to align code in the Eclipse Force.com IDE

How to align code with the Force.com ID Eclipse database. The shortcut key "CTRL + SHIFT + F" does not work for Apex code.

+6
source share
3 answers

None of the suggestions work for me yet. Note that the Force IDE opens the Apex class in the Apex editor. This editor does not appear in the list of contexts that you can associate with a key event. For example, this list contains contexts such as โ€œediting in structured text,โ€ โ€œediting in a Java source,โ€ etc.

Apex Editor does not contribute to the Source menu on the right-click menu. Thus, there is no way to get the ability to format.

I tried to open the apex class in Java. Now the "Source" option appears, the format option does nothing. (Therefore, no key event can do anything.)

The only thing I can find is ...

Select a file .... Open with ... Other ... find a Java editor. When the file is open ... select all the text .. right-click and select "Source" ... "Indent correctly."

This does not reformat, but eliminates the indentation problem.

Someday I hope that SFDC will make the code for the open source Force IDE. Then we, as a community, could create more tools for developers.

+4
source

Apex classes and triggers use a different editor than Java. Autoformat (or code alignment) does not work with Apex Code (or Apex code editor). I could not get CTRL-SHIFT + F to work in the latest version of Eclipse using the Force.com IDE. I believe that this is due to the fact that autoformat is designed to work only with Java.

However, if you switch to the Java perspective and open your Apex class with a Java editor, CTRL + I will correct the indent correctly.

+3
source

Go to Preferences -> General -> Keys and enter "format" in the search field, you will see which keys (if any) are associated with format commands. Then you can snap what you like, or use the ones available.

0
source

Source: https://habr.com/ru/post/905599/


All Articles