How can I revert restrictive line length limits?

Answered

I know how to set the line length limit, and am able to reformat from a longer line length (120) to a shorter line length (80).  However, I need to go in the opposite direction- I have source files which were wrapped at 80 chars and I want to extend these lines to 120 chars (subject to the settings in java editor).  I'm able to change it to 120 and anything new will be subject to this limit, but what can I do about existing lines short of manually editing them?

thank you

0
7 comments

Make sure line breaks are not kept when reformatting:

0
Avatar
Permanently deleted user

already tried that and it didn't seem to make a difference (but thanks)

0

Please share a sample project with the code style saved with the project and the sample file that is not formatted as you'd expect: https://uploads.services.jetbrains.com/ .

0
Avatar
Permanently deleted user

not easy to do right now, but my settings are what you show above and it is a standard java file.

my question is did it work for you?  can you take a java file and reduce the line length limit (then reformat) and then increase the line length limit (then reformat) and it reverts to what it originally was?

 

0

Before reformat:

After reformat:

0
Avatar
Permanently deleted user

well that's good news in that intellij can handle this case, not sure why it's not working for me but I'll reset my settings etc and try again with a different file.  
I'm assuming all you changed was the Hard Wrap value prior to each Code->Reformat action

thanks

0
Avatar
Permanently deleted user

got it to work.  what is interesting is that when I reformatted my original java file nothing changed (line length limit 120), meaning my file as is was consistent with the (default) rules defined under Settings->Editor->Code Style->Java. 

When I reduced the limit and again reformatted it reorganized it, as would be expected.  However, when I again increased the length limit to 120 and reformatted it did *not* revert to my original formatting.  This makes sense as, I imagine, there are multiple ways a file can meet the rules, and as long as it does intellij won't change it.  On the downside though your original (format) state is lost.

0

Please sign in to leave a comment.