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

I have a simple feature request.

Can we have a new item in the editing toolbar referencing syntax-highlighting? It will display all available languages and simply add the right line at the cursor position.

I think it would be really helpful. Many threads don't use syntax highlighting, mainly in first-time messages, probably because the are not aware of it. Moreover, I myself sometimes forget spaces, or some characters in the syntax, failing to activate this wonderful feature.

EDIT 1 : Indeed, I'm not using only StackOverflow ;), I'm posting on dba, serverfault, and sometimes read superuser. Even when I'm posting on SO, I use categories (or read questions) tagged with non obivous mappable tags : jQuery, maven, ant, ... Moreover, when I talk about mysql, maven or anything else, I often mix languages (xml, text, conf, java). So, relying on auto recognization is not an option for me. Thats why I suggested an extra button. But maybe am I an edge user ?

share|improve this question
2  
What for? 99% of the time SO should recognize and apply the correct highlighting on it's own. Do you have so many posts that need that manual intervention? –  Time Traveling Bobby Jun 26 '12 at 8:18
1  
Indeed, I spent 80% of my time, when I edit posts, just to add syntax higlighting. I'm really enjoying helping people, but I would be better if they were aware of it themselves. And, from my experience, auto recognization don't work with a rate of 99%, even this is a way of speaking. –  Jean-Rémy Revy Jun 26 '12 at 8:22
1  
You are throwing numbers around that I think many people will disagree with. Please provide examples for these cases. 99% is definatley an over-exaggeration... –  Lix Jun 26 '12 at 8:25

1 Answer 1

It would be nice if anywhere you placed code there would be a syntax highlighter/syntax checker however Stack Overflow is not a replacement for your IDE...

The system does a pretty good job at deciding what language to highlight according to the tags that were specified... In the event that this is not the correct language, you can explicitly set some syntax highlighting.

Syntax highlighting

Prettify is used to add colour to the code, but only if the language can be uniquely determined given the tags of the question, or if manual hints have been provided in HTML comments, using:

<!-- language: lang-or-tag-here -->

    code goes here

<!-- language: lang-or-tag-here -->

    code goes here

See the full specification.

Note that:

  • The HTML comments must not be indented
  • The blank line between <!-- language: ... --> and the indented code block is required
  • The space between language: and the language is required
  • When using a tag to specify language, the tag name is case-sensitive

If no language is defined then no highlighting occurs at all. But in the preview, or if multiple language tags define very different languages and no manual definition is used, a default highlighting is used in which Prettify makes a best guess.

Source - How do I format my code blocks?

share|improve this answer
1  
I'm already aware of this feature. Maybe I'm misunderstanding, but you are explaining how this works, aren't you ? I just want to improve interface edition, in order to promote and ease the use of this feature –  Jean-Rémy Revy Jun 26 '12 at 8:14
    
What I'm saying is that if people want to use syntax highlighting, they can do so, the feature exists... All you are saying is that you want an extra button on the toolbar packed with all possible languages - why not let the system do its work and automatically select a language according to the tags? If there is a problem, you can manually specify a language... –  Lix Jun 26 '12 at 8:19
1  
I will take a look to new posts, and see if the auto recognization indeed work better than I thought. I'm maybe influenced my own posts, but I often mix languages, don't use xml prolog in my snippets, and use tags (like maven, or ant) that don't imply xml recognization. This is maybe why I don't trust too much in it. On server fault, for bash or xml, this is pretty the same observation. But I understand what you are saying. –  Jean-Rémy Revy Jun 26 '12 at 8:42
    
Editing first message in order to clarify why recognization is not an option –  Jean-Rémy Revy Jun 27 '12 at 8:50
    
I took time to see if auto recognization was the solution. Half the time it is. I started to review posts a few days ago, and I really really often add prettyfier comment. And I make mistakes myself (forgotting a space, using the wrong name for the language). I'm now sure that would help to have this feature in the GUI. –  Jean-Rémy Revy Jul 15 '12 at 10:12

You must log in to answer this question.

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