code-formatting

Indenting #defines

泄露秘密 提交于 2019-11-27 03:22:14
I know that #define s, etc. are normally never indented. Why? I'm working in some code at the moment which has a horrible mixture of #define s, #ifdef s, #else s, #endif s, etc. All these often mixed in with normal C code. The non-indenting of the #define s makes them hard to read. And the mixture of indented code with non-indented #define s is a nightmare. What is the benefit of not indenting #define s? Does it make me a bad person if I indent them? Isn't this much nicer? #ifdef SDCC #if DEBUGGING == 1 #if defined (pic18f2480) #define FLASH_MEMORY_END 0x3DC0 #elif defined (pic18f2580) #define

Formatting code in Notepad++

给你一囗甜甜゛ 提交于 2019-11-27 02:49:56
Is there a keyboard shortcut to format code in Notepad++ ? I'm mainly working with HTML, CSS and Python code. For example: <title>{% block title %} {% endblock %}</title> <link rel="stylesheet" href="/media/style.css" type="text/css" media="screen" /> </head> To: <head> <title> {% block title %} {% endblock %} </title> <link rel="stylesheet" href="/media/style.css" type="text/css" media="screen" /> </head> I remember Visual Studio doing it with Ctrl + K + D and NetBeans having the feature too but can't find it within Notepad++, if it can even do it. gablin TextFX -> HTML Tidy -> Tidy: Reindent

ReSharper formatting: align equal operands

狂风中的少年 提交于 2019-11-27 01:57:27
Note to Googlers , this question is somewhat out of date as the requested feature is now supported in the current version of ReSharper 2017.3.1 I like to formatting my code to align right side of equal operands. Like here: bool canRead = false; bool canReadClass = true; string className = boType.Name; I've switch to ReSharper recently and found it very useful but cannot find option allowing me format code in described way. Do you know if there is such option / plugin? Maybe you know other than ReSharp solution allowing that? EDIT: How to decide what part of code shall be aligned? My convention

Code Formatting In Xcode

一世执手 提交于 2019-11-27 01:47:29
问题 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? 回答1: Select some text and then: Edit->Format->Re-Indent You can bind this to a hotkey in the preferences. 回答2: In Xcode 4, it's been moved to Editor > Structure > Re-Indent command (and has a default shortcut of CTRL + I ). 回答3: Other than re-indentation (Edit > Format > Re-Indent), not really. However, Xcode does

IntelliJ IDEA code format from checkstyle configuration

余生颓废 提交于 2019-11-27 01:41:19
I've decided to contribute to android maven plugin. They use quite specific code style format. It will take some time for me to modify IDEA code format rules to satisfy their requirements. Fortunately there is checkstyle configuration. I've already installed check-style plugin for IDEA and immediately see where my current formatting is wrong. Unfortunately I didn't find way to import checkstyle configuration into IDEA formatting rules. I'm interested if it's possible. CrazyCoder UPDATE : supported since 4.24.0 plug-in version, see here for details. Original answer from 2013: Not possible yet ,

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

旧时模样 提交于 2019-11-27 00:09:38
问题 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? 回答1: 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

Auto-indent in Notepad++

断了今生、忘了曾经 提交于 2019-11-26 23:44:52
We always write code like this formal: void main(){ if(){ if() } But when I use Notepad++ , the display is: void main(){ if(){ if() } How do I use Notepad++ to auto indent? Thanks to Jonathan , I have set it, but it does not take any effect. The snapshot is below: I am using Notepad++ version 5.1.3. Notepad++ will only auto-insert subsequent indents if you manually indent the first line in a block; otherwise you can re-indent your code after the fact using TextFX > TextFX Edit > Reindent C++ code . If the TextFX menu does not exist, you need to download & install the plugin. Plugins->Plugin

Tool to Unminify / Decompress JavaScript [closed]

大憨熊 提交于 2019-11-26 23:34:08
问题 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.) 回答1: 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"

How can I reformat code in MATLAB editor?

人盡茶涼 提交于 2019-11-26 22:58:03
问题 How can I reformat code in MATLAB editor? Other IDEs usually have reformat or format option that arrange position of written codes. Does editor of MATLAB have it? I use MATLAB R2013a 回答1: A few default formatting shortcuts for the Matlab editor - assuming windows ctrl + A - Select all ctrl + I - Smart Indend ctrl + = - Collapse All (loop control statements) ctrl + shift + = Expand All (loop control statements) ctrl + ] - Increase indent ctrl + [ - Decrease indent ctrl + J - Wrap comments

How to generate an Eclipse formatter configuration from a checkstyle configuration?

北慕城南 提交于 2019-11-26 22:49:41
问题 I have a checkstyle configuration XML file and want to automatically generate an Eclipse formatter configuration from this. Is there any tool that can do this? 回答1: In Eclipse (3.6): Install Checkstyle plug-in Import stylesheet using Windows --> Preferences, General --> Checkstyle --> New. Since you have an external file, choose "external file" as the type. Right-click on your project in the Package view and select Checkstyle --> Create Formatter-Profile. Then enable the formatter for your