3

I am on Mac and trying to do a clang-format during the save-action like below.

enter image description here

I also set the quick-key of clang-format like:

enter image description here

But when I type - command + S in Mac, I got the file saved, but the reformat is totally wrong:

class AUtilityTest : public ::testing::Test {
public:
    void SetUp() override {
    }

    void TearDown() override {

    }

protected:
};

TEST_F(UtilityTest, Test1
) {

a = 0.2;
b = 0.3;
for (
int i = 0;
i < 10;i ++) {
std::cout << a + b <<
std::endl;
}
}

I need to manually go to Code -> Reformat Code with clang-format to make it go back to normal.

How do I make it to save with clang-format at the same time? Thanks!

Edamame
  • 23,718
  • 73
  • 186
  • 320
  • https://stackoverflow.com/questions/34648255/using-clang-format-in-clion there is one answer there that seems to do exactly what you need – Andreas DM Mar 08 '19 at 01:19
  • That was not what I need. I can do clang-format normally, I just can not do it along with the save short-cut. – Edamame Mar 08 '19 at 01:25
  • Was the file modified before you saved it? As I know Command+S doesn't save not modified files. – 273K Mar 08 '19 at 03:52
  • Yes, the file is modified – Edamame Mar 08 '19 at 07:22
  • @Edamame, what CLion version you are using? Has it embedded support for ClangFormat? Did you try it with CLion 2019.1 EAP (191.6014.11 build)? – uta Mar 09 '19 at 07:51
  • I am using 2018.3.4 built on Jan 2019. How do I get the latest version? – Edamame Mar 09 '19 at 07:58
  • The latest (EAP - pre-release version - Early Access Program) https://www.jetbrains.com/clion/nextversion/ The latest CLion 2019.1 EAP (191.6014.11 build) has ClangFormat from the box. – uta Mar 10 '19 at 08:13

0 Answers0