Java 8: Formatting lambda with newlines and indentation

后端 未结 9 1161
[愿得一人]
[愿得一人] 2020-12-12 23:46

What I would like to achieve with lambda indentation is the following:

Multi-line statement:

String[] ppl = new String[] { \"Karen (F)\", \"Kevin (M)         


        
9条回答
  •  生来不讨喜
    2020-12-13 00:09

    Eclipse (Mars) has an option for lambda expressions formatter.

    Go to Window > Preferences > Java > Code Style > Formatter

    Click the Edit button, go to the Braces Tag and set the Lambda Body to Next Line Indented

    Another option is update these properties into your project settings. (yourWorkspace > yourProject > .settings > org.eclipse.jdt.core.prefs)

    org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
    org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line_shifted
    

提交回复
热议问题