Eclipse IDE
Auto Formatting
Line Length
Programming Tips
Code Optimization

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

  1. Open Preferences: Window > Preferences on Windows or Linux, Eclipse > Preferences on macOS.
  2. Open the formatter: expand Java (or the language your project uses), select Code Style, then Formatter.
  3. Edit a profile: select an existing formatter profile and click "Edit", or create a new one.
  4. Open Line Wrapping: in the edit dialog, go to the Line Wrapping tab.
  5. Set the width: enter the value you want in Maximum line width. Comments have a separate width, Maximum line width for comments, on the Comments tab. Common standards are 80 or 120 characters, depending on your team's code style.
  6. Save: click "OK" to save the profile with the new setting.
StepLocationAction
1Window > PreferencesOpen Eclipse Preferences
2Java > Code Style > FormatterNavigate to Formatter settings
3Edit/Create ProfileSelect and edit/create a formatter profile
4Line Wrapping TabAccess line wrapping settings
5Set Maximum Line WidthEnter desired maximum line length
6Apply and OKSave and apply changes

Applying the formatter

  • Manually: right-click in the editor and choose Source > Format, or press Ctrl + Shift + F on Windows/Linux or Command + Shift + F on macOS.
  • On save: in Preferences, go to Editor > Save Actions, enable Perform the selected actions on save and check Format 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.


Course
Intermediate
27 lessons
15 hours
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 course
Data 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.

Practice algorithms