Eclipse auto format: set the maximum line length
Codemia Knowledge Hub ·
Eclipse's maximum line length for auto formatting lives in the formatter profile: open Window > Preferences > Java > Code Style > Formatter, edit a profile, and set the width on the Line Wrapping tab. Then format with Ctrl + Shift + F (Command + Shift + F on macOS) or on save. The formatter wraps any line longer than that width, which keeps code within the limit your team's style guidelines set.
Setting the maximum line length
- Open Preferences:
Window>Preferenceson Windows or Linux,Eclipse>Preferenceson macOS. - Open the formatter: expand
Java(or the language your project uses), selectCode Style, thenFormatter. - Edit a profile: select an existing formatter profile and click "Edit", or create a new one.
- Open Line Wrapping: in the edit dialog, go to the
Line Wrappingtab. - Set the width: enter the value you want in
Maximum line width. Comments have a separate width,Maximum line width for comments, on theCommentstab. Common standards are 80 or 120 characters, depending on your team's code style. - Save: click "OK" to save the profile with the new setting.
| Step | Location | Action |
| 1 | Window > Preferences | Open Eclipse Preferences |
| 2 | Java > Code Style > Formatter | Navigate to Formatter settings |
| 3 | Edit/Create Profile | Select and edit/create a formatter profile |
| 4 | Line Wrapping Tab | Access line wrapping settings |
| 5 | Set Maximum Line Width | Enter desired maximum line length |
| 6 | Apply and OK | Save and apply changes |
Applying the formatter
- Manually: right-click in the editor and choose
Source>Format, or pressCtrl + Shift + Fon Windows/Linux orCommand + Shift + Fon macOS. - On save: in
Preferences, go toEditor>Save Actions, enablePerform the selected actions on saveand checkFormat source code.
Why a line limit helps
- Readability: shorter lines are easier to read, especially for new developers or external teams.
- Consistency: the whole codebase looks uniform, which makes maintenance easier.
- Less horizontal scrolling: lines fit on screen, so you rarely have to scroll sideways to read code.
The setting matters most in large projects where many developers work on different parts of the same codebase, because the shared formatter profile keeps everyone's code wrapped the same way.
Related reading
- Effect of using page-able memory for asynchronous memory copy?
- Effective queries in machine learning
- Efficent way to split a large text file in python
- Efficiency of crossover in genetic algorithms
- Efficiency of Java Double Brace Initialization?
- Efficient algorithm for detecting cycles in a directed graph
- Efficient algorithm for finding a common divisor closest to some value?
- Efficient algorithm for finding all maximal subsets

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.