You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 09:57:03