Zend Studio’s Dark Theme Variable Highlighting Got You Down?

I’ve long preferred working in light-text-on-dark-background editing environments. However, Zend Studio’s Dark Theme presented one problem for me, until I discovered the Annotations Preferences settings. Now, I’m happy again!

How would you like to go from this (“Argh! I can’t see the variable name!”)…

zend studio dark theme where you cannot read the variable names because of contrast issues.

… to this?

zend studio where you can read variable names because the contrast issues have been fixed.

Or this?

zend studio an example of an even better dark theme where variable names have a good contrast.

These highlights show all occurrences in a script of the variable the cursor is in, distinguishing between “read occurrences” and “write occurrences”. An example of a read occurrence is when a variable appears in an expression on the right-hand side of an assignment operator (i.e., the value is “read”). Write occurrences exist when the variable is given a value, for example by appearing on the left-hand side of the assignment operator, or by appearing in a function/method parameter list.

The default settings work much better in light themes than a dark one (see the first image above), but it turns out it’s easy to change.

First, go to Window | Preferences (On OSX, Zend Studio | Preferences):

zend studio menu showing the preferences option.

Type annotations in the Search filter field in the upper left or navigate to General | Editors | Text Editors | Annotations:

zend studio preferences screen.

In the center of the dialog box, under the list of Annotation types, select PHP elements ‘read’ occurrences. Then, from the select list on the right next to Text as, choose one of the options, and click OK (Apply didn’t seem to make the changes immediately visible).

zend studio preferences screen showing the annotations section.

Here’s what choosing Box looked like for me. Note we’ve changed only what a read access of the variable (the part inside the string) looks like:

zend studio highlighting partially fixed.

Below, we change the annotation to a box, and the annotation’s color, this time for PHP elements ‘write’ occurrences’:

zend studio preferences panel showing the color picker.

And here are the results, with default-colored boxes around read occurrences, and rose-colored boxes around write occurrences:

zend studio code sample showing progress being made in the highlighting of code.

Play around with the various annotation methods (box, dashed box, highlight, etc.) and colors, until you find a combination you like. Here are green highlights for read occurrences, and red highlights for write accesses:

zend studio final version of the color highlighting.

This last one is growing on me quickly; I think I’ll keep it!