• Login
Community
  • Login

Using UDL as default file type?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 2 Posters 2.6k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J
    John English
    last edited by John English Jan 23, 2022, 10:35 AM Jan 23, 2022, 10:34 AM

    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?

    P 1 Reply Last reply Jan 23, 2022, 10:33 PM Reply Quote 0
    • P
      PeterJones @John English
      last edited by Jan 23, 2022, 10:33 PM

      @john-english ,

      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.
      87cb1989-8da3-4cd8-ab00-2da1735c3340-image.png

      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 use Ctrl+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.

      J 1 Reply Last reply Jan 24, 2022, 1:38 PM Reply Quote 2
      • J
        John English @PeterJones
        last edited by John English Jan 24, 2022, 1:39 PM Jan 24, 2022, 1:38 PM

        @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.

        P 1 Reply Last reply Jan 24, 2022, 1:56 PM Reply Quote 0
        • P
          PeterJones @John English
          last edited by Jan 24, 2022, 1:56 PM

          @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 is new 1 and empty)

          J 1 Reply Last reply Jan 25, 2022, 12:18 PM Reply Quote 1
          • J
            John English @PeterJones
            last edited by John English Jan 25, 2022, 12:18 PM Jan 25, 2022, 12:18 PM

            @peterjones
            OK, thanks, I’ll give it a whirl.

            P 1 Reply Last reply Jan 28, 2022, 2:28 PM Reply Quote 0
            • P PeterJones referenced this topic on Jan 27, 2022, 6:32 PM
            • P
              PeterJones @John English
              last edited by PeterJones Jan 28, 2022, 2:28 PM Jan 28, 2022, 2:28 PM

              @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.

              1 Reply Last reply Reply Quote 2
              2 out of 6
              • First post
                2/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors