Notepad ++:如何在加载文件时自动将语言设置为 Xml
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9119517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Notepad++: How to automatically set Language as Xml when load files
提问by devlord
Whenever I edit a .config file in Notepad++ (which is an XML file) I want the syntax highlighting to automatically color it like XML. How do I configure Notepad++ to do this so that I don't have to manually select it every time I open a .config file?
每当我在 Notepad++(这是一个 XML 文件)中编辑 .config 文件时,我都希望语法突出显示能够像 XML 一样自动为其着色。如何配置 Notepad++ 来执行此操作,以便每次打开 .config 文件时都不必手动选择它?
Thanks.
谢谢。
回答by Erikest
You can do this by using the Style Configurator (Settings Menu):
您可以通过使用样式配置器(设置菜单)来做到这一点:
This image shows the php language, but it works for any language you want to map
此图显示了 php 语言,但它适用于您要映射的任何语言


回答by Adam Hawkes
From the Settingsmenu, choose Style Configurator.... Choose the XML Language from the list, and enter "config" in the User extfield.
从Settings菜单中,选择Style Configurator...。从列表中选择 XML 语言,然后在User ext字段中输入“config” 。
回答by James Allardice
I don't think you can set a default style for all files (there may be some config file trickery that does allow it though) but as you specifically mention .configfiles, you can open the langs.xmlor langs.model.xmlfile in your Notepad++ installation directory, find the xmlsection, and add configto the value of the extattribute:
我认为您不能为所有文件设置默认样式(尽管可能有一些配置文件技巧允许这样做)但是当您特别提到.config文件时,您可以在 Notepad++ 安装目录中打开langs.xml或langs.model.xml文件,找到该xml部分,并添加config到ext属性的值:
<Language name="xml" ext="xml xsml xsl xsd kml wsdl config" commentLine="" commentStart="<!--" commentEnd="-->">
</Language>
Or, use the Style Configuarator as noted by @AdamHawkes (+1), instead of messing around in the XML config files themselves!
或者,使用@AdamHawkes (+1) 指出的样式配置器,而不是在 XML 配置文件本身中乱搞!
回答by James Allardice
To set a 'global' default language:
要设置“全局”默认语言:
- Launch Notepad++
- Click Settings > Preferences
- Click on the New Document/Default Directory tab
- Change the Default Language to HTML
- Click the Close button
- 启动记事本++
- 单击设置 > 首选项
- 单击新建文档/默认目录选项卡
- 将默认语言更改为 HTML
- 单击关闭按钮

