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.

1539 questions
9843
votes
29 answers

What is the "-->" operator in 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() { …
GManNickG
  • 483,438
  • 51
  • 484
  • 539
2522
votes
43 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
  • 30,523
  • 10
  • 46
  • 67
1983
votes
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…
happyhardik
  • 24,235
  • 6
  • 45
  • 59
988
votes
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
  • 62,623
  • 6
  • 18
  • 24
871
votes
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,077
  • 15
  • 62
  • 102
619
votes
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 ;)
Thanks
  • 39,797
  • 71
  • 205
  • 320
521
votes
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
  • 32,260
  • 14
  • 72
  • 104
483
votes
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…
Zombies
  • 24,261
  • 41
  • 138
  • 223
443
votes
13 answers

How to auto-format code in Eclipse?

How do you auto-format code in Eclipse?
HasanAboShally
  • 18,249
  • 7
  • 29
  • 34
437
votes
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,925
  • 8
  • 24
  • 11
436
votes
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,300
  • 3
  • 26
  • 35
414
votes
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?
Anders
  • 9,918
  • 7
  • 29
  • 36
399
votes
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
  • 32,260
  • 14
  • 72
  • 104
364
votes
12 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
  • 11,858
  • 3
  • 18
  • 18
348
votes
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
  • 89,077
  • 144
  • 324
  • 466
1
2 3
99 100