2
\$\begingroup\$

It looks like the syntax highlighting has recently changed for VBA (I would post a sample but I don't think meta does code highlighting...)

Here's an image to preserve what I'm seeing, tagged with lang-vb which is the default extension for the VBA tag:

code sample

The blues are a slightly lighter shade and the red strings are more vivid than before.

According to this post on syntax highlighting, SE uses Google code-prettify for formatting code. However there are no recent pulls that would suggest a change to how lang-vb looks.

What's caused the change?

Also this looks really bad on mobile (Android + Chrome):

code sample

The dark blue, red and black are almost indistinguishable - VBA code doesn't even use the light blue

| |
\$\endgroup\$
  • \$\begingroup\$ Confirming the tag is still configured to use lang-vb syntax highlighting. It's really all just CSS though; could be that colors for keywords and string literals (and comments?) were tweaked. \$\endgroup\$ – Mathieu Guindon Feb 26 at 17:42
  • 1
    \$\begingroup\$ Cross site duplicate. \$\endgroup\$ – 1201ProgramAlarm Feb 27 at 1:53
6
\$\begingroup\$

code-prettify works by adding <span class="..."> elements into the prettified code with classes for different syntax elements. The supported elements for lang-vb are "plain", "string", "comment", "keyword", "literal" and "punctuation". The colors themselves are controlled by a stylesheet provisioned by Stack Exchange (you're looking for primary.css), so SE gets to tweak the colors anytime they want, and nothing needs to be pushed to Google's repository for that to happen.

lang-vb is used for all "flavors" of VB, including , , , but also . Looks like there was a CSS update from SE — explaining why there isn't any pull requests on the repo you linked — to make VB syntax highlighting look more like VB.NET does (by default anyway) in a modern IDE like Visual Studio:

VB.NET code in Visual Studio

The default syntax highlighting in the VBE wasn't all that great anyway (lang-vb used to look similar to this, at least as far as keyword-blue is concerned):

VBA code in the Visual Basic Editor


Personally I like configuring the VBE's identifier text forecolor to teal - it makes string literals (whose forecolor isn't configurable) neatly distinguishable from identifiers:

VBA code in the VBE, with identifiers in teal instead of black

I wish the VBE allowed different colors for type names vs other kinds of identifier names, but 1998 doesn't agree!

| |
\$\endgroup\$
  • \$\begingroup\$ Thanks, that explains it clearly - is there a way to view the primary.css source for SE? Also, are different style sheets used on mobile, as code blocks on my phone (Android 10, Chrome) have greatly reduced contrast compared to on desktop - kinda hard to read lang-vb now \$\endgroup\$ – Greedo Feb 29 at 18:53
  • \$\begingroup\$ You should be able to read it with your browser's dev tools - CSS gets downloaded to the client. \$\endgroup\$ – Mathieu Guindon Feb 29 at 19:13

You must log in to answer this question.

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