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

Since version 13 it’s possible to wrap the code with // @formatter:off … // @formatter:on IntelliJ IDEA v.2018+: File > Settings > Editor > Code Style IntelliJ IDEA v.2016+: Preferences > Editor > Code Style IntelliJ IDEA v.14+: Preferences > Editor > Code Style > Formatter Control You can change the formatter control markers, as … Read more

How to auto-indent code in the Atom editor?

I found the option in the menu, under Edit > Lines > Auto Indent. It doesn’t seem to have a default keymap bound. You could try to add a key mapping (Atom > Open Your Keymap [on Windows: File > Settings > Keybindings > “your keymap file”]) like this one: ‘atom-text-editor’: ‘cmd-alt-l’: ‘editor:auto-indent’ It worked … Read more

How can I beautify JSON programmatically? [duplicate]

Programmatic formatting solution: The JSON.stringify method supported by many modern browsers (including IE8) can output a beautified JSON string: JSON.stringify(jsObj, null, “\t”); // stringify with tabs inserted at each level JSON.stringify(jsObj, null, 4); // stringify with 4 spaces at each level Demo: http://jsfiddle.net/AndyE/HZPVL/ This method is also included with json2.js, for supporting older browsers. Manual … Read more

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

There are pieces to this answer that helped me get what I needed (easy multi-line concatenation WITHOUT extra whitespace), but since none of the actual answers had it, I’m compiling them here: str=”this is a multi-line string”\ ‘ using implicit concatenation’\ ‘ to prevent spare \n\’s’ => “this is a multi-line string using implicit concatenation … Read more

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

Eclipse 3.6 allows you to turn off formatting by placing a special comment, like // @formatter:off … // @formatter:on The on/off features have to be turned “on” in Eclipse preferences: Java > Code Style > Formatter. Click on Edit, Off/On Tags, enable Enable Off/On tags. It’s also possible to change the magic strings in the … Read more