I have some comments in my code:
//asdf
when I use clang-format on it, it adds a space just after the // characters:
// asdf
How can I prevent that from happening in the clang-format configuration ?
Thanks
You can use comments in your code to disable clang-format from modifying a section of code: Note the space in between the comment start ( //) and clang-format. This space is required for the comment to be successfully detected. There are clang-format integrations for vim, emacs, BBEdit, and Visual Studio described in the clang-format documentation.
Note the space in between the comment start ( //) and clang-format. This space is required for the comment to be successfully detected. There are clang-format integrations for vim, emacs, BBEdit, and Visual Studio described in the clang-format documentation.
ColumnLimit ( Unsigned) clang-format 3.7 The column limit. A column limit of 0 means that there is no column limit. In this case, clang-format will respect the input’s line breaking decisions within statements unless they contradict other rules. CommentPragmas ( String) clang-format 3.7
clang-format supports two ways to provide custom style options: directly specify style configuration in the -style= command line option or use -style=file and put style configuration in the .clang-format or _clang-format file in the project directory.
Combining the answers to these two questions should solve the problem:
So the following line in your .clang-format
file should do the trick (I did not test it):
CommentPragmas: '^[^ ]'
That tells clang-format not to mess with comments that start with something other than a space.
For completeness, clang-format documentation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With