vscode-cpptools
vscode-cpptools copied to clipboard
Can cpptools support excluding some files while formating?
Feature Request
"C_Cpp.files.exclude" has no effects. Sometimes i want to modify some files but i don't want to change their formats. I think this is a useful function.
How is the formatting invoked? Is it from a formatOnSave?
Yeah, currently, C_Cpp.files.exclude isn't checked when formatting, i.e. it's checked for operations involving global symbols and code analysis (with the additional C_Cpp.codeAnalysis.exclude setting as well).
We could potentially add a setting equivalent to C_Cpp.formatting.exclude which would inherit from C_Cpp.files.exclude, but due to the existing C_Cpp.formatting setting we'd need to use some alternative setting name.
How is the formatting invoked? Is it from a formatOnSave?
In one project, I need to open this configuration when I want to modify some files and need to close this configuration when I want to modify some other files, this is so inconvenient!
A setting equivalent to C_Cpp.formatting.exclude will be perfect.
One potential workaround is to have a 2nd workspace folder for the files that shouldn't be formatted (and set it's formatOnSave differently).
Another potential workaround if you're using clang-format for formatting is to add a .clang-format file to the root of the folder that has the files that shouldn't be formatted:
---
Language: Cpp
DisableFormat: true
One potential workaround is to have a 2nd workspace folder for the files that shouldn't be formatted (and set it's formatOnSave differently).
Another potential workaround if you're using clang-format for formatting is to add a .clang-format file to the root of the folder that has the files that shouldn't be formatted:
--- Language: Cpp DisableFormat: true
Actually my project was configured like this: "C_Cpp.clang_format_style": "{ BasedOnStyle: Google, ColumnLimit: 100}", Is there a way to set C_Cpp.clang_format_style like .clang-format?
Yeah, you could change the style to "file" (the default) (or "file:<path>/.clang-format"
) and put a .clang-format file with
---
BasedOnStyle: Google
ColumnLimit: 100
at the root location where you want formatting to be applied.
And setting
"C_Cpp.clang_format_fallbackStyle": "{ DisableFormat: true }"
will cause formatting to be disable for other folders where a .clang-format doesn't exist in the folder or its parent, or if you want to disable formatting for a subfolder, you could add the previously mentioned .clang-format to that subfolder.
DisableFormat
That works for me, thank you!
This feature request is being closed due to insufficient upvotes. Please leave a 👍-upvote or 👎-downvote reaction on the issue to help us prioritize it. When enough upvotes are received, this issue will be eligible for our backlog.