code-formatting

Delphi code formatter

若如初见. 提交于 2019-11-26 22:24:11
Are there any utilities that reformat Delphi code ? EDIT I am using Delphi 2006 Some feedback Thanks to all that answered this question I have been using the JCF code formatter - it works well and my code is been formated to Object Pascal Style Guide Germán Estévez -Neftalí- You can try the " Jedi code Format ". See more information here: http://jedicodeformat.sourceforge.net/ The formatting engine of DelForExp has been integrated into the code base of GExperts. An experimental version of GExperts including a "Code formatter" here: http://blog.dummzeuch.de/experimental-gexperts-version/

Per-token font size in Sublime Text 2

末鹿安然 提交于 2019-11-26 21:41:52
问题 Apologies if this has already been answered but I couldn't find any duplicates. Is it possible to set font sizes on a per-token basis in Sublime Text 2? For example, all 'function' tokens would be size 10 whereas 'functionName' would be size 30? I've put together a rough mock-up of what I want to achieve: The motivation here is to make it easier for you to focus on the important parts of your code - especially when skimming. I would suspect that such a thing should be possible given that, by

Most idiomatic way to print a time difference in Java?

∥☆過路亽.° 提交于 2019-11-26 21:04:40
I'm familiar with printing time difference in milliseconds: long time = System.currentTimeMillis(); //do something that takes some time... long completedIn = System.currentTimeMillis() - time; But, is there a nice way print a complete time in a specified format (eg: HH:MM:SS) either using Apache Commons or even the dreaded platform API's Date/Time objects? In other words, what is the shortest, simplest, no nonsense way to write a time format derived from milliseconds in Java? Apache Commons has the DurationFormatUtils class for applying a specified format to a time duration. So, something like

Sorting methods in Eclipse

社会主义新天地 提交于 2019-11-26 20:34:15
问题 Is there an easy way to sort methods within a class in Eclipse? 回答1: select the class, Source > Sort Members you can set the order in Java preferences via Eclipe forums 回答2: Found it on the Eclipse newsgroup: select the class, Source > Sort Members 来源: https://stackoverflow.com/questions/854232/sorting-methods-in-eclipse

Checking for NULL pointer in C/C++ [closed]

假装没事ソ 提交于 2019-11-26 19:28:02
In a recent code review, a contributor is trying to enforce that all NULL checks on pointers be performed in the following manner: int * some_ptr; // ... if (some_ptr == NULL) { // Handle null-pointer error } else { // Proceed } instead of int * some_ptr; // ... if (some_ptr) { // Proceed } else { // Handle null-pointer error } I agree that his way is a little more clear in the sense that it's explicitly saying "Make sure this pointer is not NULL", but I would counter that by saying that anyone who's working on this code would understand that using a pointer variable in an if statement is

Eclipse: Can you format code on save?

时光怂恿深爱的人放手 提交于 2019-11-26 18:54:42
问题 In Eclipse, under Windows -> Preference -> Java -> Code Style , you can define code templates for comments and code, and you can setup a code formatter. I'm wondering if it is possible in Eclipse to have these setting take affect every time I save a source file. Basically, instead of me highlighting everything and pressing Ctrl + Shift + F , I want Eclipse to be responsible for making sure my code is formatted properly. Is this possible and how do you set it up? Note On Using the Auto-Format:

How to auto-format code in Eclipse?

匆匆过客 提交于 2019-11-26 18:03:27
How do you auto-format code in Eclipse? On Windows : Ctrl + Shift + F On Mac : ⌘ + ⇧ + F (Alternatively you can press Format in Main Menu > Source) Another option is to go to Window->Preferences->Java->Editor->SaveActions and check the Format source code option. Then your source code will be formatted truly automatically each time you save it. Tabrock CTRL + SHIFT + F will auto format your code(whether it is highlighted or non highlighted). This can also be done at the Project Level: In the Package Explorer, right-click on the project > Properties > Java Editor > Save Actions This might be

Turn off auto formatting in Visual Studio

天大地大妈咪最大 提交于 2019-11-26 16:06:53
I'm a code purist, preferring 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. After using any of the built-in refactorings, Visual Studio clobbers my settings with its default settings. How do I keep VS from doing that? Tango91 I had this problem while writing VB in an aspx page. The solution was to go to 'Tools > Options > Text Editor > Basic > VB Specific' and turn 'Pretty Listing' OFF. Note - in Visual Studio 2015 this can be found at: Tools > Options > Text Editor > Basic >

Unnecessary curly braces in C++?

折月煮酒 提交于 2019-11-26 15:02:32
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 code: do some new fancy stuff here } existing code } What is the outcome, if any, from this? What could be the reason for doing this? Where does this habit come from? Edit: Based on the input and some questions below I feel that I have to add some to the question, even though that I already marked an answer. The environment is embedded devices. There is a lot of legacy C code wrapped in C++ clothing. There are a lot

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

浪子不回头ぞ 提交于 2019-11-26 12:51:06
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 decoupled from any particular development environment . Ideally, it should be independent of any particular operating system as well. So, a built-in formatter for the IDE du jour is of little interest here (unless that IDE supports batch mode formatter invocation, perhaps from the command line). A formatter written in closed-source C/C++ that only runs on, say, Windows is not ideal, but is