Notepad++ Syntax Highlight, AutoComplete - AHK v1 & v2 - 2023/10/05

Scripting and setups with Notepad++ and AutoHotkey.
User avatar
TheArkive
Posts: 1032
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Notepad++ Syntax Highlight, AutoComplete - AHK v1 & v2 - 2023/10/05

10 Feb 2020, 14:32


Syntax Highlighting
Install:
  • place files in ...\userDefineLangs folder
  • modify files names as desired
    The default config is my config, which puts AHK v2 as the default, and is listed first. If you want AHK v1 to be the default, remove the #_ from the file name
  • go to the UDL ui:
    Language > User Defined Language > Define your language...
  • select the version of AHK UDL you want to edit
  • input the extension data ONLY for the one you want to be the default for loading AHK files
  • if you are using the light theme, rename the following line (near the top of the file) to exclude (light)

    Code: Select all

    <UserLang name="AutoHotkeyV2 (light)" ext="" udlVersion="2.1">
    
    --- rename to ---
    
    <UserLang name="AutoHotkeyV2" ext="" udlVersion="2.1">
    This is particularly important if you plan to use Auto-Complete / Call Tips. I don't actually use the light theme, but I do put effort into maintaining it.

Auto-Complete and Call Tips
Notes:
  • only AHK v2.0.10 for now
  • I added all #directives, functions, built-in variables
  • #directives work with auto-complete with a few conditions:
    1) I made a list of #directives starting with _ so you can pull up a list of directives by typing _
    2) I also made a list of #directives ending with _ for easy Auto-Complete and identifying which terms are #directives. Of course, backspace the _ when done.
    3) Finally, all directives are included with # for call tips. It works if you type ( (and if needed manually invoke the call tip). Of course, don't forget to backspace the ( when you are done.
  • Most functions have at least 2 pages.
    1) Page 1 is the basic syntax.
    2) Page 2 is some kind of help, whatever I found to be useful. If I found more info useful, in many cases I added extra pages.
  • I also included Call Tips for several flow control statements in order to have quick examples at the ready. Just type a ( after the flow control statement, and backspace it when you are done.
Install:
  • place the file(s) in ...\autoCompletion
  • syntax highlighting UDL is required for these to work (see above)
Usage:
  • manually invoke Auto-Complete with CTRL+Space (default)
  • manually invoke Call Tips with CTRL+SHIFT+Space (default)
  • press ALT+⬆️ and ALT+⬇️ to navigate the pages of the Call Tips when multiple pages exist
  • Notepad++ settings can be set to automatically show Call Tips and Auto-Complete:
    Settings > Preferences... > Auto-Completion
  • I recommend "Function Completion" only. This will allow functioning Call Tips as well as Auto-Complete for functions, #directives, and built-in variables.


:arrow: Download on GitHub

============================================================
Warning for aspiring coders and newbies...
============================================================

============================================================
Updates
============================================================

I am currently using these tools on Notepad++ v8.5.7 64-bit.

For custom call tips try CallTipsForAll.

CallTipsForAll is a bit old, and does need to be updated, but it still functions ok-ish.
Last edited by TheArkive on 06 Oct 2023, 05:47, edited 40 times in total.
User avatar
Cerberus
Posts: 172
Joined: 12 Jan 2016, 15:46

Re: Notepad++ Syntax Highlight and Auto-Complete (dark theme) - AHK v1 and v2 combined - 2020/02/10

16 Feb 2020, 18:29

Great work! I'll try these when next I use Notepad++.
User avatar
TheArkive
Posts: 1032
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Notepad++ Syntax Highlight and Auto-Complete (dark theme) - AHK v1 and v2 combined - 2020/03/06

06 Mar 2020, 13:50

Updated!

The new update is MUCH more complete and functional than before.

Now you have AutoComplete + Function Hints, and syntax highlighting for:
  • Functions (+ hints)
  • Commands (+ hints)
  • Objects (+ hints)
  • Methods (+ hints)
  • Properties (+ hints)
  • Variables
  • Flow Control Keywords
  • Keys List
AHK1 and 2 is included in these files, and the hint data shows you which version of AHK the keyword applies to.

Basics: Type keyword and press . (period) for hint window. Press Backspace to close window and remove the .. This workaround is what allows me to create hint data for all these types of syntax elements.

ToDo:
  • I'm going to revise this, now that I have the script done and I've defined the format that's easy to work with, I can just edit the source files and make much more descriptive and helpful hints.
  • I might try and turn this into a script that runs in the background, and will hopefully be compatible with any text editor, using CaretGetPos([OutputVarX, OutputVarY]). If this works then I'll include URL's to help docs as much as possible in a future update.
User avatar
TheArkive
Posts: 1032
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1 and v2 combined - 2020/03/08 - release 3

08 Mar 2020, 17:23

2020/03/08 Update:
  • added TreeView functions from AHK1 to syntax highlighting, autocomplete, and call tips
  • added ListView functions from AHK1 to syntax highlighting, autocomplete, and call tips
  • added ImageList functions from AHK1 to syntax highlighting, autocomplete, and call tips
  • added "Global" and "Local" to syntax highlighting (grouped with commands - Keyword list 1)
User avatar
TheArkive
Posts: 1032
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1 and v2 combined - 2020/03/08 - release 3

14 Mar 2020, 04:45

2020/03/14 Update:
  • added SetRegView, Run, RunWait, RunAs, Shutdown to command list for call tips
  • added Parse, Files, Reg to command list for call tips, but are filtered from KW_Cmd.txt list because these are Flow Control keywords
  • modified format for List_*.txt files
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1/2 combined - 2020/03/18 - release 5

25 Apr 2020, 12:56

Would it be possible to extend this script to allow to paste a full snippet and not only a single command?
E.g. when typing „Switch“ not Only Switch Expression but

Code: Select all

Switch Expression
{
  Case „result“:
  Case „result“:
  Default:
}
ciao
toralf
User avatar
TheArkive
Posts: 1032
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1/2 combined - 2020/03/18 - release 5

25 Apr 2020, 13:36

@toralf
should be possible using hotstrings. You're just looking for some quick auto-complete?
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1/2 combined - 2020/03/18 - release 5

27 Apr 2020, 03:22

I meant via the auto completion mechanism of npp. I didn’t find a way to add linebreaks or indentation to the output of the auto completion mechanism. Did you?
ciao
toralf
User avatar
TheArkive
Posts: 1032
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1/2 combined - 2020/03/18 - release 5

27 Apr 2020, 03:37

the only possible way that MIGHT work is to use &#x0a;. It works in making a multi-line description for call tips, but this might not work for auto-complete.

Are you trying to get a hotstring effect similar to AHK, but happening in NPP?
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1/2 combined - 2020/03/18 - release 5

27 Apr 2020, 05:12

In npp you can choose between different autocomplete when there are more options, e.g. different set of parameters or command options. But it is only for a single line of code. I would like to add an option to autocomplete also a code block. I do not want to have two different systems for autocomplete.
ciao
toralf
Beholder
Posts: 1
Joined: 17 Jun 2020, 15:28

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1/2 combined - 2020/03/18 - release 5

17 Jun 2020, 15:38

Hi, your AHK NPP highliting fails at the ahk script of EitherMouse 0.81. Please check it out if you want, you can download EitherMouse ahk in the zip from their website: eithermouse.com

The other AHK NPP syntax highlighting from this forum works fine on the EitherMouse script: https://www.autohotkey.com/boards/viewtopic.php?t=50
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1/2 combined - 2020/03/18 - release 5

17 Jun 2020, 19:05

@TheArkive, can this be used along with your other tool that you posted in the v2 section or would it interfere with it? Basically, I'd like to add v2 syntax highlighting to Notepad++ capability alongside your other tool.
User avatar
TheArkive
Posts: 1032
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1/2 combined - 2020/03/18 - release 5

18 Jun 2020, 01:57

@boiler
Yes you can use this, though i suggest not using the auto-complete / call tips in notepad++.
EDIT: I mean, it's not a good idea to use CallTipsForAll and notepad++ call tips / auto-complete at the same time.

@Beholder
Thanks, I know there are a few different keywords I've missed. Can you give a few examples of missed keywords? I'll check out eithermouse and see if I can see them too.

EDIT: Ah yes, strings, and handling `" for highlighting. I'll see what I can do, but I like my strings to be a different color. I actually never use `" specifically because of that. I usually use q := Chr(34) or something like that to use literal quotes.

EDIT: @Beholder
How does this syntax highlighting fail? The one you linked to (which i have used before, and is still good of course) does the same thing when `" is used. I only posted this one because I didn't see an AHK v1 and v2 combined version. That is what this is supposed to be.
Last edited by TheArkive on 18 Jun 2020, 08:57, edited 1 time in total.
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1/2 combined - 2020/03/18 - release 5

18 Jun 2020, 08:32

TheArkive wrote:
18 Jun 2020, 01:57
though i suggest not using the auto-complete / call tips in notepad++.
why?
ciao
toralf
User avatar
TheArkive
Posts: 1032
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Notepad++ Syntax Highlight / Auto-Complete / Function Hints - AHK v1/2 combined - 2020/03/18 - release 5

18 Jun 2020, 08:56

toralf wrote:
18 Jun 2020, 08:32
why?
Not trying to brag, but I think my call-tips / auto-complete are better. Notepad++ call tips don't easily support commands / functions / methods, specifically for AHK. Of course for other languages I would assume Notepad++ call-tips and auto-complete is perfectly fine.

EDIT: Specifically, I was referring to not using CallTipsForAll and Notepad++ call tips / auto-complete at the same time.

Didn't mean to make such a broad statement, I'll modify that. Thanks.
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Notepad++ Syntax Highlight - AHK v1/2 combined - 2020/06/18 - release 6

18 Jun 2020, 09:47

@TheArkive - Thanks. I thought it was all one package. I should have realized that it would just be an XML file that could be used independently of the other stuff. Works well. :thumbup:
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Notepad++ Syntax Highlight - AHK v1/2 combined - 2020/06/18 - release 6

18 Jun 2020, 11:00

I misunderstood your statement, sorry. I read it as if you said that call tips for all should not be used with npp. Glad, I was wrong
ciao
toralf
User avatar
TheArkive
Posts: 1032
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Notepad++ Syntax Highlight - AHK v1/2 combined - 2020/07/01 - release 8

01 Jul 2020, 07:18

2020/07/01 Update:
  • added new ControlGet / ControlSet commands and #Require directive for AHK v2-a113
  • added some missing Control... commands
User avatar
TheArkive
Posts: 1032
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Notepad++ Syntax Highlight - AHK v1/2 combined - 2020/07/02 - release 8

02 Jul 2020, 04:20

For yesterday's post I forgot to upload the changes. They are now uploaded.
sdkyron
Posts: 61
Joined: 06 Aug 2018, 00:57

Re: Notepad++ Syntax Highlight - AHK v1/2 combined - 2020/07/02 - release 8

28 Jul 2020, 03:43

It's nice and all but when i import it and open an ahk script, it looks like this ?
Untitled.jpg
Untitled.jpg (82.59 KiB) Viewed 26286 times

Return to “Notepad++”

Who is online

Users browsing this forum: No registered users and 1 guest