Template substitution from list
-
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:- A list of names:
HARRY
RON
HERMIONE
…- 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 :)
-
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]))