CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Darrell Norton's Blog [MVP]

Fill in description here...

Get Visual Studio syntax highlighting for alternate file extensions

Question:
How do I configure things so that I can get proper code highlighting when I have a file that is a standard format (XML, or SQL) but has an alternate extension (.DNN, .SqlDataProvider)?

Answer:
Edit the registry (Warning: This is dangerous!  Backup the registry first!  I take no responsibility for any damage this may cause).  Also, you need to change 7.1 if you are not using Visual Studio 2003:

Under this subkey:  [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1\Languages\File Extensions], add a new key for whatever file extension you want to add syntax highlighting for (ie, .DNN or .SqlDataProvider).  It should show up as a little folder icon.

For the default REG_SZ, change the value to equal the GUID for the file extension you want to copy (ie, for .SqlDataProvider use the same GUID as for .sql).  Copy any other DWords, values, etc. (just copy everything from the key of the extension you want to copy).



Comments

Darrell said:

Joel - yes that is easier! Nice tip.
# April 21, 2004 5:37 AM

Gavin said:

If you also want to get the other nice features (such as auto-formatting when editing .jsp pages in the HTML editor, for example) find the editor that you want under \7.1\Editors (which would be the 'HTML Editor' in this case) and add the extension in the \Extensions key as a DWORD. The value for the DWORD seems to change a bit, but if you just copy what's already there it works fine.
# May 12, 2004 3:06 AM

Darrell said:

Nice tip Gavin. Thanks!
# May 12, 2004 3:15 AM

Graham Cottle said:

Hi,
I found this via Google and have managed to implement most of it. I can open a jsp page in VS2003 and it highlights syntax etc.
It will also provide the closing tag when I open a new one. eg </td> after <td>.
However, instead of being able to see the HTML designer, I get the XML designer, which refuses to load, since it doesn't like the jsp.
What else would I need to do to make the Studio open the file and give me the HTML Editor?

Also, is it possible to get the intellisense for HTML (I know I won't get the JAVA bits)?

Below are the registry entries which I made.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1\Editors\{C76D83F8-A489-11D0-8195-00A0C91BBEE3}\Extensions]
"jsp"=dword:00000028

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1\Editors\{8281C572-2171-45AA-A642-7D8BC1662F1C}\Extensions]
"jsp"=dword:00000027

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1\Languages\File Extensions\.jsp]
@="{58E975A0-F8FE-11D2-A6AE-00104BCC7269}"
"unused"="HTML"

As for why use jsp, it's because I'm working on an SAP project which uses jsp. I'm a .NET developer, so anything I can use which gives me the niceties of VS is good.

Thanks for the tip so far - it is very useful.
# November 16, 2004 6:46 PM

usr said:

thanks a lot, used that registry trick to colorify my bison/flex scripts.

the "open as" method somehow did not work, maybe because it already defaulted to plain text which is the same editor with the highlighting disabled or something like that.
# March 7, 2005 5:19 PM

Visual Studio syntax highlighting for Monorail views « James Hollingworths Adventures in Code said:

Pingback from  Visual Studio syntax highlighting for Monorail views &laquo; James Hollingworths Adventures in Code

# February 24, 2008 6:12 AM
Check out Devlicio.us!