问题描述
我可以告诉Visual Studio如何处理带有自定义文件扩展名的文件吗?我希望能够在Visual Studio中打开扩展名为".xxx"的文件并突出显示CSS.
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.
我已经尝试通过转到VS->工具->选项->文本编辑器->文件扩展名来做到这一点,但是在编辑器下拉菜单中没有指定将其作为CSS处理"的内容.
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".
推荐答案
您可以使用注册表黑客. http://www.engagesoftware. com/Blog/EntryId/117/Editing-SqlDataProvider-scripts-within-Visual-Studio.aspx
There is a registry hack that you can use. http://www.engagesoftware.com/Blog/EntryId/117/Editing-SqlDataProvider-scripts-within-Visual-Studio.aspx
基本上,您查看HKLM:\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Languages\File Extensions\.css
(根据VS的版本更改版本号,如果不在64位操作系统上,则删除Wow6432Node
)并对其进行复制,将其称为.my-custom-extension
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
更新,根据类似的Stack Overflow问题,对于某些扩展(例如CSS),还需要采取进一步的措施.它说要从要复制的扩展名中获取GUID,并在HKLM:\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Editors
中找到其条目,并在其Extensions
项中添加一个DWORD值,如现有的css
值.这个问题也指向了VS Gallery中的一个扩展.但是,即使这样做,我本人仍然无法突出显示语法...
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...
这篇关于我可以告诉Visual Studio如何处理具有自定义文件扩展名的文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!