Darrell Norton's Blog [MVP]

Sponsors

The Lounge

News

  • Darrell Norton pic

    MVP logo

    View Darrell Norton's profile on LinkedIn

    Currently Reading:

    weewar.com

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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).


Posted Wed, Apr 21 2004 8:46 AM by Darrell Norton

[Advertisement]

Comments

Joel Ross wrote re: Get Visual Studio syntax highlighting for alternate file extensions
on Wed, Apr 21 2004 5:36 AM
There's a better way to do this for a few of the file types, such as XML! When you are in the file -> open dialog box in VS.NET, click the arrow on the Open button, and choose open with...

In the new dialog, select the type of editor you want to edit the file with, then click "Set as Default" and the next time you open a file in VS.NET with that same extension, it uses the default highlighting. I used this with .build files for NAnt, which is just XML.
Darrell wrote re: Get Visual Studio syntax highlighting for alternate file extensions
on Wed, Apr 21 2004 5:37 AM
Joel - yes that is easier! Nice tip.
Gavin wrote re: Get Visual Studio syntax highlighting for alternate file extensions
on Wed, May 12 2004 3:06 AM
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.
Darrell wrote re: Get Visual Studio syntax highlighting for alternate file extensions
on Wed, May 12 2004 3:15 AM
Nice tip Gavin. Thanks!
Graham Cottle wrote re: Get Visual Studio syntax highlighting for alternate file extensions
on Tue, Nov 16 2004 6:46 PM
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.
usr wrote re: Get Visual Studio syntax highlighting for alternate file extensions
on Mon, Mar 7 2005 5:19 PM
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.
Visual Studio syntax highlighting for Monorail views « James Hollingworths Adventures in Code wrote Visual Studio syntax highlighting for Monorail views &laquo; James Hollingworths Adventures in Code
on Sun, Feb 24 2008 6:12 AM

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