This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes How to set the formatter in Eclipse? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "How to set the formatter in Eclipse?" Watch "How to set the formatter in Eclipse?" New topic

How to set the formatter in Eclipse?

Thomas Chang
Ranch Hand

Joined: May 13, 2008
Posts: 61
Hi all,

Normally one can format the source code in Eclipse with ctrl-shift-f. But the default length of a line is set to 70 charaters. How can I change this to let it be 100 charaters?

Peter Johnson

Joined: May 14, 2008
Posts: 5852

That depends on the file type. For Java source files, the setting is at Window > Preferences > Java > Code Style > Formatter, click Edit, then select the Line Wrapping tab.

For other file types it is in other locations. For example, for HTML is is at Window > Preferences > Web > HTML Files > Editor.

JBoss In Action
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

Actually, I set my lines DOWN to 65 characters. Years ago when I was doing Macintosh development, some of my co-workers had large monitors. I couldn't read their code properly, because it ran outside the viewing window on my smaller monitor.

I've got a nice wide monitor myself these days, but one thing hasn't changed: I still print on standard-sized paper. Wide lines either get truncated (losing data) or wrapped (ruining the nice pretty formatting). So even though I have sufficient screen space, I still keep the lines fairly narrow. 65 was a more or less arbitrary number that was somewhat influenced by the fact that I started on punched-cards, where the normal width was 72 columns.

Although I use the Java pretty-printer to enforce the text width, I also enable the "print width" option. It places a line down the editor view at the end of column 65 so I know
where things are going to wrap.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: How to set the formatter in Eclipse?
It's not a secret anymore!