If you edit shader code in Visual Studio 2013, you might like to use NShader to get syntax highlighting. NShader was originally written by Alexandre Mutel. His version is available here but it only supports VS2008, VS2010, and VS2012. Issam Khalil had forked it and added VS2013 support, as well as Unity shader highlighting.
You can now override the file type detection by specifying, on the first line of a shader file, a comment like so:
<type> is one of:
This will force the file to use the specified syntax highlighter. This is case sensitive and must appear exactly as above. Otherwise if the
shadertype tag is not present, the file extension will be used to decide what type of highlighting to use. The following extensions are recognised:
HLSL syntax highlighter – .fx, .fxh, .hlsl, .vsh, .psh, .fsh
GLSL syntax highlighter – .glsl, .frag, .vert, .fp, .vp, .geom, .xsh
CG syntax highlighter – .cg, .cgfx
Unity syntax highlighter – .shader, .cginc, .compute
The keyword mapping files that can be placed in
%APPDATA%\NShader now override the built-in mappings. For example, if
float is mapped as a
keyword in the built-in mapping for GLSL, it can be changed to a
type by adding the following line to
Multiple words can be specified on a single line by separating them with spaces or tabs. The zip file contains the built-in keyword mapping files as examples.
I’ve also added a separate colour setting for anything that is defined as a
type. This should appear in Tools > Options > Environment > Fonts and Colors in the display items list for the text editor colours. Scroll down to ‘n’ and you should see all the NShader colour settings. The new setting is ‘NShader – Type’.
If you are having troubles with files not highlighting, try uninstalling NShader first via Tools > Extensions and Updates. Also make sure you restart Visual Studio after installing NShader!