Monday, August 12, 2019

c++ - How to prevent clang-format to add space after comment char?



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


Answer



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.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...