Critique of Gedit Syntax Highlighting + PHP Color Schemes

Author: Jacob Barkdull on Wednesday, June 25 2014 Comments

I've always liked PHP's default syntax highlighting, that is to say the color scheme used by highlight_file(). I've often found myself easily grokking code examples on PHP.net when, say, looking up the parameter order for something like imageconvolution(), only to suffer some frustration once going back to Gedit.

Here's the thing, syntax highlighting is supposed to help prevent syntax errors (obviously) and aid programmers in finding what they're looking for in very large amounts of code. I didn't understand what was causing my frustrations with Gedit until recently when I realized its default color scheme is terrible.

Let's take a look at it...
Gedit's default syntax highlighting color scheme


Firstly, if the aim is to help prevent syntax errors, then errors must be clearly indicated as such by some means. Red text should, therefore, never be used in syntax highlighting schemes for anything other than errors, such as spelling errors and in advanced text editors -- of which Gedit is sadly not one, and most are not -- syntax errors such as calls to undefined variables, functions or uninstantiated classes should be indicated by red text or red underline. Red is the most useful and expected color to indicate errors, red should not be used to indicate function and class definitions, as is being done in the above screencap.

I also notice an unnecessary use of bold font for "class", "public", "function", and "for", which I have yet to find useful. However, Gedit does share this oddity with Wikipedia, GNU Nano, GNU Emacs, and even GitHub, so perhaps this kind of syntax highlighting is simply common among text editors.

Gedit's default syntax highlighting color scheme also poorly aids programmers in finding what they're looking for. For example, function and class names as well as constants are colored black, and therefore hard to find. If a programmer is defining or looking for a specific variable they should be able to simply skim over the source code tree looking for text of a certain color, allowing them to focus on or ignore the defining of functions, classes, constants and likewise calls to functions, classes, constants and variables. Gedit's default color scheme fails to do this well, for every language. However, GNU Nano is by far the worst offender.

Admittedly, the default PHP color scheme is only marginally better than Gedit's default, as variables, integers, floats, functions, and classes all use the same color. However, that isn't a deal breaker as the idea behind it -- as far as I can tell -- is that things the programmer defines like variables, functions, classes, and constants are of one color, the defining method ($, function ..., class ..., define) are of another color and the values of things like variable strings, echoes, and arrays are of yet another color... sadly red.

I personally think Gedit should conform to the standard or default syntax highlighting color scheme of each language. Gedit's default may feel very comfortable to C/C++ and JavaScript programmers, but it's rather foreign to PHP programmers. Therefore C/C++ and JavaScript should use one color scheme, PHP should use another, and HTML/CSS/XML should use a different scheme as well. This would be particularly useful for PHP projects where HTML, JavaScript and PHP code is often mixed together, having each language conform to specific color schemes would allow programmers to easily differentiate between the different languages.

With that said, here are three Gedit color schemes that mimic PHP's default.

Screenshots
All three color schemes
Default PHP color scheme
PHP Default
Default PHP color scheme (with grey comments)
PHP Default
(grey comments)
Default PHP color scheme 'User Contributed Notes' section
PHP.net
(User Contributed Notes) section

Installation Instructions
Step 1. Download .tar Archive

Step 2. Extract the files to the hidden directory ~/.local/share/gedit/styles

Step 3. Start or restart Gedit.

Step 4. Select "PHP Default" from the "Color Scheme" list in the "Font & Colors" tab under Preferences.

Step 5. Enjoy! Happy hacking!


Known Issues
* Curly braces aren't colored, there doesn't appear to be an option to define a color for curly braces.
Share This Page On...
Subscribe to Newsletter:
Advertisements: portfolio
On the blog...
HashOver Gets a Logo!
Regarding Identi.ca and Its Share Button
Did Brendan Eich Contribute to Firefox's Decline?
The NSA backdoor in "Linux"
The popularity of Firefox is definitely waning!
Stop Complaining, Gedit Is Better Than Ever