IntelliJ IDEA社区版2019.2:Scala格式化调整case class位置
Fixing Scala Formatting Order in IntelliJ IDEA 2019.2 Community
Hey there! I’ve run into this exact issue before, so let me walk you through how to tweak the settings to get your desired code order:
- First, open up the Settings panel. You can use the shortcut
Ctrl+Alt+S(Windows/Linux) orCmd+,(Mac), or go to File > Settings from the top menu. - Navigate to Editor > Code Style > Scala in the left sidebar.
- Switch to the Arrangement tab—this is where all the code sorting rules live.
- Look at the Rules list on the right. You’ll see entries for different code elements like type definitions, methods, case classes, etc.
- Find the rule for
Case classesand use the up/down arrow buttons on the right side of the list to move it above theMethodsrule. Make sureType definitionsstays at the top. - Hit Apply then OK to save your changes.
Now when you use your formatting shortcut (default is Ctrl+Alt+L), your code should be ordered as: type definitions → case classes → functions, just like you wanted!
内容的提问来源于stack exchange,提问作者mjbsgll
相关产品推荐
相关产品推荐

