1,665 questions
4
votes
1
answer
142
views
How to configure .clang-format to indent access modifiers in a class definition?
I want my C++ class definitions to have access modifiers indented like below:
class Foo
{
public:
Foo(Bar bar);
Foo(Bar *bar);
};
Foo::Foo(Bar bar)
{
if ()
{
while ()
{
}
}...
-1
votes
1
answer
125
views
How do I configure the VS Code C_Cpp extension's auto insertion of linebreaks before braces?
VS Code is auto inserting linebreaks before my curly braces. I have always used K&R style braces, and would like to use that style for C++ inside of VS Code. Does anyone know how I can configure ...
2
votes
1
answer
119
views
How can I get CLion not to indent the case lines within a switch statement?
I'm using CLion to work on some C++ project. When I write case statements, CLion always indents my case lines, like so:
switch(foo) {
case bar_1:
do_stuff(); break;
case bar_2:
...
0
votes
0
answers
68
views
How to make "align wrapped arguments" a default formatting behavior in Visual Studio 2022
I want this kind of long parameters list to wrap automatically on saving or running formatter ctrl + k + d.
And not the wrapping from Options => Text Editor => C# => General
Not this:
I know ...
1
vote
0
answers
150
views
.editorconfig Support in Windsurf IDE for C# Formatting
I've been trying to get automatic code formatting working with my .editorconfig settings in Windsurf IDE for my C# codebase.
I tried the Prettier extension, but found it doesn't support C#. I also ...
2
votes
1
answer
160
views
How to use Prettier as beautifier of user's code? [closed]
In my project Prettier is already connected for the project code formatting. I'm trying to use Prettier for user's code formatting in Ace Editor:
import * as prettier from 'prettier';
import * as ...
1
vote
1
answer
157
views
How to break construct into multiple lines?
I'm new to COBOL, and I'd like to understand continuation if a line is too long. I know that there is a free form, but originally (in strict mode), the line length is limited.
I'd like to split the ...
1
vote
0
answers
57
views
clang-format causing unnecessary line breaks after disallowing single line lambda
Code:
auto transs = transitions | stdv::filter([alph](const auto trns) { return trns.first == alph; })
| stdv::values | stdv::transform([](auto x) { return x; }) | stdv::as_rvalue;
...
0
votes
0
answers
49
views
How to control formatting of attributes with explicit expressions in Razor components using Rider with editor config setup
I can't for the life of me figure out how to do this, if possible.
When using explicit expressions as values for EventHandlers or actions on components, is there a way to define how you want them ...
0
votes
0
answers
32
views
editorConfig file not considered by Visual Studio 2022 / C++
I code in C++ in Visual Studio 2022.
My sources and solution/project files are in two different directories. Neither is included in the other. They're strictly separated.
I put and .editorconfig file ...
1
vote
2
answers
242
views
How to easily and quickly apply custom indentation format rule to selected Pascal/Delphi code?
I am working with Pascal/Delphi code and need to format a selection of code with custom indentation rules (e.g. 4 spaces for indentation). I want to apply these formatting rules to the selected code ...
-1
votes
1
answer
131
views
How to revert auto formatting changed lines and save the file
Actions on save -> checked,
Reformat changed lines -> checked
Optimize imports -> checked.
This works excellently most of the time, but sometimes I want my own formatting to remain.
I seem ...
0
votes
2
answers
932
views
VSCode adds unwanted extra spaces on enter
I am using VSCode since a couple years and have recently changed computers.
After installing VSCode, I came upon this issue:
lets say I have a list like this:
int_list = [
1, 2, 3, 4,
]
and now I ...
0
votes
0
answers
55
views
How to prevent Vue extension from "fixing" my code?
I'm experiencing an issue where "unreachable code" in a Vue/TypeScript file is automatically deleted on save. (A pretty shocking behaviour, often I'm temporarily adding a "return false&...
2
votes
0
answers
45
views
Eclipse indenting of nested HTML tags in Javadoc comments
Suppose I have Javadoc comment with:
/**
* <ul>
* <li>stuff</li>
* <li>stuff</li>
* </ul>
*/
When I run any of the eclipse formatting methods on ...
1
vote
1
answer
997
views
Why won't my C# code format correctly in Visual Studio 2022?
Even when I use the shortcut Ctrl+K Ctrl+D (Or Edit>Advanced>Format Document) in VS 2022, this C# code won't format properly:
Why won't the Visual Studio 2022 formatter fix these issues? How ...
7
votes
2
answers
275
views
How to prevent Delphi from formatting a code block?
I would like to be able to keep Delphi from formatting a specific block of text because it is much easier to read when formatted in a specific way, but pressing Ctrl+D will make it much harder to read....
2
votes
0
answers
79
views
Is it possible to achieve JetBrains-like type alignment with SQLFluff?
I’m using SQLFluff for formatting SQL files and trying to replicate the behavior of JetBrains IDEs where types are perfectly aligned under each other, and constraints (e.g., NOT NULL) dynamically ...
0
votes
1
answer
120
views
SQL formatting in DataGrip
I use DataGrip 2022.2.1. When I use code formatting AND condition in new line set before JOIN
select pfv.value
from pay.PaymentFields pf
inner join pay.PaymentFieldValues pfv on pfv.id = ...
0
votes
1
answer
61
views
Broken BraceWrapping in clang-format in presence of an empty macro
I have the following code
enum MyFlag SOME_EMPTY_MACRO( ARG )
{
MyEnumValue = 1 << 1 //!< ...
};
In my clang-format, I have BraceWrapping.AfterEnum: true
This always get transformed to (...
0
votes
0
answers
62
views
Clang format option to "explode" function declarations
I'm looking for a Clang configuration that will convert code A into code B (see below).
My preference is to "explode" functions with 3 or more arguments for personal readability, and I haven'...
0
votes
0
answers
75
views
auto formatting using yapf to put parameters on multiple lines in condensed format
Related to this. But instead of putting all arguments on single line, I want to put them onto multiple lines in condensed form.
Basically I want to transform:
def f(arg1: typ1, arg2: typ2, ..., ...) -&...
0
votes
1
answer
17
views
How to disable irregular tab shading in VS Code
In VS Code in Python I have my autoformatter set to indent function parameters in-line if I make a line break between them, like so:
However something else is making that shading on line 84 and I can'...
0
votes
0
answers
66
views
Shortcuts for auto indentation not working
I want to use the command Reindent Selected Lines or Reindent Lines with a shortcut. I tried setting keybindings to each of them but when I press them in notebooks or scripts (using Python), nothing ...
2
votes
1
answer
135
views
How to configure clang-format to place ) and } on a new line?
I’m trying to configure clang-format to break after each function parameter and place ) and } on separate lines for (member) function declarations and calls, like this:
void draw(
const geometry::...
1
vote
1
answer
1k
views
How to auto format HTML (.cshtml) documents on save (VS2022)
I rely on clean-up profile with the "run on save" checked to ensure my code is formatted on save:
'Format code' and 'sort using' on save in Visual Studio 2022
While that ...
1
vote
0
answers
97
views
How to Prevent Prettier from Formatting C++ Macros into a Single Line?
I'm encountering an issue where Prettier automatically reformats my C++ macros into a single line, even though I've tried using the // prettier-ignore directive. Here's an example of my code:
`// ...
2
votes
1
answer
96
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, ...
-4
votes
1
answer
139
views
does spacing between statements, indentation and comments in code affects its time and space complexity? [closed]
I'm trying to understand how code formatting and documentation impacts the performance of a program
Spacing between statements: having more or fewer blank lines between code statements.
Indentation: ...
1
vote
1
answer
122
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&...
0
votes
1
answer
55
views
Visual Studio 2022 - indent closing function paren with beginning of argument
In Microsoft driver code (even the driver templates included in VS), they frequently format the function signature like this:
VOID
EvtIoStop(
_In_ WDFQUEUE Queue,
_In_ WDFREQUEST Request,
...
0
votes
0
answers
54
views
IntelliJ SQL-Formatter to indent SET after UPDATE
How can I modify the IntelliJ SQL-Formatter to insert an indent before the SET (after an UPDATE)?
Current code:
UPDATE role
SET is_available = 0
, is_updated = 1
WHERE name = 'Admin';
Desired ...
2
votes
0
answers
44
views
Pre tag with style="white-space: pre-line" removes leading spaces as desired, but how can I prevent it from losing internal spacing?
I'm having an issue with the HTML pre tag. If I do a very simple test it preserves spacing the way that I want it to. For instance, notice that there are two spaces in a row in certain parts of the ...
0
votes
1
answer
761
views
Visual Studio Code Cleanup: How to avoid removing unassgiend/unused variable when file is on save
I am using Code Cleanup in Visual Studio and noticed when file is on save.
The unused variable will be removed like:
I tried editing the .editorConfig file but it didn't seem to work with any of the ...
5
votes
2
answers
533
views
How do you set formatting rules for C# spread operator in Visual Studio?
I know this is probably not the right place to ask this, but I doubt I'd find an answer somewhere else.
Visual Studio 17.9.5 will, by default, format the following snippet as such
int[] arr = [1, 2];
...
5
votes
2
answers
3k
views
How to automating Code Formatting in VSCode for Jupyter Notebooks with Black Formatter?
I've been enjoying the convenience of the Black Formatter extension in Visual Studio Code, especially its "Format on Save" feature for Python files. Being able to automatically format my ...
1
vote
0
answers
135
views
Having space problem while using phpfmt [code formatter] with ...$variable_name
Here is my example code where i am having error while using phpfmt [code formatter].
function ( int | float...$numbers ): int | float {
return array_sum( $numbers );
};
Here as we can see in the ...
0
votes
1
answer
593
views
Is there a way to code format info.plist file like prettier?
If the info.plist file changes, the PR changes and it's very cumbersome to modify. Is there a way to modify it through github action or CI build? Or I'm looking for a way to keep it consistent through ...
0
votes
2
answers
186
views
Common Lisp formatting/indentation
(defun heapify-down (heap-id
index)
(if
(is-leaf heap-id
index)
nil
(let ((left (left-child index))
(right (right-child index))
...
0
votes
2
answers
859
views
How do I configure prettier to not separate my attributes onto new lines and not separate my opening bracket and closing bracket?
Before I state any of my problems this is my .prettierrc file so far
{
"semi": true,
"useTabs": true,
"tabWidth": 4
}
Problem 1:
I would like my prettier to ...
0
votes
1
answer
103
views
Why does if break into multiple lines?
Why does this if:
if (value == null || value.trim().isEmpty || !value.contains('@'))
breaks into multiple lines upon save?:
if (value == null ||
value.trim().isEmpty ||
!value.contains('@')) {
...
1
vote
1
answer
1k
views
Visual Studio Code - Microsoft Black Formatter from command line?
I have the Microsoft Black Formatter extension in VSCode (in WSL, inside Windows 11). I can format opened python files with no problem, one-by-one, either using keyboard shortcut or right click on the ...
2
votes
1
answer
279
views
How to prevent Xcode re-indentation from affecting block comments?
In Xcode, let's say I have an arbitrary section of code in a Swift file such as:
static func getDocumentsDirectory() -> URL {
let paths = FileManager.default.urls(for: .documentDirectory, in: ....
4
votes
0
answers
144
views
Format brace-list of lambda expressions nicely
Is there any way I can setup clang-format to nicely* format an expression like this?
foo({
[](int) {
bar();
baz();
},
[](float) {}
});
With my current config this gets ...
4
votes
0
answers
404
views
Indent non-preprocessor code between #if and #endif with clang-format
I'm currently trying to set up a .clang-format file for a project, and was wondering if there's a combination of settings to auto-indent not just preprocessor directives but also code enclosed by them....
-1
votes
1
answer
45
views
Does a code transformer / formatter exist that will add curly braces to Typescript code
I want all the code in our repository to always use blocks enclosed with brackets for the clauses of if statements, loops and even for inline functions. The following code is banned:
const func = () =&...
3
votes
2
answers
105
views
Alignment issue when printing formatted prime numbers in J language
I am a relatively new programmer in J-Lang and recently discovered its efficacy in Code Golfing, where it excels in scoring. I am currently working on a coding problem that involves printing all prime ...
1
vote
1
answer
1k
views
How to Configure Prettier/ESLint to Keep Space Between Function Name and Parentheses? VS Code
I'm using Visual Studio Code for a JavaScript project and facing a formatting challenge with Prettier, which I'm using in conjunction with ESLint. My preference is to maintain a space between the ...
0
votes
2
answers
209
views
How to put item from room into inventory
I am having issues with not being able to get any item and move it into my inventory on this text-based game, I have tried a couple of things but none of it has helped and I am genuinely stuck. I am ...
1
vote
2
answers
200
views
How to work with poorly formatted Code in VSCode without committing format changes?
I am currently working on a project in Visual Studio Code that has poorly formatted code. Due to project constraints, I am not allowed to reformat the existing code and commit those changes. This ...