Using UDL as default file type?
-
I am trying to set up an IDE for students based on portable NPP, which is being used for a language which is not one in the “standard” list. I have defined syntax colouring and so on as a UDL, and everything is working nicely apart from one problem. I would like to use my UDL as the default file type for new files (and thus also give the appropriate file extension), but I can’t find a way to do this. Is there a way to set the default file type to something which is not hard-wired into NPP?
-
Not at this time. But it’s easy enough to write up a PythonScript that you could call instead of hitting the normal File > New or New File button which would create a new file and associate it with the chosen UDL language.
And if your Language menu is staying constant (not changing frequently), you could even make it a macro instead – you would need one action in the macro for the File > New (which you could get by recording a macro and saving that macro), then adding another call to set the language (the language-menu entries are not macro-recordable, for historical reasons)
For example, UI Spy plugin tells me that in my normal Notepad++ installation,
Markdown (preinstalled)
UDL is 46182.
I then can create a macro in my shortcuts.xml:
<Macro name="NewMarkdown" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="2" message="0" wParam="41001" lParam="0" sParam="" /> <Action type="2" message="0" wParam="46182" lParam="0" sParam="" /> </Macro>
When I reload Notepad++ and run Macro > NewMarkdown, it creates a new file, and tells it to use
Markdown (preinstalled)
. And then when I save that file, it will default to markdown’s default.md
from the UDL settings.You can use Macro > Modify Shortcut to assign a shortcut to that (even the standard
Ctrl+N
, as long as you change File > New to not useCtrl+N
)Since your students’ installs are all going to be setup by you originally, I would bet that the menuCmdID will be the same for your UDL on all their machines, so I think it would work for you.
-
@peterjones
OK. I wanted this to just happen automatically when they start up NPP. At the moment it starts up with a tab labelled “new1” using C++ as the default language, and it does C++ syntax colouring when they start typing into it. The students will then have to click on my UDL in the language menu to get the right syntax colouring before they do anything else. Thanks for the suggestion, but it doesn’t really help in this situation AFAICS. -
@john-english said in Using UDL as default file type?:
t doesn’t really help in this situation AFAICS.
Possibly not. At which point, my other suggestion (PythonScript) would help. (make sure ATSTARTUP is selected; add code or a call in the user
startup.py
that sets the language to your UDL if the file isnew 1
and empty) -
@peterjones
OK, thanks, I’ll give it a whirl. -
-
@john-english and others reading this discussion:
I have submitted #11097 Allow UDLs in Default Language, due to this discussion and another recent one. (As well as the related #11096 Allow UDLs in SaveAs, which should also make dealing with UDLs easier)
I cannot guarantee that anything will happen as a result of those issues, but they’ve at least been submitted. And anyone reading this discussion who agrees that one or more of those is a good idea is free to go upvote or comment on those issues.