Syntax highlighting

Shaderific now supports syntax highlighting.

Syntax highlighting works on both iPad and iPhone running iOS 6. Highlighting works in the background in response to any text change you make.

For the following types of text specific highlighting colors are defined:

  • Text
  • Keywords
  • Functions
  • Variables
  • Indices
  • Numbers
  • Comments
  • Preprocessor directives

Every color can be customized to your liking as part of the selected theme.


The text color is the standard color used for text, that is not affected by any of the highlighting colors.

The keyword color is used for all data types, qualifiers and statements. To give some examples:

  • Data types are int, float, ivec3, mat4, etc.
  • Qualifiers are attribute, uniform, varying, const, highp, etc.
  • Statements are if, else and return

The function color is used for all build-in functions of the shader programming language (GLSL). These include:

  • Trigonometric functions
  • Geometric functions
  • Matrix functions
  • Functions for comparing vectors
  • Functions for texture lookup

The variable color is used for all user-defined variables (as well as user-defined functions). Variables and functions are not highlighted at their first occurrence when they're defined but whenever they are used after that.


The index color is used for all vector and matrix indices. Indices are only highlighted when they are formed with valid characters and the respective variable has been properly defined. Valid index characters are x, y, z, w, r, g, b, a, s, t, r and q.

The number color is used for all numbers. No further explanation needed here.

The comment color is used for all comments. But a disclaimer has to be made here. Comments enclosed by /* and */ are not recognized by the highlighting routine. But they are completely legit as far as the compiler is concerned.

The preprocessor color is used for all preprocessor directives. These are statements like #define, #ifdef and #pragma, etc.

Should you encounter a situation where highlighting is not working properly for a code segment, please let me know.