code-formatting

An autoformat tool to automatically insert braces around single-line clauses?

So assuming that in our work environment we've decided that the One True Faith forbids this: if (something) doSomething(); And instead we want: if (something) { doSomething(); } Is there a tool that will do that automagically? Awesomest would be to have eclipse just do it, but since we're really just recovering from one e...

ReSharper formatting: align equal operands

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 / pl...

How to move private fields to the top of the class with ReSharper

I want to move all the private fields in a class to the top or at least to a block where they are gathered together. Is there any quick way to achieve this with ReSharper? ...

Are there any templates to make Ruby code in Netbeans look as sexy as in Textmate?

As much as I love Netbeans for Ruby programming the traditional white background and drab color coding leave me with Textmate envy. Is there any solution to this in the absence of buying a Mac? ...

Smart Indent algorithm documentation?

I'm a big fan of documenting the proper behavior of IDE features that have a subtle but significant impact on coding flow - things like auto-completion selection and commenting/uncommenting code you might not realize you take advantage of but at the end of the day you got just a bit more done than you might have. I do so in hopes that ot...

Nice exception handling when re-trying code

I have some test cases. The test cases rely on data which takes time to compute. To speed up testing, I've cached the data so that it doesn't have to be recomputed. I now have foo(), which looks at the cached data. I can't tell ahead of time what it will look at, as that depends a lot on the test case. If a test case fails cause it doe...

Eclipse-like formatting for Visual Studio

Hey all, Is there a tool for Visual Studio that will automatically format source code (C#) on saving it? This would be useful for my multi-developer team to keep the code looking uniform, especially before the code is checked into the source control repository. ...

Should 2 executables compiled from the same source at different times have the same MD5SUM?

Should 2 executables compiled from the same source at different times have the same MD5SUM? I have been evaluating Automated Code Formatting using Artistic Style. One test I did was: Do a Clean Compile MD5SUM the executables Clean the build directory out. Run Astyle formatter on the code Recompile the code. MD5Sum the executable...

Are there any plugins for Visual Studio which automatically formats code how I like?

When I open any code file, whether something i've written or something from another developer, I want it to automatically format it with my preference of bracing, indentation, line spacing, etc.. Ideally, when saving a file to disk, it would only save the formatting for code/lines i've touched. It would still display the rest of the cod...

How make a better markdown for developer blog

I'm rebuilding my blog at http://www.elmalabarista.com/blog/. I have use in my previous version markdown and now I remember why I have almost zero code samples. Doing code samples in markdown is very fragile. I try to put some python there I can't make markdown mark it as code!. The main culprit? The syntax is markdown for code is out s...

Stop Eclipse from mangling my comments

Is there a way to stop eclipse from mangling the comments in my source files? My main issue is stopping it from word wrapping them. I've managed to configure eclipse to not word wrap any code but it still seems to do it to comments. Code that I enter like this: public int myVariable = 100; // this variable is a very interesting variab...

How do I modify Eclipse code formatting?

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...

Seeking a C Beautifier that will insert spaces between line elements.

I like spaces between almost all semantic elements in my C code. Thus I prefer if ( ( foo = bar ( arg1, arg2, arg3 ) ) == NULL ) { printf ( "Error 42" ); } to if((foo=bar(arg1,arg2,arg3))==NULL){ printf("Error 42"); } Is there a C beautifier around (unix platform) that can do this? It takes a seriously smart beautifier 'c...

How can I strip comments and doc strings from python source code?

Is there a program which I can run like this: py2py.py < orig.py > smaller.py Where orig.py contains python source code with comments and doc strings, and smaller.py contains identical, runnable source code but without the comments and doc strings? Code which originally looked like this: #/usr/bin/python """Do something blah blah......

Auto formatting code

Our team has recently inherited code which is extremely disorganized. As a result, my team leader has decided to enforce a policy of auto-formating of code prior to saving a file. We have even found an option in Eclipse (The IDE of our choice) that auto-formats the code automatically before each save action. Personally I am against it...

Should PHP code have spaces before operators?

I've seen a lot of code recently formatted as the following: A: if ($var=='test'){ $var=Foo('blah'.$var1); }else{ // do something } Personally I don't like it and would prefer it as: B: if ($var == 'test') { $var = Foo('blah' . $var1); } else { // do something } I think it's much more readable (note the addition o...

How to bulk cleanup imports in Java with eclipse?

On a generated project i 100s of warnings caused by unused imports and the like. Can i bulk cleanup those imports for all files? ...

ASP.NET MVC View Code Formatting - braces <% } %>

Does anyone know how to configure visual studio to correctly format code segments within a View This annoys the crap outta me!: <select> <% foreach(Height height in ViewData.Model.Heights) {%> <option value="<%=height.ID %>"><%=height.Value%></option> <% }%> </select> It should be like this: <% foreach(Height height in ViewData.Mode...

Intellisense and code formatting T-SQL for SQL Server 2008 in Visual Studio 2008?

I'm looking for a Visual Studio 2008 add-in / plug-in that can provide Intellisense and flexible code formatting for T-SQL for use with SQL Server 2008. It needs to work with Team System Data Edition ("data dude"). I am familiar with the Red Gate tools, but they do much more than I needwhich unfortunately puts the price on the high sid...

Can you recommend a CSS stylesheet that formats C# code?

I'm working on a code generation tool where the output is display in a tag and wondered if anyone knew of a CSS stylesheet that would format the output. My rendering engine is Javascript based and I'd like to continue perform all operations of rendering client side. ...