Reputation: 7888
I have a specific project where I need to wrap every code line at 65 characters. I have set up the eclipse Java code formatter properly for this. But what I really want is a vertical line to be drawn in the editor showing where the max line width while I am typing, not just when I run the formmater. I know this feature is available in some capacity because it is displayed in the code formatter property page.
I don't see any option in eclipse to turn this on and I didn't see any plug-ins that do it on Eclipse Plugin Central
Upvotes: 220
Views: 102287
Reputation: 11
After some months with Espressif, but also with other brands plugged-in Eclipse, I found how to enlarge maximum line width. I made a lot of attempts and show how to do for Espressif-IDE:
Right click a project->properties->C/C++ General->Formatter ->Enable Project specific settings-> New->Give your profile a name and base it on a built-in formatter: I choose BSD/Allman->Edit this new profile->within Line Wrapping tab type for example 200 for Maximum line width->Apply changes.
Format source files: you'll have long lines.
Before I did the same manouvres starting from: Window->Preferences->C/C++->code Style->Formatter... : that never worked.
Upvotes: 0
Reputation: 52449
@Jon Skeet's answer is incomplete.
Window
--> Preferences
--> General
--> Editors
--> Text Editors
--> check the box for Show Print Margin
Ticking this box will show the vertical line.
As a quick way of finding this, use the search filter in the top and filter on "margin".
However, this only shows the line, but under most situations the "Print margin column" value there is flat-out ignored.
To set the column number for where the line should be, do what @John Percival Hackworth mentions here:
Window
--> Preferences
--> C/C++
[or whatever language you are using] --> Code Style
--> Formatter
--> click Edit
--> under the Line Wrapping
tab set the value you desire for Maximum line width
.
How do you enforce hard line wrapping at the column you set above (ie: that adds a carriage return)? I don't know yet. If you figure it out let me know. In Sublime Text 3 (a much better editor but with a much worse indexer/function definition finder :() it's Alt + Q.
Update: I think it may be possible with the "CppStyle" plugin, which uses clang-format
, by using Ctrl + Shift + F to apply the auto-format, but I don't know the exact instructions to make it work yet.
Upvotes: 7
Reputation: 1499770
Look in Windows / Preferences (at least on Windows - IIRC it moves around for different operating systems) then:
General -> Editors -> Text Editors -> Show Print Margin
Tick this and it should show the line.
As a quick way of finding this, use the search filter in the top and filter on "margin".
Notes from the comments - unverified by me, but I have no reason to doubt them:
It has changed somehow in 2016: For details see [here] (https://bugs.eclipse.org/bugs/show_bug.cgi?id=495490#c2) You have to set it in the formatter: From menu [Window]-->[Preferences], select [Java]-->[Code Style]-->[Formatter], and then edit your formatter profile. In the tab page [Line wrapping], you can find a setting named "Maximum line width". Change this setting, and the print margin in Java source editor will be changed too.
Upvotes: 376
Reputation: 52488
In Eclipse Luna (4.4):
Choose menu Window\Preference
. Look at top-left corner, in search box type filter text
, type: margin
.
In section Apperance color option
, Choose Print margin
. Choose Show print margin
. In text box Print margin column
, type 65
as what you want.
Upvotes: 48