Reputation: 2494
I'm dealing with a bunch of legacy C code whose formatting is all over the place and I would like to clean it up as I work. However, there are some sections that I do not want touched (or I'd rather format manually (such as structures being used as bitfields with an explanation as to what each bit represents in comments). I'm working in an embedded environment, so understanding what each bit represents is important and keeping that nicely formatted is important, however, the C-lang formatter in VS Code wants to do its own thing with this kind of stuff.
How can I exclude sections of a file from autoformat?
Upvotes: 7
Views: 3265
Reputation: 180651
Are you using the clang-format extension clang-format ? If so, see disable formatting on a piece of code.
int formatted_code;
// clang-format off
void unformatted_code ;
// clang-format on
void formatted_code_again;
Upvotes: 12