How to call clang-format over a cpp project folder?

后端 未结 9 2168
眼角桃花
眼角桃花 2021-01-29 21:43

Is there a way to call something like clang-format --style=Webkit for an entire cpp project folder, rather than running it separately for each file?

I am us

9条回答
  •  猫巷女王i
    2021-01-29 21:51

    I'm using the following command to format all objective-C files under the current folder recursively:

    $ find . -name "*.m" -o -name "*.h" | sed 's| |\\ |g' | xargs clang-format -i
    

    I've defined the following alias in my .bash_profile to make things easier:

    # Format objC files (*.h and *.m) under the current folder, recursively
    alias clang-format-all="find . -name \"*.m\" -o -name \"*.h\" | sed 's| |\\ |g' | xargs clang-format -i"
    

提交回复
热议问题