Skip to main content

Questions tagged [code-formatting]

Code formatting is the way to format the source code of programs, such as using spaces and tabs, improving legibility.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
16 views

Intellij "Reformat Code" behaves differently for a specific line of Java code depending on extent of the selection

The symptom: If I select a few lines piece of code with two calls of a fluent interface and run "Code -> Reformat Code" I get ... .toFileTarget( List.of(stuff), ... 1 long ...
Harald's user avatar
  • 5,001
0 votes
0 answers
24 views

Want to add API response to eclipse code editor temporarily and once click outside temporarily portion Api response should disappear

I am using the below code to write Api response in eclipse code editor. StyleText textWiget =(StyleText) textEditor.getAdapter(Control.class); textWiget.replaceTextRange(insertOffset, 0, apiResponse); ...
Raj Kumar's user avatar
0 votes
1 answer
30 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, ...
Alex Env's user avatar
0 votes
0 answers
38 views

VS Code : force horizontal alignment of parentheses, braces and square brackets

Is there any way to auto format code (in VS Code) in a way that forces horizontal alignment of parentheses, braces and square brackets? For example: let foo = { a: 'a', b: 'b', c: 'c' }; ...
Marc F's user avatar
  • 73
0 votes
0 answers
35 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 ...
Simon's user avatar
  • 1,376
0 votes
0 answers
13 views

Enforcing Consistent Code Formatting for HTML and Typescript (VS Code & WebStorm)

I'm in a team working on Angular projects and using Prettier for code formatting (HTML, TypeScript, SCSS). We're encountering merge conflicts due to inconsistent Prettier formatting across team ...
jessiepinkman's user avatar
0 votes
0 answers
29 views

Formatting issues with PhpStorm for React/RN

I'm having issues with my PhpStorm settings where it's wrapping on save. I'm not seeing any setting that would allow me to prevent this. I've confirmed it's not Prettier or ESLint causing the issue. ...
Pwntastic's user avatar
  • 451
2 votes
0 answers
24 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 ...
kenneyher's user avatar
0 votes
1 answer
141 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 ...
Sophie cai's user avatar
4 votes
2 answers
186 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]; ...
Cristi's user avatar
  • 1,281
2 votes
2 answers
380 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 ...
Ellie Su's user avatar
0 votes
0 answers
27 views

Why Intelij inserts space after final parameter in annotations when using Reformat Code

Why does Intelij randomly decided to insert space after final parameter in every annotation. How it was until now: @GetMapping("/something") @Tag(name = "Something", description = &...
Łukasz Mączka's user avatar
1 vote
0 answers
36 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 ...
Lord_Shiva_Mahadev's user avatar
0 votes
1 answer
118 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 ...
DONGNYEONG's user avatar
0 votes
2 answers
112 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)) ...
Matias Bonoli's user avatar
-1 votes
1 answer
79 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 ...
MrGod1y's user avatar
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('@')) { ...
niko craft's user avatar
  • 2,967
1 vote
1 answer
478 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 ...
Andras Vanyolos's user avatar
0 votes
0 answers
74 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 ...
oweydd's user avatar
  • 111
1 vote
1 answer
108 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: ....
User45i6h45ih3455's user avatar
4 votes
0 answers
112 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 ...
chrysante's user avatar
  • 2,635
0 votes
0 answers
64 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 ...
Sabah's user avatar
  • 11
-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 = () =&...
kaan_atakan's user avatar
  • 3,865
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 ...
user21524036's user avatar
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 ...
JoligeJ's user avatar
  • 47
0 votes
1 answer
490 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 ...
Gabe Mata's user avatar
0 votes
0 answers
41 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 ...
alparius's user avatar
0 votes
2 answers
78 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 ...
TEsco's user avatar
  • 3
1 vote
2 answers
81 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 ...
Mikhail Yevchenko's user avatar
-1 votes
2 answers
165 views

VS Code code formatting for TypeScript and JavaScript [duplicate]

I'm looking for extensions or JSON settings to format my code given below: if(true) { } else { } and not like below: if(true){ } else { }
Mohammed Sufian's user avatar
0 votes
0 answers
36 views

Color code font to 1) function arguments and 2) iterators in loops

I would like function arguments and iterators in loops to have a different color than the rest of the code. I am currently using the 'Merbivore Soft' theme, and in the code below... fn <- function(...
EmilA's user avatar
  • 165
3 votes
0 answers
142 views

CLion Nova code formatting: new scope on the same line as previous scope

When i format c++ code in clion it puts new scope { at the same line as the previous } of an if statement for example. what i want: if (...) { ... } { // Some Code } what it does: if (...) { ... } { ...
Erik15's user avatar
  • 31
1 vote
1 answer
53 views

certain VBA keywords (Add, Format) can't capitalize properly in VBE (As if I declared it as variable)

I was writing my code as usual, until suddenly I realized that certain keywords (so far, it is add and format) that won't capitalize properly after entering the line, as if it was set as variable name,...
Quarky's user avatar
  • 13
0 votes
0 answers
144 views

How can I make VS Code format C/C++ function return types on their own line?

I'm on macOS. GNU C++ in Visual Studio Code automatically format like int main () { ... } Instead I want to do : int main() { ... } Follows my current settings: "[cpp]": { "...
Juan J's user avatar
  • 37
4 votes
0 answers
416 views

Project-wide formatting options for `dart format`

I want to use dart format to format dart code, but my team uses custom format rules – such as line length of 120 characters and a few other things. Currently, code is formatted using settings in the ...
Your Friend Ken's user avatar
2 votes
1 answer
523 views

How to allow 2-line if statements using clang-format

I am working on setting up a style format check for a large library. Currently, our team styleguide prefers that instead of one line if statements, we use a "2 line" statement, which looks ...
Ska's user avatar
  • 29
1 vote
1 answer
151 views

How do I stop ReSharper/Rider from doing this: "}, {"

How do I prevent rider from generating }, { between chopped elements of an initialization? I looked through Editor --> Code Style --> Braces Layout/Line Breaks and Wrapping, but I may have ...
Charles Burns's user avatar
0 votes
0 answers
30 views

Pycharm - JSX, How to surround style classes, id's in whole file with curly braces '{}'?

I am using Pycharm and i am curious, how to surround style classes in a file with curly braces - {}. So, I am trying to learn some React, and yesterday i did it, but i do not remember how i did it, ...
radek155's user avatar
0 votes
1 answer
213 views

How to add custom separator between functions using clang format?

I have a C and C++ code base which I format using clang format. I'd like to make my code easy to read by placing separators between functions in the following way: //-----------------------------------...
locke14's user avatar
  • 1,365
0 votes
0 answers
588 views

how to setup a jsconfig.json for node.js

So I started to learning Node.js recently so far the gatherings all are good but I came across the concept of setup with jsconfig.json which largely helps to free the clutters made in mentioning the ...
changembidar's user avatar
-1 votes
1 answer
49 views

No proper formatting in React App.js in VS Code

Working on React got this improper formatting of code import logo from './logo.svg'; import './App.css'; function App() { return ( <div className="App"> <header ...
Tushar Batra's user avatar
0 votes
1 answer
183 views

How to make clang-format not break after = signs and not BinPackArguments

I'm using clang-format with a small configuration file, based on the Microsoft style. --- BasedOnStyle: Microsoft BinPackParameters: 'false' BinPackArguments: 'false' ColumnLimit: '120' #Other options....
Bob from IT's user avatar
0 votes
1 answer
55 views

How to reverse the effect of code style "Chop down if long"?

I have a big multi-dimensions array like this (the ouput of a PhpUnit provider) : return [ 'my first test case' => [ $variable1, $variable2, $variable3, $...
Thibault Witzig's user avatar
0 votes
0 answers
32 views

Squiggly AND double line to highlight errors/warnings in Visual Studio Code

After using the Extensions Bisect feature of VSCode (which is a pretty handy tool imo), I figured out that the extension causing the ugly squiggly AND double line to highlight errors/warnings (shown ...
john_jay's user avatar
0 votes
1 answer
29 views

Intellij - how to force split on operator rather than on max size

How to tell intellij to split lines like Eclipse does: private static final boolean VERY_VERBOSE = !(System.getProperty( "veryverbose" ) == null || System.getProperty( "...
DDS's user avatar
  • 2,443
1 vote
1 answer
133 views

Rider - place curly bracket with offset based on the begining of the parent level, not the parent declaration

I use JetBrains Rider 2022.2.3 Build #RD-222.4167.23, built on September 9, 2022 I want curly braces to be positioned based on the beginning of the level, not the declaration. For example, I want var ...
Mykola's user avatar
  • 216
0 votes
0 answers
54 views

jupyterlab_code_formatter: multi-line list in code, specify items/characters per line?

jupyterlab_code_formatter installed for Jupyter lab Black, isort, YAPF, Autopep8 added for jupyterlab_code_formatter Question: which config should I twist if I want the auto-formatted list to not be ...
shaoooo's user avatar
0 votes
1 answer
63 views

Intellij IDEA Java code formatting: can I force a newline after public and before a method return type?

I would like my java method declarations to look like: static public boolean method1(int arg1) { ... } where there is a newline after public and before boolean. Is there a way to do that in IntelliJ ...
Doug's user avatar
  • 704
0 votes
1 answer
250 views

Rider/ReSharper - Wrap chained method calls before first method

I have set Line Brakes and Wrapping -> Arrangement of Members Access Expression -> Wrap chained method calls to Chop always Rider is formatting chained method calls this was: var numbers = ...
Padge's user avatar
  • 3
1 vote
1 answer
335 views

May I vertically-align YAML values?

YAML code can get difficult to read and maintain, so like in other languages, I'd like to vertically-align "scalars". For example, instead of this: breakfast: spam: 1 hamHamHamHam: 2 ...
lonix's user avatar
  • 17.7k

1
2 3 4 5
33