For example, in the MySQL++ library there are macros that can be used to define simple structs based on sql table definition, like this:
sql_create_6(stock, 1, 6,
mysqlpp::sql_char, item,
mysqlpp::sql_bigint, num,
mysqlpp::sql_double, weight,
mysqlpp::sql_decimal, price,
mysqlpp::sql_date, sdate,
mysqlpp::Null<mysqlpp::sql_mediumtext>, description)
The problem is that clang-format will reformat this in a way that is much more difficult to read (every param on a new line). Most code formatters can recognize special format-off / format-on comments, but I haven't found anything like that in the clang-format manual.
Disabling Formatting on a Piece of Code The code between a comment // clang-format off or /* clang-format off */ up to a comment // clang-format on or /* clang-format on */ will not be formatted.
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.
Short answer: YES. The clang-format tool has a -sort-includes option. Changing the order of #include directives can definitely change the behavior of existing code, and may break existing code.
Tools > Options configuration By default, Visual Studio will use any existing ClangFormat file in your source tree for formatting operations. To turn this off, you can uncheck Enable ClangFormat support.
With this integration you can press the bound key and clang-format will format the current line in NORMAL and INSERT mode or the selected region in VISUAL mode. The line or region is extended to the next bigger syntactic entity. It operates on the current, potentially unsaved buffer and does not create or save any files.
To do so, you can override the defaults by writing another .clang-format file in a subfolder. The tool itself has already been included in the repositories of popular Linux distributions for a long time. Search for clang-format in your repositories.
clang-format. clang-format is a tool to format C/C++/… code according to a set of rules and heuristics. Like most tools, it is not perfect nor covers every single case, but it is good enough to be helpful. clang-format can be used for several purposes: Quickly reformat a block of code to the kernel style.
Change “C-K” to another binding if you need clang-format on a different key (C-K stands for Ctrl+k). With this integration you can press the bound key and clang-format will format the current line in NORMAL and INSERT mode or the selected region in VISUAL mode. The line or region is extended to the next bigger syntactic entity.
In newer version, you can surround a section of code with:
// clang-format off ... // clang-format on
Try adding a //
comment marker after each line, this may do it. I had the same issue in Eclipse and learned this trick.
sql_create_6(stock, 1, 6, // mysqlpp::sql_char, item, // mysqlpp::sql_bigint, num, // mysqlpp::sql_double, weight, // mysqlpp::sql_decimal, price, // mysqlpp::sql_date, sdate, // mysqlpp::Null<mysqlpp::sql_mediumtext>, description)
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