Community
    • Login

    Is it possible to add new document templates?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 4 Posters 3.3k 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.
    • Nate0523N
      Nate0523
      last edited by

      I heard it’s possible to make templates with NewFileBrowser, but I don’t understand quite how to use it.

      What I’m looking for is to be able to start a new document and have a little bit of code written for me.

      Does anyone know if this is possible? Any help would be appreciated.

      PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Nate0523
        last edited by

        @Nate0523 ,

        I had never heard of nor used it; apparently, there is only a 32bit version.

        But I installed it, and was able to muddle my way through. (The plugin’s docs at its sourceforge page are minimalistic, and focus on the author’s other plugin housed at the same page.)

        So my process was

        1. Install plugin
        2. Go to Plugins > Newfile&Browser > Option
        3. If you go to the New File No. drop-down
          92ed1920-2b91-48e2-a081-8c510fd75de4-image.png
          • you can pick either File1 (for HTML) or File2 (for JAVA)
          • if you Edit Initial Text, you can modify the template for that language
        4. if you change the Total Count dropdown to another number (3 or more), then New File No. will get additional entries
          • you can choose one of the new entries, then select File Type as appropriate.
          • If you enter a File Name, it will show up in the menu (later), though as far as I can tell, that isn’t used anywhere
          • click Edit Initial Text to edit the text for the template. It will save as %AppData%\Notepad++\Plugins\Config\template#.dat. Save the file in Notepad++
          • click on Save in the Config Setting dialog to make sure it saves the number and order of templates.
        5. After exiting Notepad++ completely and restarting, the new entries show the new entry:
          e4442ae5-1e8e-4960-b3d7-998a783e7c10-image.png
        6. If you click on one of the Plugins > Newfile&Browser > Create … entries, it will populate the
          • The About Newfile&Browser shows that placing the sequence ^! in the template file will mean when it creates the new file from the template, it will place the cursor at that location in the template file
        PeterJonesP 1 Reply Last reply Reply Quote 1
        • Alan KilbornA
          Alan Kilborn @Nate0523
          last edited by

          @Nate0523 said in Is it possible to add new document templates?:

          What I’m looking for is to be able to start a new document and have a little bit of code written for me.
          Does anyone know if this is possible? Any help would be appreciated.

          It’s certainly possible; I have it doing just that kind of thing when I start writing a new script file for the Pythonscript plugin. The little thing itself is written in…, well, Pythonscript itself.

          So maybe say a bit more about what you’re looking for, and, knowing that, I’ll see if what I’ve got can handle it (I think it probably can), and I’ll post something…

          1 Reply Last reply Reply Quote 3
          • andrecool-68A
            andrecool-68
            last edited by

            I advise you to test the “Npp Snippets” plugin. It already has a lot of snippets of different code and for different languages. You can also create and save your own code snippets, and insert them wherever you need it.
            https://github.com/ffes/nppsnippets

            1 Reply Last reply Reply Quote 3
            • PeterJonesP
              PeterJones @PeterJones
              last edited by

              And now, since you brought it up, my review of that plugin, and suggestions for other choices.

              • It looks to be pretty old (last update 2015), and doesn’t appear maintained
              • It only comes in 32bit (but they still have a non-Unicode “ANSI” version available!)
              • When you do create a new file of a given type, it doesn’t use the File Name entry from the Config Setting dialog at all. Instead, it gives it a random all-caps name, and uses the all-caps version of the File Type dropdown as the extension for the file, rather than using any sort of reasonable extension. (so if you’ve defined a PERL entry, it names it XXXXXX.PERL instead of XXXXXX.pl)
              • I do like that it automatically sets the Language for the new file.
              • It doesn’t let you pick UDL
              • It doesn’t seem to honor the Auto Show in Browser when Saved (HTML) for either File1 (HTML) or for any of the other types (at least not in my experiments).
              • If you click the little IE logo it adds to the toolbar, it opens the active file in an in-Notepad++ instance of IE that the plugin has embedded.

              Personally, I find it an interesting idea, but not well-executed. It may have been top-of-the-line in 2015 when released, but I think it could be better today. For getting the same features today, I would use:

              • I would use the QuickText plugin for snippets, which allow me to do the initial populating of the file (by typing start then the QuickText-expansion keystroke).
              • I would use the builtin View > View Current File In … rather than than its embedded IE instance; if I wanted to render in the Notepad++ environment itself, I would use the PreviewHTML plugin instead
              • The one feature I see missing is automatically applying the Language selection when creating a new file.
                • Of course, when I use Windows built-in Windows Explorer > Right Click > New … > (select file type), I can use Windows to store those templates, and assign a reasonable filename and extension right away; then when I open-with Notepad++ on the new file, it’s been populated from the template and opens with the right Language already selected as well… And this allows you do define a template for any UDL by just using the right extension as well.

              (PS: Seeing the new posts from @Alan-Kilborn and @andrecool-68 , I concur that PythonScript could be used to automate the initial template as well, and Npp Snippets is an alternative to the QuickText plugin.)

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