如何在 CLion 中的 if/for/while 后自动添加括号?

How to auto add the parentheses after if/for/while in CLion?

当我使用 IDEA 时,键入 if/for/while,括号将自动完成 added.But CLion 不会自动完成。

想法

CLion

如何解决这个问题?

它可以在 Settings/Editor/General/Smart Keys 中找到(或者只需转到帮助-> 查找 -> 智能键)

您可以选择检查 HomeEnd (on blank line)Insert pair bracket 等。检查 Insert pair bracket。应该这样做。

您需要使用完整的语句 (Ctrl+Shift+Enter)。

void foo() {
  if|<Ctrl+Shift+Enter>
}

生成

void foo() {
  if (true|<Ctrl+Shift+Enter>) {
  }
}

再完成一次就可以进入区块:

void foo() {
  if (true) {
    |
  }
}