Special characters in Notepad++ user defined language files
I use Notepad++ as my main editor when writing HTML files. The default html.xml
API file that defines the autocompletion rules for HTML files always annoys me, because it's full of old/obsolete/invalid tag names. To combat this, I am attempting to create a new API file for valid HTML5.
One of the problems is that non-alphanumeric characters do not seem to be recognised by the editor (you can see one instance of this in the default HTML autocompletion file - it defines !doctype
but you can never get that to appear since the editor doesn't seem to like the !
character).
I have tried replacing the characters in question with escaped versions (such as !
for the exclamation mark), but that doesn't seem to make a difference.
So my question is, is there a way to get Notepad++ user defined language files to recognise non-alphanumeric characters?
(Another question is whether this question should be asked here or on StackOverflow... I posted it here because it doesn't really ask anything about programming. It's more about the use of a programming tool.)
Example (enable autocompletion in preferences, select HTML as language and type a letter):
Delete the letter you just typed, and type an exclamation mark. No autocomplete selection pops up, even though if you scroll to the top of it (when it opens for other characters) the first entry is !doctype
.
The fact that this is the case with the default HTML API file kind of makes me believe that it can't be done, but if that's the case, why is !doctype
listed in there at all?
Update
I have also tried changing the default encoding in the API file from Windows-1252
to UTF-8
(and some others), and changing the encoding in a test file to match (in the Encoding menu), but this appears to make no difference.
Solution 1:
Unfortunately there is no way, because this is how Notepad++ is implemented.
I've looked into the source code of Notepad++ and when it does auto completion it checks back to the start of the word that you're typing. Meaning it only checks alphanumeric characters and '_'.
So if you type "!d" and hit CTRL+Space to activate the auto-completion drop-down, it will parse your string backwards and it will stop on '!' because that is not alphanumeric, nor '_'. Therefore, it will show you the words starting with 'd'.