Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to exclude lines from being auto-formatted? #235

Closed
davidzchen opened this issue Mar 20, 2024 · 2 comments
Closed

Is there a way to exclude lines from being auto-formatted? #235

davidzchen opened this issue Mar 20, 2024 · 2 comments
Labels

Comments

@davidzchen
Copy link

Are there annotations that can be added to the code to omit certain lines from autoformatting?

@davidzchen
Copy link
Author

Never mind. Looks like this is a feature specific to formatters: https://stackoverflow.com/questions/33258159/how-to-make-clang-format-skip-sections-of-c-code

@dbarnett
Copy link
Contributor

Yes exactly. For example clang-format does support clang-format off directives: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#clang-format-style-options. YMMV with different formatters.

You're not going to want to embed formatting rules in anything specific to a vim plugin because they'd be blown away when you format the file outside vim.

OTOH, #9 to format lines more selectively could be helpful here to not have the formatter fighting you quite so aggressively when you are unlucky enough to be fighting the formatter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants