问题
This is a very minor issue that has nonetheless annoyed me for months. I've spent hours Googling it to no avail.
To enable syntax highlighting of .ahk files in Notepad++, I've downloaded & imported an .xml file for AutoHotkey. The issue is that- to enable this highlighting- I have to manually select it from the "Language" drop-down. I'd like to it to be enabled whenever an .ahk file is opened, as it is for various other languages.
I've tried adding the .ahk extension to the AutoIt language in the Style Configurator, which does nothing for me. Any ideas? I can't be the first person to have been annoyed by this, but I haven't been able to ask Google with any success.
回答1:
It should be working. Check again:
- Go to
Settings → Style Configurator
, select your language and add in theUser ext.
theahk
extension (without a dot!). - If it's a User Defined Language, then go to
Language → Define your language
, then select from the dropdown list your language, and in the text box namedExt.
that will appear, add your "ahk" extension. - Make sure that the
ahk
extension is defined ONLY to AutoHotKey, not in two languages simultaneously (so remove the extension from AutoIt). - If it's still not working, check your Notepad++ version. Latest is 6.5.1, previous versions might had a bug.
回答2:
To install the syntax highlighter in Notepad++ version 6+:
- In the main menu, go to View > User defined language...
- Push the "Import..." button.
- Browse to the syntax colouring file. It may be either an
.xml
or a.udl
file. - It will report "Import Successful"
- Now, go and open one of the configuration files in Notepad++.
- Voila! Colour!
If the file was created correctly, it should already include the extension reference and automatically recognize new files and display them in the proper context. However, any files open in NPP will not automatically display the new colour highlighting until you close and re-open them.
Here is more information on NPP highlighters.
Here are some more User-Defined Highlighters.
Otherwise, maybe something is wrong with your udl file. You can try one that I made, if you like.
回答3:
My problem was that upon importing a friend's file, the extension field associated with my user-defined language had quotes around it : "mcr". I eliminated the quotes and now it works perfectly.
来源:https://stackoverflow.com/questions/20105620/syntax-highlighting-in-notepad-how-to-treat-a-user-defined-language-as-built