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]))
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login