我有以下格式不正确的文件,
test.cpp
#include "maininclude.h"
int main() {
class SIMPLE smpl;
for (int i = 1; i < 100;
i++) {
printf("Printing %d", i); // Trying out different stuff...
getchar();
}
}
clang-format
. 在运行这个之前,为了直观地看到要修改的地方,我运行
clang-format -n test.cpp
. 这将正确识别由于终端上的格式和输出错误而将被更改的点:
test.cpp:3:13: warning: code should be clang-formatted [-Wclang-format-violations]
int main() {
^
test.cpp:5:27: warning: code should be clang-formatted [-Wclang-format-violations]
for (int i = 1; i < 100;
^
test.cpp:6:9: warning: code should be clang-formatted [-Wclang-format-violations]
i++) {
^
test.cpp:7:64: warning: code should be clang-formatted [-Wclang-format-violations]
printf("Printing %d", i); // Trying out different stuff...
^
跑步时
clang-format test.cpp
,我获得格式正确的文件的外观(此显示在终端上):
#include "maininclude.h"
int main() {
class SIMPLE smpl;
for (int i = 1; i < 100; i++) {
printf("Printing %d", i); // Trying out different stuff...
getchar();
}
}
test.cpp
磁盘上的文件。是否有单独的选项/命令
叮当声格式
是否继续应用其更改并将文件保存到磁盘上?