Best Eclipse Code Formatters? [closed]

こ雲淡風輕ζ 提交于 2019-11-29 19:57:59

I always change the formatter in Eclipse to Java Convention AND change the tab policy to always use space instead of tab or mixing of tab and space. Sometime I change also the line width to be 100 or 120 (80 characters is just too narrow in my monitor).

Regarding your specific request: yes you can change this behavior. Go to the Formatter preference and create your own profile. Modify it on tab Line Wrapping and uncheck Prefer wrapping outer expressions (keep nested expression on one line).

More information on: https://bugs.eclipse.org/bugs/show_bug.cgi?id=313524

Anupam Saini

I would highly recommend the google's style guide, it's a collection of coding style guide for commonly used programming languages.

The eclipse configurable Java guide can be found here. Installing the guide is quite simple, Save the style xml to a file and import it using the following dialogue box:

Window -> Preferences -> Java -> Code Style -> Formatter

Finally select the active profile as GoogleStyle.

Vineet Reynolds

In addition to the ability to customize the formatter, as indicated by Thorbjørn, it is also possible to import coding conventions from specific projects, especially the ones from frameworks and libraries that you are working on.

For instance, the Spring framework coding conventions have been made available, as is the case with Android. Eventually, you're better off starting with the Sun coding conventions (than a completely hand-crafted one), with a few tweaks done to suit your organization's coding style and readability requirements.

Have you considered looking at the preferences for the formatter? You can basically configure it to do anything you want.

I would, however, strongly consider the standard Eclipse formatting. It helps a lot to just use the standard, and then adjust your coding style to work well with that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!