Community
    • Login

    How to create a macro in notepad ++ to read a template and write it to the current file?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    macro writingnotepad++v8.1.3reading file sawrite-files
    3 Posts 2 Posters 1.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.
    • Daniel BriceñoD
      Daniel Briceño
      last edited by

      I want to make templates for different programming languages. I did the following:

      • Start macro recording

      • I opened a file from notepad ++. (This file is a template I made).

      • I copied the entire content of this file and inserted it into a file that I had created earlier.

      • I closed the file and finished the macro.

      When I ran the macro I saw that it had not copied all the content of the template, but simply pasted everything that was on the clipboard.<br/>
      This is where the question comes from.

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Daniel Briceño
        last edited by

        @Daniel-Briceño

        The clipboard commands in macros are literal. This means that they can work with variable data found on the clipboard when the macro is run.

        To do what you want, you’d have to, while recording a macro, actually type out the text you want to end up with. Or you could edit shortcuts.xml (where the macros are stored) to make it a bit easier to add your text.

        Isn’t a better way just to keep your template where you already have it (separate file), and when you need it copy the contents of that file into a new file that needs it?

        Alternatively, you could open your template file and then use the SaveAs command to create a new file with its contents.

        Daniel BriceñoD 1 Reply Last reply Reply Quote 4
        • Daniel BriceñoD
          Daniel Briceño @Alan Kilborn
          last edited by

          @Alan-Kilborn Gracia.

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