code-formatting

Why might my Emacs use spaces instead of tabs?

一笑奈何 提交于 2019-11-28 12:58:15
I am trying to diagnose this problem. TAB creates 4 spaces instead of a 4 col TAB like I want. But I don't think it should because C-h v indent-tabs-mode on the buffer in question says it is set to t . When I check my keybindings, TAB is set to c-indent-line-or-region . Does this function ignore my tabs-mode? Tabs and indentation in Emacs is a considerably more complex subject than most people anticipate. I highly recommend spending some time reading about it -- it will almost certainly save you some confusion in the long run. The following page at the Emacs Wiki groups together most of the

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

社会主义新天地 提交于 2019-11-28 12:04:37
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 opening { , not closing one. Can Javascript insert semicolon after closing } of if block even if next token

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

半城伤御伤魂 提交于 2019-11-28 10:40:22
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 kind of markup similar to how ReSharper suppresses other warnings/features. If not, is there some way of

JavaScript formatting: must braces be on the same line as the if/function/etc keyword? [duplicate]

梦想的初衷 提交于 2019-11-28 08:30:15
问题 Possible Duplicate: why results varies upon placement of curly braces in javascript code We have company policies that dictate that in PHP opening curly braces should be on their own lines for readability and so that they can line-up with the closing brace; thus: if (true) { ... } but in JS they should be kept on the same line, in case there are problems with browsers incorrectly interpretting it . if (true) { ... Is the above italic part a legitimate concern? PS - I suspect that this

Code Formatting In Xcode

有些话、适合烂在心里 提交于 2019-11-28 07:25:05
Is there anyway to format the code in Xcode like you can do in Eclipse or Netbenas. I have not found any option in menu, is there any hot key for this or its simply not in Xcode? Select some text and then: Edit->Format->Re-Indent You can bind this to a hotkey in the preferences. In Xcode 4, it's been moved to Editor > Structure > Re-Indent command (and has a default shortcut of CTRL + I ). Dave DeLong Other than re-indentation (Edit > Format > Re-Indent), not really. However, Xcode does have support for scripts (the menu to the right of the Window menu), so you could conceivably write a script

How to create an Intellij and Eclipse compatible code style and code formatting configuration (for java code)?

我怕爱的太早我们不能终老 提交于 2019-11-28 07:15:01
Few weeks ago I tried Intellij and I found it really awesome. Now, at my project there are two programmers (including me) using Intellij and few other programmers who are going to keep using Eclipse. Since this project is already very large and it's going to grow a lot, we need to use compatible Code Style and Code Formatting between Intellij and Eclipse. We do not want to have problems when one user edits some file and reformats it before saving. With Eclipse "alone" we used to have some exported configuration, and before anybody starts to work, the first step is just to import this

AnkhSVN client side pre-commit hook

不问归期 提交于 2019-11-28 05:20:15
问题 Basically I want to do the same thing as the fella over there. It seems that everybody was thinking about server-side hooks (with all their evil potential). I want a client side script be run before commit so astyle can format the code the way my boss likes to see it. Since my IDE (VS2010Pro) automatically checks when a file changed on the disk an opts me in for reloading it, there is no real evil with all that. Is there any (clean) way to accomplish that with AnkhSVN? Maybe there's also a

Clang-format line breaks

房东的猫 提交于 2019-11-28 05:14:18
I'm looking for a clang-format setting to prevent the tool from removing line breaks. For example, I have my ColumnLimit set to 120, and here's what happens when I reformat some sample code. Before: #include <vector> #include <string> std::vector<std::string> get_vec() { return std::vector<std::string> { "this is a test", "some of the lines are longer", "than other, but I would like", "to keep them on separate lines" }; } int main() { auto vec = get_vec(); } After: #include <vector> #include <string> std::vector<std::string> get_vec() { return std::vector<std::string>{"this is a test", "some

How should I order the members of a C++ class?

浪尽此生 提交于 2019-11-28 03:46:50
Is it better to have all the private members, then all the protected ones, then all the public ones? Or the reverse? Or should there be multiple private, protected and public labels so that the operations can be kept separate from the constructors and so on? What issues should I take into account when making this decision? I put the public interface first, but I didn't always do this. I used to do things backwards to this, with private, then protected, then public. Looking back, it didn't make a lot of sense. As a developer of a class, you'll likely be well acquainted with its "innards" but

Tool to Unminify / Decompress JavaScript [closed]

﹥>﹥吖頭↗ 提交于 2019-11-28 01:47:11
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 an issue.) You can use this : http://jsbeautifier.org/ But it depends on the minify method you are using, this one only formats the code, it doesn't change variable names, nor uncompress base62 encoding. edit: in fact it can unpack "packed" scripts (packed with Dean Edward's packer : http://dean.edwards.name/packer/ ) Jon Adams Chrome developer