1

I'm trying to fix the style in a directory of about 60 .c and .h files. This can be taken in steps (e.g. I don't have to figure out find and vim script syntax at the same time), but ultimately I want to do something like this:

find . -name '*.[ch]' -exec vim "{} +'set tabstop=2 shiftwidth=2 expandtab | wq'" \;
1

While using vim might work, a better alternative would be a tool designed for formatting source code.

0
find . -name '*.[ch]' -exec vim +"set tabstop=2 shiftwidth=2 expandtab | retab | wq" {} \;

Wow. The linux command line is incredible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.