• Login
Community
  • Login

Header in new file

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
3 Posts 3 Posters 4.2k 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.
  • R
    Roberto Moreno
    last edited by Oct 10, 2021, 8:23 PM

    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!

    A 1 Reply Last reply Oct 10, 2021, 8:47 PM Reply Quote 0
    • T
      Terry R
      last edited by Oct 10, 2021, 8:46 PM

      @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
      • A
        Alan Kilborn @Roberto Moreno
        last edited by Alan Kilborn Oct 10, 2021, 8:49 PM Oct 10, 2021, 8:47 PM

        @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
        • T Terry R referenced this topic on Feb 15, 2023, 8:17 AM
        1 out of 3
        • First post
          1/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors