Questions tagged [code-formatting]
Code formatting is the way to format the source code of programs, such as using spaces and tabs, improving legibility.
code-formatting
1,624
questions
0
votes
2
answers
115
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))
...
-1
votes
1
answer
88
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
87
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
511
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 ...
0
votes
0
answers
80
views
Managing JupyterLab extensions with different Conda environments
I've been trying to install a code formatter into Jupyter lab. I'm unsure how to manage such extensions with multiple conda environments.
I have JupyterLab installed on my base conda environment and ...
1
vote
1
answer
114
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
119
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 ...
0
votes
0
answers
66
views
Ctrl k+D not working on last microsft vs update
After last update of Microsoft VS ctrl K+D for format code not working for razor page although it format cs page
I tried to format form Edit-Advanced-format document but the code didn't format
Then i ...
-1
votes
1
answer
37
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 = () =&...
2
votes
2
answers
78
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 ...
0
votes
0
answers
118
views
Why does my code give a segfault whilst I haven't used raw pointers combined with the new keyword?
I've been working on my own little project for the last few days, and, still being a beginner, I figured it would be a good idea to make a chess game. I've already made some other simple programmes in ...
0
votes
1
answer
531
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
0
answers
42
views
How to re-format HTML (in vscode) to remove unnecessary line breaks after every tag
I know that most code formatters have config to prevent breaking on <b>, <i> etc tags, but I cannot figure out what to do if the disaster already happened and I want to go back from 1000 ...
0
votes
2
answers
80
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
83
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 ...