Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I tell Visual Studio how treat a file with a custom file extension?

Tags:

Can I tell Visual Studio how treat a file with a custom file extension? I want to be able to open a file with ".xxx" extension in Visual Studio and have CSS highlighting.

I've tried to do it by going to VS -> Tools -> Options -> Text Editor -> File Extension but in the Editor drop down there is nothing to specify "treat it as CSS".

like image 891
dev.e.loper Avatar asked Aug 16 '10 13:08

dev.e.loper


People also ask

How do I add an extension to Visual Studio?

For example, to add file extension '. m' so that Visual Studio will recognize Macintosh XCODE iOS C files, type 'm' into Extension file, field "Editor:" = Microsoft Visual C++, and press "Add", close and re-open your . m file (if already open in VS), and there it is.

How do I add a code association in Visual Studio?

Open your settings (CMD + , on a Mac or CTRL + , on Windows) and enter a file association. We can do this with the settings UI or the settings JSON, both are options to edit your settings. Then enter a file association for the .


2 Answers

In Visual Studio go to Tools > Options > Text Editor > File Extension

There you can add specific extensions and choose which 'Editor' Visual Studio uses for that extension.

like image 134
jedi.jesse Avatar answered Sep 28 '22 03:09

jedi.jesse


There is a registry hack that you can use. http://www.engagesoftware.com/Blog/EntryId/117/Editing-SqlDataProvider-scripts-within-Visual-Studio.aspx

Basically, you look at HKLM:\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Languages\File Extensions\.css (changing the version number based on your version of VS, and removing Wow6432Node if you aren't on a 64-bit OS) and make a copy of that, calling it .my-custom-extension

UPDATE According to a similar Stack Overflow question, for some extensions (i.e. CSS), there's another step to be taken. It says to take the GUID from the extension that you're copying, and find its entry in HKLM:\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Editors and add a DWORD value in its Extensions key like the existing css value. That question also points to an extension in the VS gallery that does that. However, even after doing that, I'm still unable to get syntax highlighting, myself...

like image 28
bdukes Avatar answered Sep 28 '22 04:09

bdukes