UDL languages keep disappearing
-
Hello,
I’m trying to get into UDLs.
But why does it disappear everytime I restart the program? Do I have to rewrite the udl every time? I tried saving as, too. Doesn’t help. I’ve rebuilt my language two times now.
-
I am going to answer myself and say I figured it out.
I had clicked “save as” in the define udl window, and saved it in my own folder. Fixed it by moving the saved file to the appdata/ userdefined folder for NPP.I learned that this file contained all my UDLs.
-
@Nils-Petter-Olsen said in UDL languages keep disappearing:
I had clicked “save as” in the define udl window, and saved it in my own folder
You need to be more precise in your description, because that’s not what happens (under normal circumstances).
- You open Language > User Defined Language > Define Your Language
- You create your new definition (though it’s currently under the “User Defined Language” name
- at this point, if you were to exit Notepad++, it would be lost; Notepad++ never stores the UDL named “User Defined Language” – it’s only there as a test bed
- Hit Save As. You give it a name. There is still no file defined. It’s just got an internal name.
- An alternate for Steps 2 and 3 would be to start by hitting Create New, which will immediately request a name; you can then define the language after that.
- Either way, it’s named, but no config file is written yet.
- Exit Notepad++: with a normal installation, it will write a file called
userDefineLang.xml
in your%AppData%\Notepad++
directory, assuming it has permission, with the new language(s) that you’ve defined. You should not have to move the file anywhere; it’s in the right spot to begin with.
If this isn’t the behavior you experienced, then either those weren’t the steps you followed, or you didn’t have write permission to your
%AppData%\Notepad++
directory, or your Notepad++ wasn’t set up to use%AppData%
– sharing your ?-menu’s Debug Info could give us insight into any non-standard config you have in that regard. If it wasn’t in the right spot in step 4 for you, you should have told us where it was, so that we could help you debug why it was in the wrong spot (but I personally doubt it was in the wrong spot, unless you have a weird configuration… or maybe if you were in Admin mode)((Hmm, maybe if you had multiple instances of Notepad++ open, it wouldn’t save properly, if the one you saved it in wasn’t the instance that had the permissions to save configs; that might be the umpteenth reason to not use multi-instance Notepad++; I haven’t tried, and won’t bother. See the Alternate section below for a procedure that will be immune to this, even if only the primary N++ instance can write to the default UDL file, which I’m not sure if there is such a limitation or not.))
I learned that this file contained all my UDLs.
When created that way, yes.
A few years back, Notepad++ added a new
%AppData%\Notepad++\userDefineLangs\
folder to hold individual UDL per file, to make it easier to make use of someone else’s UDL definition (like from the UDL Collection). But when you create a new UDL using the sequence above, it makes use of the old, combined file, rather than standalone files in the subdirectory.So if, in your original report, by “disappear”, you meant "no file shows up in
%AppData%\Notepad++\userDefineLangs\
, then that’s expected behavior. But when you restart Notepad++, they should have still shown up in the Language menu, whether you created it with Save As or Create New from the UDL dialog.Alternate
That said, I dislike Notepad++'s default behavior of keeping them all in the single
userDefineLang.xml
file, and much prefer using theuserDefineLangs\
folder. So I use a slightly modified sequence:- Open Language > User Defined Language > Define Your Language
- Immediately hit Save As (or Create New) and give it a name (in this example, I will use
MyName
) - Before inputting any keywords or stylers, I hit Export, and save to
%AppData%\Notepad++\userDefineLangs\MyName.xml
- Confusingly, I now hit Remove to delete the current copy of
MyName
from the UDL dialog (if you skip this step, you will soon have two copies of the same UDL name) - Exit Notepad++ and restart
- Language > MyName will exist (though it won’t do any highlighting yet)
- Go to Language > User Defined Language > Define Your Language and pick
MyName
from the dropdown. - Edit the Stylers and Keywords, etc, to make the UDL do what I want.
- Notepad++ automatically saves any changes made to the UDL to the right config file when you exit Notepad++ (assuming not in multi-instance mode; I make no guarantees or warranties about behavior in that confusing mode)
… Hmm, the User Manual isn’t clear enough on that in the UDL File Locations section. I should fix that.
Update: new section “Keeping UDL Files Separate” using a variant of that sequence of steps.