IntelliJ:禁用Kotlin多行接口方法签名后自动换行
解决IntelliJ中Kotlin接口多行方法后自动添加空行的问题
你可以通过以下步骤修改IntelliJ的代码风格设置来禁用这个行为:
- 打开设置面板:使用快捷键
Ctrl+Alt+S(Windows/Linux)或Cmd+,(Mac) - 进入Kotlin代码样式设置:依次展开
Editor > Code Style > Kotlin - 切换到Blank Lines标签页
- 在Between declarations分组下,找到In interfaces里的After multiline declaration,将其值改为
0 - 点击Apply和OK保存更改
修改后重新格式化代码,原本在多行方法签名后自动添加的空行就会消失,回到你期望的格式:
格式化前:
interface Foo { fun method0() fun method1( arg1: Int, arg2: Int, arg3: Int, ) fun method2() }
格式化后:
interface Foo { fun method0() fun method1( arg1: Int, arg2: Int, arg3: Int, ) fun method2() }
内容的提问来源于stack exchange,提问作者Son Nguyen
相关产品推荐
相关产品推荐

