tags:

views:

54

answers:

3

I'm looking for something like CSS for code. Does it exist either in an IDE, or as a plugin?

The compiler often doesn't care how many more spaces or tabs or newlines you have between tokens in your code, but people do care.

I want to specify in my "style sheet" that braces always live on a seperate line, commas are always followed by spaces, and spaces always surround operators.

Somebody else could then take my code and in their style sheet, specify that no unnecessary spaces should be visible, braces should always be on the same line as their predecessor, and functions should always be separated by 3 line breaks. But the code itself should not actually change.

Is there such a tool?

A: 

I don't think such a thing exists, the best solution is to have a custom style for local coding (most IDE's allow this) and then use a tool to reformat your source code (like Jalopy for Java) when you commit it centrally.

That way you have something that's common centrally, but can still style how you want locally.

I don't know of any tool that can arbitrarily apply a style to code without actually modifying the text itself. Since you need to edit the code, that seems impractical.

cynicalman
A: 

This is called code formatting and if you google "code formatter" and your language of choice you should get a list of available options.

Larry Lustig
I think he's looking for something that doesn't merely modify the code.
cynicalman
Thinking outside the IDE++
pst
A: 

Try some eclipse based IDE (Aptana) or eclipse itsefl and and from there you can configure how the formatting works :)

Aviatrix