AutoComplete XML Problem
-
Hello everyone - newbie to the forum but long standing NPP user, currently 8.8.3. I’ve been trying to create an autocomplete file for the PureBasic language, but have run into a problem. I’m hoping someone might be able to spot where I’m going wrong. A (short) sample of my file is shown below but it’s only partially successful:
<?xml version="1.0" encoding="UTF-8" ?> <NotepadPlus> <AutoComplete language="Purebasic"> <Environment ignoreCase="yes" startFunc="(" stopFunc=")" paramSeparator="," terminal="" additionalWordChar = "" /> <KeyWord name="If" func="no" /> <KeyWord name="EndIf" func="no" /> <KeyWord name="OpenWindow" func="yes"> <Overload retVal="" descr="Opens a new window according to the specified parameters."> <Param name="#Window" /> <Param name="x.I" /> <Param name="y.I" /> <Param name="InnerWidth.I" /> <Param name="InnerHeight.I" /> <Param name="Title.S" /> <Param name="Flags.I" /> <Param name="ParentID.I" /> </Overload> </KeyWord> <KeyWord name="#PB_Window_BorderLess" func="no" /> <KeyWord name="#PB_Window_Invisible" func="no" /> </AutoComplete> </NotepadPlus>
Keywords like the ‘If’ and ‘EndIf’ appear in autocomplete properly, as do functions and overloads like ‘OpenWindow’. However I’m having problems showing constants, they’re all ignored. I’ve tried two different forms, as shown in the example but neither works.
Does anyone have any suggestions?
Notepad++ v8.8.3 (64-bit) Build time : Jul 9 2025 - 01:39:59 Scintilla/Lexilla included : 5.5.7/5.4.5 Boost Regex included : 1_85 Path : C:\Program Files\Notepad++\notepad++.exe Command Line : "C:\Users\david\Downloads\gtk.res" Admin mode : OFF Local Conf mode : OFF Cloud Config : OFF Periodic Backup : ON Placeholders : OFF Scintilla Rendering Mode : SC_TECHNOLOGY_DIRECTWRITE (1) Multi-instance Mode : monoInst File Status Auto-Detection : cdEnabledNew (for current file/tab only) Dark Mode : OFF Display Info : primary monitor: 1920x1080, scaling 125% visible monitors count: 1 installed Display Class adapters: 0001: Description - Intel(R) Iris(R) Xe Graphics 0001: DriverVersion - 31.0.101.5186 OS Name : Windows 11 Home (64-bit) OS Version : 24H2 OS Build : 26100.5074 Current ANSI codepage : 1252 Plugins : DSpellCheck (1.5) HTMLTag (1.3.6) JsonTools (5) mimeTools (3.1) NppConverter (4.6) NppExport (0.4) NppRegExTractorPlugin (2.1) NppSnippets (1.7.1) XMLTools (3.1.1.13)
-
@spikey-pb said in AutoComplete XML Problem:
Does anyone have any suggestions?
When Notepad++ is doing auto-completion, it goes back to the first “word character” (A-Z, 0-9, _, and various unicode letters or numbers, and anything you define in the Delimiters settings), so it doesn’t include punctuation with default settings.
Thus, it does not see the
#
at the beginning as being part of a “word” when trying to auto-complete#PB_Window_Invisible
, so it doesn’t match.Secondly, the XML library that is used for processing the config files doesn’t seem to handle the decimal
&#
sequences under all circumstances; instead, use#
or the shorter#
to represent the#
– but even with that, Notepad++ will not auto-complete from there out-of-the-box.You have two choices:
- Don’t include the # in the keyword name. If you just have
PB_Window_BorderLess
andPB_Window_Invisible
, then typing#P
will still allow you to auto-complete on those, but it won’t start your character count until theP
instead of the#
. So if you have your auto-complete threshold at 2, you’d have to do#PB
instead of#P
before it would pop up
- but this has the drawback that if you type
PB_
even without the#
prefix, it will still suggest those words in auto-completion, which may or may not be acceptible to you.
- but this has the drawback that if you type
- Use Settings > Preferences > Delimiter’s
Add your character as part of a word
field to include#
as a pseudo “word” character.
I am updating the wording of the user manual:
Names For both parameter hint call tips and function autocompletion to work, keywords must be “words”:the easiest way to think of words is that it must be characters that most programming languages would readily accept as identifiers (variable names, function names, etc); this means that only the 26 Latin alphabet letters in either lower or upper case (no diacritics), digits and the underscore character _
are guaranteed to work. If you just care about function name completion, then spaces can work; also, for funtion-name completion only, any non-“word”, non-space ASCII character that is defined in the **Settings > Preferences > Delimiter >☑
entry field will work; however, spaces or non-“word” characters found in the list in the preferences will prevent Notepad++ from being able to display parameter hints for any function name keyword that uses those non-“word” characters. (Special characters, outside of the ASCII range, will not work for function name or allowing parameter hint autocompletion, even if you use XML entity notation; sorry.)Special Characters If you want to include special characters in the retVal
ordescr
attributes and have it render properly in the call tip popup, or if you want to have non-ASCII characters in the auto-completion text, you need to use hexadecimal XML numeric entities, in the form &#xhhhh; (you do not need to prefix the0
characters if it uses fewer than four hex digits). So 
or 
will insert a non-breaking space, or←
to get an ← arrow. (The 
decimal-XML numeric entity notation, unfortunately, will not work. Use the hexadecimal version of the notation.) - Don’t include the # in the keyword name. If you just have
-
@PeterJones said in AutoComplete XML Problem:
Thus, it does not see the
#
at the beginning as being part of a “word” when trying to auto-complete.I thought something like that might be the case but there was always a possibility of user error!
You’d have to do
#PB
instead of#P
before it would pop up
Use Settings > Preferences > Delimiter’sBy default the PureBasic IDE doesn’t show autocomplete before 3 characters anyway so I can’t see an issue there personally, but there’s a workaround for anyone who just can’t live with that.
I am updating the wording of the user manual:
Thank you for your amazing response! That’s just what I’m looking for.