【问题标题】:How to format variable strings by alphabetical order using jidea?如何使用 jidea 按字母顺序格式化变量字符串?
【发布时间】:2014-10-22 05:57:26
【问题描述】:

有没有办法使用 IntelliJ-Idea 按字母顺序格式化(排列)变量字符串? 示例代码:

public static final String c = "some_value";
public static final String a = "some_value";
public static final String b = "some_value";

格式化后应该如下所示,

public static final String a = "some_value";
public static final String b = "some_value";
public static final String c = "some_value";

请帮忙。

【问题讨论】:

    标签: java string intellij-idea formatting alphabetical


    【解决方案1】:

    Settings > Project Settings > Code Style > Java > Arrangement ~ Matching Rules。在那里(每个规则)你可以选择order by name。这应该按照您的要求按字母顺序排列。虽然我不知道您是否需要更改所有匹配规则。

    【讨论】:

      【解决方案2】:

      转到File-->Settings--->Code Style(在其下选择Java)--->Arrangement--->Editpublic static final行--->选择Order 作为order by name

      然后从弹出窗口转到Code--->Reformat Code--->Ticked the Reformat entries。-->Run

      就是这样。

      【讨论】:

        猜你喜欢
        • 2012-01-03
        • 2018-03-30
        • 1970-01-01
        • 2015-07-06
        • 2023-03-12
        • 2022-01-02
        • 2016-04-21
        • 1970-01-01
        相关资源
        最近更新 更多