how to turn off break line in eclipse

后端 未结 4 864
深忆病人
深忆病人 2021-02-01 16:31

Does anybody know how to turn line breaking in eclipse after you press CTRL + SHIFT + F (code format), ex :

System.err
                    .println         


        
相关标签:
4条回答
  • 2021-02-01 17:14

    The default line wrapping in Eclipse is really rather irritating and the main reason why is that the 'line width' is set as 80 characters, clearly a hangover from the nineteen eighties. This really should be updated now that everyone uses high resolution monitors instead of 80 char wide punch cards.

    You probably don't want to turn it off entirely but instead you want to change the 'line width' to something more sensible (otherwise when you use the auto formatter you may get lines of code that go on forever).

    I would suggest a value of 140, which seems to work nicely for most of us now using 1080p monitors.

    In order to do this you need to...


    With-in Preferences, navigate to...

    > Java
        > Code Style
            > Formatter
    

    You can't edit the default profiles so you have to hit New... and type a name like 'Eclipse 140 Line Width' for your profile and OK.

    Then Edit the profile

    Change to the Line Wrapping tab

    Change the Maximum Line width from 80 to 140.

    Then OK your way out.


    If you then want to fix up your existing code, select your target code and use the Source > Format menu option.

    0 讨论(0)
  • 2021-02-01 17:16

    Go to Window->Preferences->Java->Code Style->Formatter. Create new formatter. Click on edit and then pick tab Line Wrapping and set Line Wrapping policy to Do not wrap.

    0 讨论(0)
  • 2021-02-01 17:22

    There is an option "never join wrapped lines". This will help to keep our custom wrapping unchanged. Great Feature.

    0 讨论(0)
  • 2021-02-01 17:32

    In Helios, set 'Line Wrapping/Function Call/Indentation Policy' to 'Indent on Column' for all cases. This seems to stop the pathological case where it splits a line to try and fit within a fixed width but ends up with it further to the right than it would have been unsplit.

    Or, as suggested above, disable line wrapping, or set a very wide line width. But I find it better to have it wrap and get it right than not to wrap at all.

    0 讨论(0)
提交回复
热议问题