Go to content Go to navigation Go to search

Add Syntax Highlighting to Additional File Extensions in Visual Studio 2005

I have been working with lot of SQL scripts lately, most of them files with the default extensions given by SQL Server’s export functionality (e.g. stored procedure scripts end in .prc, views end in .viw, triggers end in .trg, etc.). By default, Visual Studio 2005 doesn’t do any syntax highlighting of these files because it doesn’t recognize their extensions as SQL scripts/files.

Here is a procedure to turn on syntax highlighting for custom file extensions:

  1. Open regedit. (Click Start, Run…, type in regedit, and hit Enter or click the OK button.)
  2. Go to the HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Languages\File Extensions key.
  3. Click on the key for the file extension which maps to the syntax highlighting you want for your custom/new file extension. (In my case, I clicked on the .sql key.)
  4. Double-click the (Default) value under the key, and copy its value.
  5. Go back to the parent key (e.g. the File Extensions key from above), right-click and choose New > Key. Name the key with the custom/new file extension you want Visual Studio to syntax highlight.
  6. Double-click the key’s (Default) value and paste in the value from the original key’s (Default) value.
  7. Done! Open a file with your extension in Visual Studio 2005 and witness the syntax highlighting goodness.