Syntax Highlighting in Notepad++: How to treat a user-defined language as built-in?
Asked Answered
T

3

11

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.

Tude answered 20/11, 2013 at 19:53 Comment(0)
K
14

It should be working. Check again:

  1. Go to Settings → Style Configurator, select your language and add in the User ext. the ahk extension (without a dot!).
  2. 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 named Ext. that will appear, add your "ahk" extension.
  3. Make sure that the ahk extension is defined ONLY to AutoHotKey, not in two languages simultaneously (so remove the extension from AutoIt).
  4. If it's still not working, check your Notepad++ version. Latest is 6.5.1, previous versions might had a bug.
Koy answered 20/11, 2013 at 20:21 Comment(7)
Thanks a lot for the response! No syntax highlighting occurs when I add in the "ahk" extension under "AutoIt" in the "user ext.:" textbox of the Style Configurator (I took note of your comment about the dot), although syntax highlighting DOES occur if I select AutoIt from the 'Languages' and have an .ahk script open. Also, none of the user-defined languages that I've imported appear as options in the Style Configurator. I'm using 6.5.1, as well. I'll keep trying to work this out, and thanks again!Tude
1) you tried "ahk" or ".ahk" ? 2) User defined languages appear in menu Language > Define your language, then select from the dropdown list your language, and there's a textbox that will appear named Ext. where you can add the extension ahk. Works for me!Koy
Still no good. (1) I've tried both. (2) All of the .ahk extensions appear in the ext. text box under Language > Define your language, but- when I open an .ahk file- I still have to manually select the language. It doesn't recognize it as being an .ahk script.Tude
@mscott5861 Strange... I've tried to reproduce your problem. I downloaded the userDefineLang.xml for ahk which I guess you are using, and since there the ahk extension is already defined, everything worked fine for me without any extra work! In your original post, you said that you defined ahk extension for AutoIt. This might be the culprit. Make sure that the ahk is defined ONLY to AutoHotKey, not in two languages simultaneously.Koy
That did it! After erasing the 'ahk' extension from AutoIt, saving & closing, then restarting the computer, I now have proper .ahk syntax highlighting whenever I open an .ahk file in Notepad++. Thanks for the time and help!Tude
Nice! I'm updating the answer so future readers don't have to read our comments.Koy
I was trying to do same thing to make ".tsc" files use VBScript syntax highlighting. I had to Close all the files that I was editing in N++ that used the extension then re-open them. That did it.Anatropous
L
3

To install the syntax highlighter in Notepad++ version 6+:

  1. In the main menu, go to View > User defined language...
  2. Push the "Import..." button.
  3. Browse to the syntax colouring file. It may be either an .xml or a .udl file.
  4. It will report "Import Successful"
  5. Now, go and open one of the configuration files in Notepad++.
  6. 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.

Laoighis answered 20/11, 2013 at 22:14 Comment(2)
Thanks for the really thorough response and for the links! Unfortunately, still no good. I went through all these steps when I imported the AHK .xml file, and again: I get the syntax formatting when I manually select from my list, but not on opening an .ahk script. It's the latter I'm trying to figure out.Tude
A bit of a late comment, but check the extension field does not include a "."Buryat
C
0

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.

Coleville answered 21/10, 2014 at 20:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.