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.

79-madms
  • 596
  • 1
  • 7
  • 19

3 Answers3

13

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.
Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
psxls
  • 6,807
  • 6
  • 30
  • 50
  • 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! – 79-madms Nov 20 '13 at 22:14
  • 1
    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! – psxls Nov 20 '13 at 22:17
  • 1
    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. – 79-madms Nov 21 '13 at 02:05
  • @mscott5861 Strange... I've tried to reproduce your problem. I downloaded the [userDefineLang.xml for ahk](https://github.com/twiz-ahk/npp-ahk/blob/master/userDefineLang.xml) 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. – psxls Nov 21 '13 at 09:23
  • 1
    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! – 79-madms Nov 22 '13 at 00:02
  • Nice! I'm updating the answer so future readers don't have to read our comments. – psxls Nov 22 '13 at 00:10
  • 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. – mnemotronic Nov 16 '15 at 15:53
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.

bgmCoder
  • 6,205
  • 8
  • 58
  • 105
  • 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. – 79-madms Nov 21 '13 at 02:08
  • A bit of a late comment, but check the extension field does not include a "." – vogomatix Sep 02 '14 at 09:46
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.