Community
    • Login

    Template substitution from list

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    templatessubstitution
    2 Posts 2 Posters 201 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.
    • Atanvarno AldarionA
      Atanvarno Aldarion
      last edited by

      Hey, I have to define lots of identical structures for many variables.
      Is there some plug-in for N++ that would allow me to have:

      1. A list of names:

      HARRY
      RON
      HERMIONE
      …

      1. A template like:

      STUDENT [NAME] IS:
      NAME: [NAME]
      ID: 1-[NAME]-2
      BIOGRAPHY: [NAME]'s biography follows.

      and would let me combine them into:

      STUDENT HARRY IS:
      NAME: HARRY
      ID: 1-HARRY-2
      BIOGRAPHY: HARRY’s biography follows.

      STUDENT RON IS:
      NAME: RON
      ID: 1-RON-2
      BIOGRAPHY: RON’s biography follows.

      STUDENT HERMIONE IS:
      NAME: HERMIONE
      ID: 1-HERMIONE-2
      BIOGRAPHY: HERMIONE’s biography follows.

      Can something do that for me? Thanks :)

      EkopalypseE 1 Reply Last reply Reply Quote 0
      • EkopalypseE
        Ekopalypse @Atanvarno Aldarion
        last edited by

        @Atanvarno-Aldarion

        Yes, there is, and it’s called the PythonScript plugin.
        Probably any other scripting plugin can do this too.

        Here is an example of what it might look like.

        names = [
        'HARRY',
        'RON',
        'HERMIONE',
        ]
        
        template = '''
        STUDENT {0} IS:
        NAME: {0}
        ID: 1-{0}-2
        BIOGRAPHY: {0}'s biography follows.
        '''
        
        editor.appendText('\r\n'.join([template.format(x) for x in names]))
        1 Reply Last reply Reply Quote 4
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors