Possible Duplicate:
VB.NET Syntax Highligting does not properly support comment.

When you try to put a code you put it into a code tag, but some programming languages have problems with this, like when you put a ', that represents a comment in Visual Basic language the code that put all the the other code highlighted as a comment and ends when you put one more ' like you can see here:

'Here is a String declaration
Dim test As String
'Here ends a String declaration

Please put something that you have to specify what is the programming language that is in the code tag, to improve the visual element. Thanks.

  • 9
    The highlighting is meant to drive people to use the languages it supports better. It is a subliminal form of mind control. – jjnguy Jul 13 '09 at 18:07
  • The stackoverflow team didn't write the coloring code btw. It is google's I believe. Pretify is the name I believe. – jjnguy Jul 13 '09 at 18:11
  • See my post here: meta.stackexchange.com/questions/4813/… – Nathan Campos Jul 13 '09 at 18:15
  • 5
    The code highlighter doesn't support languages that suck. Now you're asking yourself, who decides what languages suck? Why, the code highlighter, of course. – Hilarious Comedy Pesto Jul 13 '09 at 18:24
  • +1 to Pesto for a very amusing comment - Thanks for making me smile! :) – BrianH Jul 13 '09 at 19:10

One thing Stack Overflow could do is have a mechanism to easily suggest what language you're using in the code, for instance:


def foo():
    return 10 // 7

<a href="http://www.python.org/">Python!</a>

This is the approach taken by Trac, and it works quite well.


I agree, the code highlighting seems very good for C#, but for VB and others it is quite poor, if not unhelpful. I would love to see this improved.


Hello, If it's in Google Code the project of the code highlighting, here is the code highlighting project that i use in my site and it support's the language selection feature, but remember that is a project written in JavaScript. SyntaxHighlighter

  • Why the down vote?????? – Nathan Campos Jul 13 '09 at 18:22
  • The whole Q&A is spam. – GEOCHET Jul 13 '09 at 18:43
  • 1
    The question is legitimate. This answer might be a shameless self-plug for a better syntax highlighter, but it doesn't make the problem with prettify an VB code go away; and it's not spam if SyntaxHighlighter does actually fix the problem posed in the question. – Lawrence Dol Jul 13 '09 at 19:00
  • @Nathan: +1 because SyntaxHighlighter does look good, but you answer is in serious need of grammar correction. – Lawrence Dol Jul 13 '09 at 19:02
  • It's because i'm improving my english! – Nathan Campos Jul 13 '09 at 19:03
  • I live in Brazil. – Nathan Campos Jul 13 '09 at 19:05
  • The syntax highlighter used by SO can support VB syntax. However, it's not built in to the base highlighter, and SO doesn't include the plugin to enable this. SyntaxHighlighter uses plugin "brushes" for every language. So, no advantage - either way, SO needs to decide which languages it'll support and include the necessary plugins. You'd be better off just pushing for the SO Team to enable VB support... – Shog9 Jul 15 '09 at 0:03

I would like to point out that it almost never highlights Perl code correctly.

These all do the same thing, but aren't highlighted the same:

die if //;  # Perl doesn't even have // for comments
die if m''; # the only one, that is even close, to being right
die if m();
die if m::;

Now I know that part of the problem is that Perl is a very difficult to parse language.

That's why I think we should be able to highlight the code manually.

<pre class="prettyprint"><code>
<span class="kwd">die</span>
<span class="pln"> </span>
<span class="kwd">if</span>
<span class="pln"> m</span><span class="str">''</span><span class="pun">;</span>

<pre class="prettyprint-correct-perl"><code>
<span class="kwd">die</span>
<span class="pln"> </span>
<span class="kwd">if</span>
<!--                      /--higlight m'' together---\   -->
<span class="pln"> </span><span class="str">m''</span><span class="pun">;</span>

Even editors that are designed for highlighting Perl code, can sometimes get it wrong.

  • Ugh, who's going to type all that out? – John Fouhy Aug 24 '09 at 3:31
  • I would write a program to do it, for my languages of choice. – Brad Gilbert Aug 24 '09 at 3:58

See my answer to the related question here:
VB.NET/VBScript syntax highlighting does not properly support comments

In summary, you can do this as workaround for now:

''# You're commenting!
Dim c As New Comment()

This has pretty much been asked before in other posts where people are requesting more language-specific highlighting features (and the ability to select what language you want).

It can definitely be frustrating when doing VB and trying to put comments, so I end up usually marking up my code with c# comments, even though that won't be very good for anyone doing a full copy/paste job on my content.

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