Is it possible to add new document templates?

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

  • @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
      • 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:
    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

  • @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…

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

  • 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
    • 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.)

Log in to reply