Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

I frequently see many questions (and very few times answers) where the code provided is not formatted or indented well. I don't want to sound like a format czar, little bit here or there is perfectly okay, but sometimes it is so out of shape that it becomes distracting and bothersome and I can't concentrate on the actual question.

Would it be possible to provide a button that can be used to pretty format a selected piece of code? It can be yet another button like the 101-010 used for marking a piece of text of code. Obviously, it would be a optional one. It can be used by an editor in case the original author forgets to do it.

Now, SO is a place for many different languages. I found discussion on formatting tools of different languages, for example:

  1. C/C++:

  2. Java:

  3. Javascript:

  4. Python:

I am not aware if there is any single tool that can handle all languages, but ideally, that's what we want. (Same like the 101-010 button, which is language independent.)

Thoughts? Comments? Ideas?

share|improve this question
It's not clear to me what you're asking for, that isn't provided already by the code format button you reference. – Michael Petrotta Oct 4 '10 at 4:46
I may be wrong, but as I understand, the 101-010 button "mainly" does (a) indents the selected block of text by 4 spaces (depending on the input provided, this may or may not result in uniformly indented output), and (b) syntax highlighting. What I am asking for is pretty formatting and uniform indenting in the output. – Arun Saha Oct 4 '10 at 5:01
You mean something like this, right? There are a few cases where the formatting has been so bad manually de-mangling it takes a bit of effort, but for the most part I find that most people paste reasonably formatted code (even if they don't properly make it a code block in their question). – Tim Stone Oct 4 '10 at 5:03
gotcha. Yeah, that would be useful. – Michael Petrotta Oct 4 '10 at 5:16
@Tim: Yes, thats a very good example. (I didn't know that). @Michael: Thanks. – Arun Saha Oct 4 '10 at 5:21

We already have that button, it is called the Post Your Question button. Shortly after that button is pressed there will be hundreds of sets of eyes looking at your posted code, and if it isn't pretty enough the ones with enough reputation will go in and edit it for you to a reasonable standard.

I think a beautify button will be a waste of time. We get a lot of n00bs on this site who barely know how to write a line of code, they don't read the FAQ before they post, and they most certainly don't read the friendly helpful formatting instructions on the right as they type their question. They don't know about the code button, so do you really expect them to use a beautify button as well?

The more experienced posters will usually be pasting code copied directly from their favorite editor, so formatting shouldn't be a problem.

The syntax highlighting etc produced by the current code feature is already good enough, i don't need my javascript colored differently to my VB, i can read both just fine. (maybe regexs can be pretty-fied up a little though, maybe a little bit of pink and purple would be appropriate for them?).

In terms of user experience (UX), there is only so much you can do to help people before you get an overload of features that have little or no return on investment.

share|improve this answer
The point of this would be (I am guessing) make the life of people who prettify ugly code easier. I know I could use it, and I edit a lot. – NullUserException อ_อ Oct 4 '10 at 6:15

You must log in to answer this question.

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