Questions tagged [code-formatting]

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

Formatting the code, such as introducing spaces or tabs, is an important and fundamental rule of good programming.

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

Modern text editors or IDE, such as Eclipse or NetBeans, perform functions of automatic code formatting, to help programmers about code developing.

Other info on Wikipedia.

1504 questions
29 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. Here's the code: #include int main() { …
  • 474,637
  • 51
  • 473
  • 538
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
  • 29,373
  • 10
  • 45
  • 66
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…
  • 23,585
  • 6
  • 44
  • 59
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
  • 59,933
  • 6
  • 18
  • 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
  • 21,946
  • 13
  • 62
  • 102
20 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 ;)
  • 39,479
  • 70
  • 204
  • 315
13 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
  • 31,492
  • 14
  • 67
  • 104
16 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…
  • 23,601
  • 40
  • 137
  • 218
13 answers

How to auto-format code in Eclipse?

How do you auto-format code in Eclipse?
  • 17,989
  • 7
  • 28
  • 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,279
  • 3
  • 25
  • 35
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,758
  • 7
  • 28
  • 35
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
  • 7,497
  • 8
  • 23
  • 11
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
  • 31,492
  • 14
  • 67
  • 104
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
  • 86,319
  • 138
  • 320
  • 459
8 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
  • 10,840
  • 3
  • 17
  • 18
2 3
99 100