Is there an Eclipse line-width marker?

后端 未结 3 2006
滥情空心
滥情空心 2020-12-07 10:30

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

3条回答
  •  广开言路
    2020-12-07 11:04

    @Jon Skeet's answer is incomplete.

    (1/2) First, do what he said:

    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:

    (2/2) Go to:

    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.

    Side note:

    1. Use Alt + Shift + Y to toggle soft line wrapping on and off. It will soft wrap (ie: no carriage return) at the end of the screen, however, not at the column you set above.

    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.

    Related:

    1. Set tab width: Changing editor tab width in eclipse 3.5

提交回复
热议问题