How to surround code by curly braces in IntelliJ IDEA?

后端 未结 7 2076
予麋鹿
予麋鹿 2021-02-03 16:50

How to surround code by curly braces in IntelliJ IDEA? Is there any keyboard-shortcut for such operation?

7条回答
  •  借酒劲吻你
    2021-02-03 17:47

    I had oneline if statement without curly braces and I had to update it with braces in whole file. So I updated code style to always add braces for if/else statement. In Idea go to:

    Settings -> Editor -> Code Style -> Java -> Wrapping and Braces (tab)

    Find "'If()' Statement"/"Force braces" and change value from "Do not force"(default) to "Always". Press ctrl + alt + L to reformat your file and curly braces would be added. settings

提交回复
热议问题