1

I'm using the Eclipse built-in formatter. Let's say I have the following method:

    protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests()
            .antMatchers("/", "/home").authenticated()
            .anyRequest().authenticated()
            .and()
        .formLogin()
            .loginPage("/login")
            .permitAll()
            .and()
        .logout()
            .logoutSuccessUrl("/login?logout")
            .permitAll();
}

When I try to format my class (Ctrl+Shift+F), it become like this:

    protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/", "/home").authenticated().anyRequest().authenticated().and()
            .formLogin().loginPage("/login").permitAll().and().logout().logoutSuccessUrl("/login?logout")
            .permitAll();
}

How can I keep the original formatting of how I split the china of method calls and still be able to format other parts of the code?

Suleiman Alrosan
  • 337
  • 2
  • 4
  • 14
  • Instead of turning the formatting off, you can configure it not to join already wrapped lines. Similar to Jitter's response, here's for Eclipse STS: Properties → Java Code Style → Formatter → Enable project specific settings OR Configure Workspace Settings → Edit → Line Wrapping (tab) → check "Never join already wrapped lines" Save, apply. – Suleiman Alrosan Oct 07 '16 at 15:51

0 Answers0