Skip to main content
The 2024 Developer Survey results are live! See the results

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
371 questions with no upvoted or accepted answers
34 votes
1 answer
4k views

How can I force Xcode to retain my indentation when I copy and paste?

I find myself wasting so much time dealing with Xcodes auto indentation that I have to ask if there is something I just have wrong in my settings. Basically if I spend time indenting code within a ...
patrick's user avatar
  • 9,642
10 votes
0 answers
1k views

Force Yapf to wrap lines after expression/just before for-loop in list comprehension

yapf formatter can wrap long lines in the code inside parentheses in the expression in the list comprehension: threads = [threading.Thread( target=worker, args=[q], daemon=True) for _ in range(...
jfs's user avatar
  • 410k
9 votes
0 answers
1k views

Use of checkstyle.xml in diffplug/spotless

I have a checkstyle.xml file to check for formatting violations . Is there any way to provide checkstyle.xml as a input to diffplug/spotless formatter . Java8 is being used and spotless verison is 2....
darth_vader's user avatar
8 votes
1 answer
741 views

Is there a eslint plugin to enforce braceless one-line if statements?

I want to enforce one-line if statements not having braces. For example: // incorrect if(foo) { bar() } // correct if(foo) bar() But if I have else/else ifs, I still want to keep braces: // ...
dr1zzled_d1ce's user avatar
8 votes
0 answers
996 views

How can I reset my TextEditor > C# > Code Style settings to the default or a previous version in VS 2019?

They don't seem to be exported in vssettings etc. I don't see a way to restore them to an earlier version or even the default out-of-the-box Visual Studio settings ... Restoring all settings also ...
Hottemax's user avatar
  • 344
8 votes
0 answers
110 views

clang-formatter: Prevent new line in function declaration

In Objective-C how to prevent new lines here: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { to see this: - (NSInteger)tableView:(UITableView *)...
János's user avatar
  • 34.6k
8 votes
1 answer
514 views

Eclipse code formatter multiline function call closing bracket indention

Currently my eclipse formatter formats a multiline function call like this: someObject.doSomething( some().long().chain().of().methods() ); But what I want is for eclipse to align the closing ...
Reins's user avatar
  • 1,109
8 votes
0 answers
3k views

Automatically grouping imports in intelliJ IDEA

I want to group imports by packages in intelliJ. Right now it sorts the imports properly, and gives me this. import com.google.common.Something import com.google.common.SomethingElse import org....
yasith's user avatar
  • 9,321
6 votes
0 answers
1k views

Importing checkstyle suppressions for IntelliJ code style

Mostly just out of curiosity, but if you are using a checkstyle configuration file checkstyle.xml and a (separate) suppression file checkstyle-suppressions.xml with the maven-checkstyle-plugin on a ...
Powy's user avatar
  • 111
6 votes
1 answer
4k views

Visual Studio Code align function parameters on multiple lines

If a Javascript (or Typescript) function signature has multiple lines of arguments (can happen easily in Typescript, with longer type names), Visual Studio Code indents like this after I hit return: ...
Rob N's user avatar
  • 16k
6 votes
0 answers
2k views

Clang-format indents inner initialisers with continuation indent

I have some C++11 code with clang-format rules that uses an normal indent (IndentWidth) of 4 and continuation indent (ContinuationIndentWidth) of 8. So a long function looks something like this: // ...
diwhyyyyy's user avatar
  • 6,282
6 votes
1 answer
870 views

How to turn off the App.config file auto arrange formatting in visual studio

I want to turn off the App.config file auto arrange formatting in visual studio. Here, I tried with this link Turn off auto formatting in Visual Studio , But it's not working in App.config file. ...
Chenna Rao's user avatar
6 votes
1 answer
1k views

require a blank line between fields if annotations are on separate lines?

Basically I want different styles depending on annotation count, e.g. class Foo { @Autowire private MyService myService; @Autowire private MyOtherService service; ... } but if I have more ...
xenoterracide's user avatar
5 votes
0 answers
1k views

How to configure Prettier to format Cypress code with chained calls?

I'm using Prettier to format my Cypress code, but it's breaking lines in a way that I don't like. Specifically, it's formatting lines like this: cy.contains("div[role='alert']", "Status ...
JVMatos's user avatar
  • 69
5 votes
0 answers
366 views

How to format C++ code in Visual Studio using my own rules?

I am using Visual Studio 2019. I want to create a setting file for Visual Studio which consists of my own formatting rules and anyone can import those settings for their Visual Studio. (I think this ...
gnase's user avatar
  • 630

15 30 50 per page
1
2 3 4 5
25