What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

Is it possible to add auto indentation for code.

For example:

do
{
for(;true;)
{
}

}while(true);

The nested scope isn't auto indented. I have to do it manually. Is it possible to add the feature or it exists already?

share|improve this question
8  
And F5 to compile and run? :) –  Benjol Mar 25 '11 at 6:29
    
@Bejol: That would be too much to ask for :) –  Shamim Hafiz Mar 25 '11 at 6:31
2  
possible duplicate of Automatic code reindent button –  Arjan Mar 25 '11 at 7:53

2 Answers 2

up vote 6 down vote accepted

It is hard enough to find a library that will tidy up HTML, then you need to prettify JS within HTML files, and on top of that CSS. That's only considering core web development.

Then you have SQL formatting, C#, VB.net, *nix scripts, dos batch files, Delphi, Haskell, Perl, Python, Smalltalk, Ruby...

Each with its own language specification. For some languages, the formatting itself defines code blocks (begin-end), so you really don't want to guess on those ones.

Even if you can find a good formatter for EVERY SINGLE LANGUAGE StackOverflow1 supports (and that means all and sundry under the sun), can you even get developers to like the implicit formatting rules imposed by SE?

1 That is without even considering all the other sites on the SE2 sites that share the same engine

share|improve this answer
    
So, can we hop on this or what? –  Won't Mar 25 '11 at 15:19

Here is a customized version of jsbeautifier's userscript, that does your example code from,

enter image description here

To

enter image description here

Install - Source

  • only tested on chrome 11 dev, firefox 3.6
  • I have only @included http://*stackoverflow.com
  • might have some issues with existing syntax highligher
share|improve this answer
    
I went to the site, but not quite sure how to use it. Is this some kind of plugin? –  Shamim Hafiz Mar 25 '11 at 10:50
    
@Gunner, yeah, thats browser extensions, use to called greasemonkey or userscript, more info here stackapps.com/tags/script/info, but currently, above script has some issues with existing syntax highligher script in stackoverflow, so I am not recommand to install that at the moment. –  YOU Mar 25 '11 at 10:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .