Intellij or Clion formatter to merge short lines

Answered

My IntelliJ and Clion can help split a long line into multiple with the auto-formatting, but the not the other way around. How should it merge multiple short lines into a single longer line?

This is needed quite often. For example it happens after I renaming a long variable, and that makes the function call chain being able to fit in a single line. My Gift Card Site

Example, what I want is:

1 Codes before formatting:

anObject
.aMethod()
.aField()

2 Intellij or Clion auto-format should change it to:

anObject.aMethod().aField()

0
1 comment

Hello!

You can use the "Join Lines" action - https://www.jetbrains.com/help/clion/working-with-source-code.html#editor_lines_code_blocks:

To join lines, place the caret at the line to which you want to join the other lines and press Ctrl+Shift+J. Keep pressing the keys until all the needed elements are joined.

0

Please sign in to leave a comment.