Community
    • Login

    Header in new file

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    3 Posts 3 Posters 4.1k 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.
    • Roberto MorenoR
      Roberto Moreno
      last edited by

      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!

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R
        last edited by

        @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

        1 Reply Last reply Reply Quote 2
        • Alan KilbornA
          Alan Kilborn @Roberto Moreno
          last edited by Alan Kilborn

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

          1 Reply Last reply Reply Quote 3
          • Terry RT Terry R referenced this topic on
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors