Questions tagged [code-formatting]

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

Formatting code, such as introducing spaces or tabs, is a fundamental rule of good programming.

In this way, it's possible to improve the legibility of source code, following the logical structure of the program, in order to separate the instructions more clearly.

Modern text editors or IDEs, such as Eclipse or NetBeans, perform functions of automatic code formatting.

Other info on Wikipedia:

1604 questions
28 answers

What is the '-->' operator in C/C++?

After reading Hidden Features and Dark Corners of C++/STL on comp.lang.c++.moderated, I was completely surprised that the following snippet compiled and worked in both Visual Studio 2008 and G++ 4.4. I would assume this is also valid C since it…
  • 494,350
  • 52
  • 494
  • 543
44 answers

How do you display code snippets in MS Word preserving format and syntax highlighting?

Does anyone know a way to display code in Microsoft Word documents that preserves coloring and formatting? Preferably, the method would also be unobtrusive and easy to update. I have tried to include code as regular text which looks awful and gets…
Lawrence Barsanti
  • 31,929
  • 10
  • 46
  • 68
21 answers

How do I format XML in Notepad++?

I have Notepad++ and I got some XML code which is very long. When I pasted it in Notepad++ there was a long line of code (difficult to read and work with). I want to know if there is a simple way to make the text readable (by readable I mean…
  • 24,987
  • 7
  • 47
  • 60
29 answers

How do you format code in Visual Studio Code (VSCode)?

What is the equivalent of Ctrl + K + F and Ctrl + K + D on Windows in Visual Studio for formatting, or "beautifying" code in the Visual Studio Code editor?
Brandon Clapp
  • 66,931
  • 6
  • 20
  • 24
24 answers

Code formatting shortcuts in Android Studio for Operation Systems

I have started developing with Android Studio. In Eclipse I was using Ctrl + Shift + F, but in Android Studio it does not work. It will be different. How can I jump to any method in a .java file? I was using Ctrl + O in Eclipse. Is it available?…
Bhavesh Hirpara
  • 22,255
  • 15
  • 63
  • 104
21 answers

How can I indent multiple lines in Xcode?

When I select multiple lines of code and want to indent them as usual with TAB key, it just deletes them all. I come from Eclipse where I always did it that way. How's that done in Xcode? I hope not line by line ;)
  • 40,109
  • 71
  • 208
  • 322
14 answers

How to turn off the Eclipse code formatter for certain sections of Java code?

I've got some Java code with SQL statements written as Java strings (please no OR/M flamewars, the embedded SQL is what it is - not my decision). I've broken the SQL statements semantically into several concatenated strings over several lines of…
Greg Mattes
  • 33,090
  • 15
  • 73
  • 105
17 answers

Ruby: Can I write multi-line string with no concatenation?

Is there a way to make this look a little better? conn.exec 'select attr1, attr2, attr3, attr4, attr5, attr6, attr7 ' + 'from table1, table2, table3, etc, etc, etc, etc, etc, ' + 'where etc etc etc etc etc etc etc etc etc etc etc…
  • 25,039
  • 43
  • 140
  • 225
1 answer

How can I beautify JSON programmatically?

Do you know of any "JSON Beautifier" for JavaScript? From {"name":"Steve","surname":"Jobs","company":"Apple"} To { "name" : "Steve", "surname" : "Jobs", "company" : "Apple" } Example some_magic(jsonObj); // return beautified JSON
Randy Mayer
  • 8,455
  • 8
  • 25
  • 11
13 answers

How to auto-format code in Eclipse?

How do you auto-format code in Eclipse?
  • 18,459
  • 7
  • 30
  • 34
17 answers

Tool to Unminify / Decompress JavaScript

Are there any command line scripts and/or online tools that can reverse the effects of minification similar to how Tidy can clean up horrific HTML? (I'm specifically looking to unminify a minified JavaScript file, so variable renaming might still be…
Andy Ford
  • 8,410
  • 3
  • 26
  • 36
5 answers

How to disable code formatting for some part of the code using comments?

I'd like to selectively disable the IntelliJ IDEA code formatter for a portion of code just like I can in Eclipse. Does IntelliJ support this feature, and if so, how do I use it?
Greg Mattes
  • 33,090
  • 15
  • 73
  • 105
13 answers

How do you format code on save in VS Code

I would like to automatically format TypeScript code using the build-in formatter when I save a file in Visual Studio Code. I'm aware of the following options, but none of them is good enough: Format manually Shift + Alt + F Format on type…
Tomas Nikodym
  • 13,210
  • 3
  • 19
  • 18
13 answers

How to auto-indent code in the Atom editor?

How do you auto-indent your code in the Atom editor? In other editors you can usually select some code and auto-indent it. Is there a keyboard shortcut as well?
  • 9,988
  • 7
  • 30
  • 36
4 answers

How to format code in Xcode?

I wonder how can I format my code to align it neatly? Does it have a feature similar to Eclipse's ctrlshiftf?
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
2 3
99 100