Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Better syntax highlighting in Notepad++


  • Please log in to reply
8 replies to this topic
jayp
  • Members
  • 23 posts
  • Last active: Jan 04 2010 10:51 PM
  • Joined: 07 Mar 2009
Hi everyone,

I wanted to quickly share a solution to better AHK syntax highlighting in Notepad++. While I do not wish to disparage other editors, I haven't been able to find anything that I like as much as Notepad++ (or NPP for short). (I do not like SciTE4AutoHotkey for example.)

The problem is that NPP, with the current language files, has never done a good job with syntax highlighting. Consider the following as one example,

Send, % RemoveTrailingZeros(Round(Eval(math),DecimalPlaces)) 

The single % causes everything that comes after to highlighted as a variable. Ugly solutions are to add ;% (a comment with a percent sign). This makes NPP stop highlighting, but is annoying.

At any rate, I wanted to mention that I've achieved some success by looking at how to make a user defined language.

I'm making my userDefineLang.xml available as a download. This contains the userDefineLang.xml file and the AHK Autohotkey.xml file for auto completion. I got this latter file from somewhere on these forums but don't remember where now! (Readme.txt files in the zip explain where to put everything.)

Basically, my breakthrough was to remove the delimiters (% and %) and then use a keyword list in prefix mode with the % character. This causes a single % to turn on syntax highlighting, and as soon as it sees a white space character or an operator character, it turns off the highlighting.

I also add a number of new characters to the operator including a comma, so that things like Send, get highlighted properly. (Previously, keyword would only get highlighted if they were follow by a space.)

I also gave built in AHK variables a different colors that my own variables.

This solution is by no means perfect (you can find cases where things don't quite get properly highlighted), but in my testing, it's a big improvement on what I had before.

A real solution is getting an AHK lexer built into NPP. There seems to be a lot of potential for this but it hasn't happen yet.

I strongly feel that NPP is way ahead of the other editors in its capabilities. I'd like to see a real solution for AHK syntax but right now it's beyond my abilities.

ScottMattes
  • Members
  • 195 posts
  • Last active: Feb 16 2015 01:43 AM
  • Joined: 21 May 2007
Could you post it on AutoHotKey.net? That site is blocked for me (and I have never seen a URL like that, so I am leary of unblocking it).

Thank you.

jayp
  • Members
  • 23 posts
  • Last active: Jan 04 2010 10:51 PM
  • Joined: 07 Mar 2009
It's Microsoft's Windows Live Skydrive. It's just a zip file with a couple of .xml files inside.

lilalurl.T32
  • Members
  • 391 posts
  • Last active: Jul 05 2011 03:39 PM
  • Joined: 17 May 2007
Quickly tested it, I can confirm it is harmless.
________
Smoke Kills

wakeboarder3780
  • Members
  • 62 posts
  • Last active: Feb 03 2017 02:59 AM
  • Joined: 15 Jan 2009
Can we get a mirror or better yet, just paste the code in this forum? This site is blocked from work. I can do this tonight, but if someone has it now, it would be nice to have it now ;)
“In a world without walls and fences, who needs Windows and Gates”

jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

Better syntax highlighting in Notepad++

Here's the link to where I posted mine :wink: .

NewUserASH
  • Guests
  • Last active:
  • Joined: --
It Works , but i want to know how to enable Auto completion of Function or Syntax in Notepad++.

philu
  • Members
  • 15 posts
  • Last active: Jan 21 2016 06:34 PM
  • Joined: 28 Aug 2012

this is extremely helpful!

 

One thing I added myself to userDefineLang.xml @ Settings/Global was allowFoldOfComments="yes" and foldCompact="yes". This enables the folding of comments which I love.

Very nice work on the intellisense suggestions on typing also

 

edit. startpost downloadlink works for me, pls mail [email protected] if you need jayp's files

 

edit2:

and while we're at, as of today (2015_07_16_9.17) (<- generated by ahk ofcourse XD) the following commands (taken from the official complete command list) are missing in userDefineLang.xml:

 

&#x000D;&#x000A;Abs&#x000D;&#x000A;ASin&#x000D;&#x000A;ACos&#x000D;&#x000A;ATan&#x000D;&#x000A;Catch&#x000D;&#x000A;Ceil&#x000D;&#x000A;ComObjActive&#x000D;&#x000A;ComObjArray&#x000D;&#x000A;ComObjConnect&#x000D;&#x000A;ComObjCreate&#x000D;&#x000A;ComObjEnwrap&#x000D;&#x000A;ComObjUnwrap&#x000D;&#x000A;ComObjError&#x000D;&#x000A;ComObjFlags&#x000D;&#x000A;ComObjGet&#x000D;&#x000A;ComObjMissing&#x000D;&#x000A;ComObjParameter&#x000D;&#x000A;ComObjType&#x000D;&#x000A;ComObjValue&#x000D;&#x000A;Cos&#x000D;&#x000A;Exp&#x000D;&#x000A;FileEncoding&#x000D;&#x000A;FileOpen&#x000D;&#x000A;Finally&#x000D;&#x000A;Floor&#x000D;&#x000A;For&#x000D;&#x000A;Format&#x000D;&#x000A;Func&#x000D;&#x000A;GetKeyName&#x000D;&#x000A;InStr&#x000D;&#x000A;IsByRef&#x000D;&#x000A;IsFunc&#x000D;&#x000A;IsObject&#x000D;&#x000A;Log&#x000D;&#x000A;Ln&#x000D;&#x000A;Mod&#x000D;&#x000A;Round&#x000D;&#x000A;SendLevel&#x000D;&#x000A;SetRegView&#x000D;&#x000A;Sin&#x000D;&#x000A;Sqrt&#x000D;&#x000A;StrPut&#x000D;&#x000A;StrGet&#x000D;&#x000A;StrLen&#x000D;&#x000A;Tan&#x000D;&#x000A;Throw&#x000D;&#x000A;Trim&#x000D;&#x000A;Try&#x000D;&#x000A;Until&#x000D;&#x000A;VarSetCapacity&#x000D;&#x000A;WinActive&#x000D;&#x000A;WinExist&#x000D;&#x000A;IfTimeout&#x000D;&#x000A;InputLevel&#x000D;&#x000A;LTrim&#x000D;&#x000A;MenuMaskKey&#x000D;&#x000A;Warn

 

so one might wanna add them (or some of them) manually



jNizM
  • Members
  • 928 posts
  • Last active: Jan 12 2018 09:23 AM
  • Joined: 01 Aug 2012
Setup Notepad++ for AutoHotkey
[AHK] 1.1.27.04 x64 Unicode | [WIN] 10 Pro (Version 1709)
My GitHub Profile | Donations are appreciated if I could help you