我可以告诉 Visual Studio 如何处理具有自定义文件扩展名的文件吗?
我可以告诉 Visual Studio 如何处理具有自定义文件扩展名的文件吗?我希望能够在 Visual Studio 中打开扩展名为“.xxx”的文件并进行 CSS 突出显示。
我尝试通过转到 VS -> 来做到这一点工具->选项->文本编辑器 ->文件扩展名,但在编辑器下拉列表中没有任何内容可以指定“将其视为 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.
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".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 Visual Studio 中,转到
Tools >选项>文本编辑器>文件扩展名
您可以在此处添加特定扩展名并选择 Visual Studio 用于该扩展名的“编辑器”。
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.
对于 Visual Studio 的最新版本,请参阅接受的答案,有一个用于将文件扩展名分配给编辑器的设置对话框。
对于 Visual Studio 2010 及更早版本
您可以使用一个注册表 hack。 https://engagesoftware.com/news/post/ 395/editing-sqldataprovider-scripts-within-visual-studio
基本上,您查看
HKLM:\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Languages\File Extensions\.css
(根据您的 VS 版本更改版本号,如果您使用的不是 64 位操作系统,则删除Wow6432Node
)并复制一份副本,将其命名为.my-custom-扩展
更新 根据一个类似的Stack Overflow问题,对于某些扩展(即CSS),还需要采取另一个步骤。它表示从您正在复制的扩展中获取 GUID,并在
HKLM:\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Editors
中找到其条目,并在其中添加一个 DWORD 值>Extensions
键类似于现有的css
值。这个问题还指出了 VS 库中的一个扩展可以做到这一点。然而,即使这样做之后,我自己仍然无法获得语法突出显示......For recent versions of Visual Studio, see the accepted answer, there's a settings dialog for assigning a file extension to an editor.
For Visual Studio 2010 and Older
There is a registry hack that you can use. https://engagesoftware.com/news/post/395/editing-sqldataprovider-scripts-within-visual-studio
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 removingWow6432Node
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 itsExtensions
key like the existingcss
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 2019 上测试。
工具>>选项>文本编辑器>文件扩展名
添加文件扩展名“.”像 .ejs (Node.JS View Engine) 一样,然后将其设置为已知编辑器之一并按添加:
.ejs>> HTML 编辑器
在 VS 中关闭并重新打开 .ejs 文件您将在它们上看到 HTML 标记。
Tested on Visual Studio 2019.
Tools > Options > Text Editor > File Extension
add your file extension with '.' like .ejs (Node.JS View Engine) and then set it to one of known editors and press add:
.ejs >> HTML Editor
Close and reopen the files with .ejs in VS & you will see HTML markups on them.
我最初发布这个答案 这里但我觉得值得重复。
工具>选项>文本编辑器>文件扩展名路线似乎只让您从一组固定的编辑器中进行选择。正确的?
我注意到(很偶然),当您右键单击时,上下文菜单上有一个打开方式选项:
然后您可以添加定制应用程序(例如 appTranslator Pro)并将其设置为默认值:
现在我可以双击 APT 文件,它将自动在 appTranslator Pro 中打开。不再弹出警告!
I originally posted this answer here but I feel it is worth repeating.
The Tools > Options > Text Editor > File Extension route seems to only let your select from a fix set of editor. Right?
I noticed (quite by chance) that there is an Open With option on the context menu when you right click:
You can then add a bespoke application (like appTranslator Pro) and set it as default:
Now I can double-click the APT file and it will automatically open in appTranslator Pro. No more popup warnings!