Eclipse: Automatic line wrapping to specified width

前端 未结 3 1416
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 08:56

I\'d like for my lines, especially within comments, to be automatically managed so they don\'t get too long.

I remember once I had a configuration for vim

相关标签:
3条回答
  • 2020-12-30 09:34

    In "Windows -> Preferences", go to "Java -> Code style -> Formatter" to customize the formatter (called when you click Ctrl+Shift+F). In the tab "comment", you can set the maximum line width for comments (it can be different then the line width for code).

    Tip: in the preferences, "Java -> Editor -> Save actions", you can make Eclipse to automatically format your file when you save it, so your code is always correctly indented !

    0 讨论(0)
  • 2020-12-30 09:37

    The automatic formatting of Eclipse great no question.

    If your comments are reformatted depends on what comment type and how you already have inserted line breaks.

    Writing for example one very long line comment starting with // will be broken down by the formatter into multiple lines.

    However you later edit the formatted lines - e.g. delete parts of it the formatter will leave them as they are. Only over-long lines will be changed.

    Just in difference to block comments like this: /* comment */ Those comments will always be re-formatted in case the line is too short or too long.

    0 讨论(0)
  • 2020-12-30 09:43

    If you want to format your header comment, you have to check Enable header comment formatting - that was the trick for me.

    Obviously, to use this, you must create new formatter profile.

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