'Intellij disable new line before annotated field for Kotlin
IntelliJ autoformat keeps adding a blank lines between class field declarations having annotations. Do you know how to disable it? This happens for kotlin files since does not work like that for java files.
Example, between each var
intellij adds a blank line each time I execute autoformat.
class Resign : UnitTest() {
@InjectMocks
private lateinit var resignService: ResignServiceImpl
@Mock
private lateinit var actionAccess: ActionAccess
@Mock
private lateinit var userReportConverter: UserReportConverter
....
}
Solution 1:[1]
The problem was fixed in KT-37891. The option to disable this behavior should be available in the next plugin version.
You may also consider voting for KT-32185: 'More code style options for minimum blank lines'
Solution 2:[2]
Go to Settings > Editor > Code style > Kotlin > Wrapping and Braces.
Change Property annotations to "Do not wrap" or "Wrap if long".
Solution 3:[3]
No answer properly points out the exact name of the configuration. Under the Kotlin code style, it can be found on the "Blank Lines" tab, with the name "Before declaration with comment or annotation".
For me, this defaulted to 1. Setting it to 0 let's me decide myself whether I want a new line or not.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Koyasha |
Solution 2 | Nicolas |
Solution 3 | Magnilex |