lvxiaomao
V2EX  ›  问与答

[求助] Intellij Idea 格式化换行问题

  •  
  •   lvxiaomao · May 30, 2024 · 1487 views
    This topic created in 738 days ago, the information mentioned may be changed or developed.

    格式化之前 if 条件都在一行,但是已经超过单行代码长度;使用过 option+cmd+L 格式化之后,会自动换行,但是 最后一个或运算(||)放在了第一行行尾,想请问一下如何才能把或运算(||)放在第二行行首呢?

    格式化之前

    if (request == null || StringUtils.isAnyEmpty(request.getRequestUserId(), request.getHostId()) || request.getRoomId() <= 0 || request.getSceneId() <= 0 ) {
                return null;
            }
    

    格式化之后

    if (request == null || StringUtils.isAnyEmpty(request.getRequestUserId(), request.getHostId()) || request.getRoomId() <= 0 ||
                    request.getSceneId() <= 0) {
                return null;
            }
    
    3 replies    2024-05-31 16:39:59 +08:00
    Dreax
        1
    Dreax  
       May 31, 2024
    Settings -> Editor -> Code Style -> xxx -> Wrapping and Braces -> Binary expressions -> Operation sign on next line
    lvxiaomao
        2
    lvxiaomao  
    OP
       May 31, 2024
    @Dreax 感谢感谢
    lvxiaomao
        3
    lvxiaomao  
    OP
       May 31, 2024
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1369 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 16:58 · PVG 00:58 · LAX 09:58 · JFK 12:58
    ♥ Do have faith in what you're doing.