coding style - How could I indent C++ pragma using clang-format? -
i using vim-autoformat
, uses clang-format
external formatter.
it seems clang-format
won't indent c++ #pragma
. example:
#include <omp.h> #include <cstdio> int main() { #pragma omp parallel (int = 0; < 10; ++i) { puts("demo"); } return 0; }
i have formatted :
#include <omp.h> #include <cstdio> int main() { #pragma omp parallel (int = 0; < 10; ++i) { puts("demo"); } return 0; }
i checked clangformat, didn't find option use.
it's been late solution looking for. formats pragma along code block.
https://github.com/medicineyeh/p-clang-format
the main concept replacing string formatter uses "correct" rules on these pragmas. motivative example following.
# replace "#pragma omp" "//#pragma omp" sed -i 's/#pragma omp/\/\/#pragma omp/g' ./main.c # format clang-format ./main.c # replace "// *#pragma omp" "#pragma omp" sed -i 's/\/\/ *#pragma omp/#pragma omp/g' ./main.c
Comments
Post a Comment