Header in new file



  • Dears, I’m looking for a Notepad++ plugin that insert a header in all new files. Example: if I click in File>New, or Ctrl+N, the new blank file brings the text “Created by Bob” at first line. There’s something like this? Thanks!



  • @Roberto-Moreno said in Header in new file:

    Example: if I click in File>New, or Ctrl+N, the new blank file brings the text “Created by Bob” at first line. There’s something like this? Thanks!

    Nothing built-in, however it is easy to set up.

    Just create a macro by recording the steps:

    1. Create a new tab
      2.Write the “header” info, followed by enter.
    2. Stop the macro and save it using a meaningful name, together with a “hot key” of your choice (one that isn’t currently used).

    The macro gets saved in the shortcuts.xml file, generally located under Notepad++ folder within the %AppData% hidden folder. So on any subsequent session hit the “hot key” and you will have a new tab with the header line inserted.

    Terry



  • @Roberto-Moreno

    Here’s a way of doing it with PythonScripting (PythonScript is a plug-in):

    # -*- coding: utf-8 -*-
    
    from Npp import *
    
    try:
        HINF__callback_npp_BUFFERACTIVATED
    except NameError:
        def HINF__callback_npp_BUFFERACTIVATED(args):
            if editor.getTextLength() == 0: editor.setText('Created by Bob')
        notepad.callback(HINF__callback_npp_BUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED])
    

    One option is to put most of that script into startup.py, or make a call to the script from startup.py if you don’t embed it.


Log in to reply