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

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -