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.

55 votes
6 answers
91k views

I'm getting an IndentationError (or a TabError). How do I fix it?

I have a Python script: if True: if False: print('foo') print('bar') However, when I attempt to run my script, Python raises an IndentationError: File "script.py", line 4 ...
Chris's user avatar
  • 22.7k
10169 votes
26 answers
1.0m views

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. ...
988 votes
29 answers
4.4m views

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's user avatar
531 votes
14 answers
191k views

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 ...
Greg Mattes's user avatar
  • 33.7k
483 votes
1 answer
317k views

How can I beautify JSON programmatically? [duplicate]

Do you know of any "JSON Beautifier" for JavaScript? From {"name":"Steve","surname":"Jobs","company":"Apple"} To { "name&...
Randy Mayer's user avatar
  • 8,755
12 votes
5 answers
4k views

Dangerous implications of Allman style in JavaScript

I cannot remember where, but recently I passed a comment where the user told that 1TBS is more preferred than Allman in JavaScript and said Allman has dangerous implications in JavaScript. Was it a ...
Ajax3.14's user avatar
  • 1,687
438 votes
17 answers
439k views

Tool to Unminify / Decompress JavaScript [closed]

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 ...
Andy Ford's user avatar
  • 8,460
127 votes
1 answer
322k views

Best C++ Code Formatter/Beautifier

There are lots of source code formatting tools out there. Which ones work best for C++? I'm interested in command-line tools or other things that can be automatically run when checking code in/out, ...
177 votes
18 answers
184k views

Turn off auto formatting in Visual Studio

I prefer my own style of code formatting as opposed to Visual Studio's default settings. I've turned off auto-formatting options in Tools→Options. In most cases, it works. However, after using any of ...
Maciej's user avatar
  • 10.7k
2739 votes
48 answers
2.5m views

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 ...
Lawrence Barsanti's user avatar
92 votes
9 answers
72k views

Stand-alone Java code formatter/beautifier/pretty printer? [closed]

I'm interested in learning about the available choices of high-quality, stand-alone source code formatters for Java. The formatter must be stand-alone, that is, it must support a "batch" mode that is ...
Greg Mattes's user avatar
  • 33.7k
894 votes
24 answers
701k views

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 ...
Bhavesh Hirpara's user avatar
438 votes
6 answers
150k views

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's user avatar
  • 33.7k
242 votes
6 answers
329k views

How can I break up this long line in Python? [duplicate]

How would you go about formatting a long line such as this? I'd like to get it to no more than 80 characters wide: logger.info("Skipping {0} because its thumbnail was already in our system as {1}."....
Gattster's user avatar
  • 4,721
213 votes
14 answers
55k views

Unnecessary curly braces in C++

When doing a code review for a colleague today I saw a peculiar thing. He had surrounded his new code with curly braces like this: Constructor::Constructor() { // Existing code { // New ...
iikkoo's user avatar
  • 2,856

15 30 50 per page
1
2 3 4 5
17