code-formatting

XML attributes order in Android Studio

人走茶凉 提交于 2019-11-27 09:12:10
问题 I'm facing problem with keeping proper order of XML attributes in Android Studio. As you can see below, the style attribute is between layout_* attributes, but I want it to be ordered by name (like in Eclipse). I'm using standard Intellij code formatter and the Android Studio gives users ability to set your own rules regarding XML ordering. The settings are located in Code Style -> XML -> Arrangement , but it seems not to work or I'm using it wrong. Any ideas how to order XML attributes by

How to format code in Xcode? [duplicate]

好久不见. 提交于 2019-11-27 08:59:19
问题 This question already has an answer here: Code Formatting In Xcode 10 answers I wonder how can I format my code to align it neatly? Does it have a feature similar to Eclipse's ctrl shift f ? 回答1: Select first the text you want to format and then press Ctrl + I . Use Cmd + A first if you wish to format all text in the selected file. Note : this procedure only re-indents the lines, it does not do any advanced formatting. 回答2: Key combination to format all text on open file: Cmd ⌘ A + Ctrl I 回答3

How do I modify Eclipse code formatting?

血红的双手。 提交于 2019-11-27 08:15:52
When I reformat code with Eclipse, it turns method headers like this: public void myMethod(String param) { into method headers like this: public void myMethod( String param) { When I was brought on here I'd never used Eclipse before, and I imported project settings provided by someone else. I have seen that on small new projects I've worked on Eclipse does not do this, so it must be in the settings I've imported. But I've gone through every panel I can find, as well as every hidden file I can find in the workspace, and I can't figure out what is causing this. How do I turn it off? I don't want

JSLint, else and Expected exactly one space between '}' and 'else' error

半世苍凉 提交于 2019-11-27 06:43:25
问题 Why JSLint report in code: function cos(a) { var b = 0; if (a) { b = 1; } else { b = 2; } return b; } error: Problem at line 6 character 5: Expected exactly one space between '}' and 'else'. This error can be turned off by disabling Tolerate messy white space option of JSLint. Or in other words -- why syntax: } else { is better then ... } else { ... Google also uses syntax with } else { form. But I don't understand why. Google mentioned ''implicit semicolon insertion'', but in context of

What is the proper way to format a multi-line dict in Python?

徘徊边缘 提交于 2019-11-27 06:03:24
In Python, I want to write a multi-line dict in my code. There are a couple of ways one could format it. Here are a few that I could think of: mydict = { "key1": 1, "key2": 2, "key3": 3, } mydict = { "key1": 1, "key2": 2, "key3": 3, } mydict = { "key1": 1, "key2": 2, "key3": 3, } I know that any of the above is syntactically correct, but I assume that there is one preferred indentation and line-break style for Python dicts. What is it? Note: This is not an issue of syntax. All of the above are (as far as I know) valid Python statements and are equivalent to each other. I use #3. Same for long

Is there a way to mark up code to tell ReSharper not to format it?

[亡魂溺海] 提交于 2019-11-27 05:53:39
问题 I quite often use the ReSharper "Clean Up Code" command to format my code to our coding style before checking it into source control. This works well in general, but some bits of code are better formatted manually (eg. because of the indenting rules in ReSharper, things like chained linq methods or multi-line ternary operators have a strange indent that pushes them way to the right). Is there any way to mark up parts of a file to tell ReSharper not to format that area? I'm hoping for some

How can I autoformat/indent C code in vim?

送分小仙女□ 提交于 2019-11-27 05:44:27
When I copy code from another file, the formatting is messed up, like this: fun() { for(...) { for(...) { if(...) { } } } } How can I autoformat this code in vim? Try the following keystrokes: gg=G Explanation: gg goes to the top of the file, = is a command to fix the indentation and G tells it to perform the operation to the end of the file. Derek I like to use the program Artistic Style. According to their website : Artistic Style is a source code indenter, formatter, and beautifier for the C, C++, C# and Java programming languages. It runs in Window, Linux and Mac. It will do things like

Online code beautifier and formatter [closed]

余生颓废 提交于 2019-11-27 05:43:48
What are the best online code beautifier and formatter out there? I'm not asking for highlighters. Any language will do. bluish CSS: code beautifier HTML: HTML Tidy , CleanUp HTML or the general purpose Pretty Diff Javascript: http://jsbeautifier.org/ PHP: http://beta.phpformatter.com/ SQL: http://dpriver.com/pp/sqlformat.htm XML: http://chris.photobooks.com/xml/default.htm Colour all: http://quickhighlighter.com/ For PHP, Java, C++, C, Perl, JavaScript, CSS you can try: http://www.prettyprinter.de/index.php You can use Perl::Tidy for Perl. JsonLint is good for validating and formatting JSON.

How to auto-indent code in the Atom editor?

依然范特西╮ 提交于 2019-11-27 04:58:53
问题 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? 回答1: 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 for me :)

Best source code formatter for Javascript? [closed]

落花浮王杯 提交于 2019-11-27 04:37:20
问题 I've been digging through Stack Overflow as well as a number of Google searches, and I cannot find a satisfactory code formatter for Javascript. I have found several related tools, such as syntax highlighters and pretty-printers, but I am looking for a tool that I can ideally create a wrapper for in Eclipse and simply run from the menu bar. Hence, if any Java-based ones are available, that is a big plus. Free and/or open-source is preferred as well. I am looking for something that my