Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
41 views

Why clang-format add a spacea after 'repeated' keyword in protobuf file?

I am using clang-format to format a protobuf file, and clang-format add a space before dot. protobuf file: message Req { repeated string IDs = 1 [(validate.rules).repeated.min_items = 1]; } I ...
Henry Jiang's user avatar
0 votes
0 answers
20 views

How to customize clang-format for inline multiline lambda after body break before brace

I just updated from llvm 12.0.1 to llvm 18.1.8 and when I run clang-format I am not happy with the modification on inline multiline lambda break before brace : dispatch(this, [this] { if (...
FlikaLB's user avatar
0 votes
1 answer
50 views

Wrap long C++ function heads with clang-format

I just started to use clang-format and I could set up quite a lot of things, but I am stuck with my general handling of long function headers. This is how I usually create them: void ...
FERcsI's user avatar
  • 410
0 votes
1 answer
121 views

How to enable aligning multiple variable declarations

I want to set up my clang-format to format this: double var1, var2, var3, var4; into this: double var1, var2, var3, var4; Is there a way to achieve this? If it cannot be set to align it, ...
Wolfiwolf's user avatar
2 votes
1 answer
53 views

How to make clang-format don't allow structure array elements in a single line

I'm trying to make my .clang-format config. Everything is fine, but there is still a little problem. When I format this: struct testStruct data[] = { {.a = 0, .b = 0}, {.a = 0, .b = ...
酸柠檬猹's user avatar
0 votes
0 answers
46 views

clang-format: How to keep the braces of an empty struct inherited from `decltype(...)` on separate lines?

I'm trying to upgrade my project's clang-format version from 12 to 18. No changes were made in the project's ".clang-format" file, I've only upgraded the version of the clang-format program. ...
Taras's user avatar
  • 538
2 votes
1 answer
67 views

clang-format option to set penalty for breaking preprocessor directives

Is there an option to set the penalty for breaking preprocessor directives into multiple lines? For example, if I have the following snippet: #define my_constant 1 // Lorem ipsum dolor sit amet, ...
skillz21's user avatar
  • 176
1 vote
0 answers
98 views

Format C functions with return type and function attributes on separate lines

I'm currently using vscode clang-format with a .clang-format config file of my own. I already succeeded to automatically have return type on a different line with the parameter : ...
lordeji's user avatar
  • 105
0 votes
1 answer
101 views

Can clang-format arrange each function entirely on one line?

I'd like to format a set of C++ files so that each function or function template is defined entirely on one line. With input such as: template <typename T> void foo(int i) { return; } ...
user2023370's user avatar
  • 10.9k
1 vote
1 answer
45 views

clang-format: how to wrap braces only for empty body of functions/if/for/while/etc

I want to wrap braces only for empty body of functions and control statements. For instance, I want: if (true) { // not empty } void func() { // no empty } but if (true) // empty {} void func(...
Nkamil's user avatar
  • 52
0 votes
0 answers
59 views

Alignment after opening parenthesis of function call

I'm using clang-format for my C++ codebase Here's the current set-up: # .clang-format BasedOnStyle: Chromium IndentWidth: 4 --- Language: Cpp ColumnLimit: 79 AccessModifierOffset: -4 SortIncludes: ...
Inigo Selwood's user avatar
1 vote
1 answer
86 views

how to clang-format long array of strings, to have strings in multiple columns

Below is the clang-format of ".h" header file with variable size of strings. string a[x] = { "masfasdno", "iasdst", "xafdsfayz", "pqssssr&...
thirdeye's user avatar
  • 302
2 votes
1 answer
135 views

How can I get clang-format to keep 3 statements in a switch/case in one line?

This code case 0xfc: printf("CM $%02x%02x",code[2],code[1]); opbytes = 3; break; case 0xfd: printf("CALL $%02x%02x",code[2],code[1]); opbytes = 3; break; case 0xfe: printf(&...
Caner - sagopanin sag kolu's user avatar
0 votes
0 answers
26 views

Force closing parenthesis to new line for multiline condition

I understand, that setting the option AlignAfterOpenBracket to BlockIndent will put 'the closing parenthesis' on a new line for function calls, where the collection of arguments does not fit in one ...
Refugnic Eternium's user avatar
0 votes
0 answers
52 views

Does .editorconfig have any property that organize includes in c++?

I would like to organize my include statements in order and in blocks, similar to the .clangd configuration. I need to know if the .clangd or eclipse configuration are the only options to organize my ...
matssauro's user avatar
0 votes
0 answers
13 views

clang-format indent variables between PPD

Anyone who knows to get clang-format handle this: #ifdef SOMEPREDEF uint32_t int1 = 333; uint32_t int2 = 444; #else uint32_t int1 = 222; uint32_t int2 = 555; #endif instead of this: #...
ED8500's user avatar
  • 51
1 vote
0 answers
54 views

Clang - Allman not adding a line break

I have this C code and I'm using Clang in Visual Studio Code to auto-format when I save the file. I would like to add line breaks after my statements as seen below. I have included both C examples of ...
t0rxe's user avatar
  • 115
0 votes
1 answer
52 views

How to prevent Google style clang formatter from ordering 'using typename' alphabetically?

My project is using a clang-format based on 'Google Style' and I would like to disable the feature that sorts using typename ... alphabetically when several are added back to back . Is there any way ...
titocazou's user avatar
0 votes
0 answers
70 views

Using clang-format over tramp

I have clang installed in a docker container which I'm able to interact with in emacs through tramp. The motivation is to replicate a dev-container like environment in emacs. As much as possible, at ...
Sav's user avatar
  • 73
0 votes
0 answers
45 views

__published not recognized as access modifier in clang-format-12 linux version

I have a C++Builder project. In this project, I need to verify code formatting using clang-format-12. When I run format on save in Windows part (clang-format version 12.0.1 (git@ngnu:llvm-project ...
Tom Penard's user avatar
1 vote
1 answer
87 views

How to Align Preprocessor Directives (#) with Code Blocks Using clang-format?

I am using clang-format to format my C++ code. However, I want to align preprocessor directives (including the # sign) with the surrounding code blocks. Currently, clang-format aligns the directives ...
Mahdi Ghasemi's user avatar
1 vote
1 answer
63 views

prevent new line after macros usage for clang-format c++

imagine that we have macros for formatted log construction, for example: LOG(log_level)("key1", "value1")("key2", "value2")...; in this case we will have in ...
Ivan Morozov's user avatar
8 votes
1 answer
2k views

How to use clangd as formatter in neovim?

I am using nvim with lazy and using mason, mason-lspconfig, nvim-lspconfig as follow return { { "williamboman/mason.nvim", config = function() ...
Nguyễn Nhân's user avatar
0 votes
1 answer
63 views

Put function parameters as normally idented block with clang-format

I have C++ code, and I want format it by Goole style with two differences: Code ident: 4 spaces Column limit: 80 Function parameters: normally idented block Function arguments: normally idented block ...
Olga Pshenichnikova's user avatar
0 votes
0 answers
28 views

In clang-format, is there any way to add line break before brace in array initialization?

I would like Allman style and break before brace; int array[3] = { 0, 1, 2, }; but it will always like this: int array[3] = { 0, 1, 2, }; Also there is no such option in ...
Tsutsugogo Tsutsugogo's user avatar
-1 votes
1 answer
73 views

Clang-format splitting method calls and statements on multiple lines

I am using clang-format version 18 on windows. In most cases, we would like all the arguments in method calls to be on the same line, but in complex cases, we want them on separate lines and aligned. ...
user3407352's user avatar
0 votes
0 answers
19 views

Is there a way to have clang-format align short function bodies?

I'd like to have clang format align consecutive short functions, aligning various parts of those functions. Is this possible? I have this: DataType GetDataType( ) const { return ...
Bruce's user avatar
  • 11
3 votes
0 answers
39 views

Restore default behavior change in clang-format 18 for space after function before bracket

In clang-format 17 with an empty config file, clang-format would remove any space after a function before the bracket on a single line. ` #ifndef LIBRARY_CSVLOG_HPP #define LIBRARY_CSVLOG_HPP class ...
Matthew McGurn's user avatar
0 votes
0 answers
38 views

Prevent clang-format breaking on << operator

I am trying to create a .clang-format file using this website: https://clang-format-configurator.site/ (version set to 17.0.6) but in this code snippet, the std::cout gets formatted onto the next line ...
Arch_Bacon's user avatar
0 votes
0 answers
39 views

I'm using clang-format 17.6 and I want to ignore the change in function arguments and parameters if it's on one or more lines

Is there a way to ignorer arguments and parameters of functin if it in one line or multy line. EX: uint8_t BufferPutUint8(OUT uint8_t* puBuffOut, IN uint8_t uVal); I don't want to change the uint8_t ...
monder's user avatar
  • 1
0 votes
0 answers
26 views

How to add tab automatically to std::map initial list with .clang-foramt

I hope std::map<MyEnum, std::string> imageEditArgsTypeJsonMap = { {MyEnum::Key, "Value"}, {MyEnum::ShortKey, "ShortValue"}, {...
Robin L's user avatar
  • 135
1 vote
1 answer
39 views

Clang-format putting in excessive tabs

I'm attempting to use clang-format (specifically the git clang-format integration) to format a commit of mine. When doing so, in multiple locations the clang-format'd output has a ridiculous amount of ...
Urethane8206's user avatar
0 votes
0 answers
16 views

How to prevent Clang-format to not break line for double quotes?

How to prevent Clang-format break line? sprintf(body, "<html><title>Tiny Error</title><body bgcolor=" "ffffff" ">\r\...
user24472154's user avatar
0 votes
0 answers
16 views

clang-format: make function name and first parameter atomic

Is there a way to make it so that the first parameter of a function will never be put on a new line? For example: ret = function( param1, &(struct thing){ .member1 = 12; ...
user24411811's user avatar
0 votes
1 answer
667 views

In clang-format how can i ensure that there is a line break after a template declaration

As written in the clang-format documentation I set the BreakTemplateDeclarations Option to "Yes", but when format my Code it still gets put on the same line. e.g. template<typename type&...
DavVader's user avatar
0 votes
0 answers
59 views

Clang format option for an `if-else if-...-else` with blocks

I have this code, which I would like to keep as it is: if (type.empty()) { os << "!EMPTY"; } else if (type->as_qubit()) { os << types::qubit_type_name; } else { os ...
rturrado's user avatar
  • 7,974
1 vote
0 answers
86 views

How to make clang-format break before lambda body but not before lambda

I am having problems to get the following behavior. clang-format should add a line break right before the body BUT NOT before the whole lambda when it's passed as a parameter to a function. This ...
Simon Kraemer's user avatar
3 votes
2 answers
139 views

Make clang-format put trailing comments onto newline after opening brace

We have a lot of code like the following int functionName(int arg) { // Some comment if (condition) { // Why are we here? ... } } Is there a setting to make clang format put the ...
eff's user avatar
  • 405
0 votes
0 answers
238 views

Error using Github actions with git clang-format

Whenever a pull request to main is created, I want an action to check that the code follows our format guidelines for the repo. Unfortunately im having trouble integrating this since the command keeps ...
Micnasr's user avatar
  • 31
0 votes
0 answers
37 views

How can I indent lambdas and initializer lists properly with clang-format?

lambda_indent("foo", "bar", []() { printf("baz"); }); initializer_list_indent("foo", "bar", { "baz&...
Tempus's user avatar
  • 27
1 vote
0 answers
81 views

How to make clang-format put braces on the same line as function body?

Is it possible to configure clang-format so that it puts braces on the same line as function body, provided it fits within the column width. To put it into code: // Provided this exceeds the column ...
lobelk's user avatar
  • 23
0 votes
1 answer
129 views

About .clang-format config: IncludeCategories

I use .clang-format in my project to configure my coding style. Among them, I configured my header file collation using IncludeCategories. The specific configuration rules are as follows: ...
magicianlib's user avatar
0 votes
0 answers
140 views

clang-format incorrect formatting of proto files

Using clang-format 17 with the following .clang-format file: # other languages ... --- Language: "Proto" BasedOnStyle: Google UseTab: Never TabWidth: 4 LineEnding: LF InsertNewlineAtEOF: ...
Alex O's user avatar
  • 1,639
1 vote
0 answers
80 views

How can align if statement in cpp with clang?

I would like to align the following lines if (_a) { return; } if (__b) { return; } if (____c) { return; } with clang-format. Desired Result: if (_a) { return; } if (__b) { return; } if (____c) ...
Angelo D'Amante's user avatar
-1 votes
1 answer
93 views

How to Fix Casing of Visual Studio Code clang-format Command-Line

Previously, Visual Studio Code was correctly applying formatting on save as specified in a .clang-format file. However, recently (sometime in the last month or so) this broke on a case-sensitive file ...
Jeff G's user avatar
  • 4,634
0 votes
0 answers
51 views

How to avoid `.clang-format` content duplication across multiple repositories?

We're using clang-format in a git repository and we'd like to have one central .clang-format file that we maintain for all of our C/C++/proto code. We use submodules to share a "common" ...
Charles Nicholson's user avatar
-1 votes
1 answer
87 views

How do I make clang to ignore the indentations during formatting?

I have clang-format properly installed on my device. The Problem is whenever I format in my editor, I always get this: int main() { printf("Hello world!"); for (int i = 0; i < 5; i++...
2leizy's user avatar
  • 3
0 votes
0 answers
37 views

how to tell clang-format not put ';' to new line?

My C code like this: while(true); for(int i=100;i--;); if i use clang-format, it will be replace like this: while(true) ; for(int i=100;i--;) ; I just try this, but it do not work: ...
Antecer's user avatar
0 votes
0 answers
59 views

Align consecutive declarations only if they are of the same kind

Consider this C code snippet: typedef unsigned char BOOL; typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; int main() { return 0; } Using clang-format, ...
ultrapoci's user avatar
  • 315
1 vote
0 answers
93 views

How to make clang-format add space after asterisk when formatting block comments

We have clang-format set up to break up block comments in C-code when they exceed the maximum line length. For example, /* This comment is longer than the allowed * line length. */ becomes /* This ...
Eph's user avatar
  • 267

1
2 3 4 5
18