<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to batch out lines of code with same code but different variables?]]></title><description><![CDATA[<p dir="auto">I’m working on macros for a maptool campaign and one thing that keeps getting me is that I have to make multiple(40+)  lines of the same code with only minor changes in the variables, while the rest of the code stays the same. Is there a way to insert a list of variables and have notepad++ substitute the second variable for all of the occurrences of the first variable in the second line, then the third for the third line etc…<br />
Example:<br />
Line 1:"aAppraise|0|Appraise “+Appraise+”/“eval(+mAppraise+)” “+cAppraise+”,<br />
Line 2:"aBluff|0|Bluff “+Bluff+”/“eval(+mBluff+)” “+cBluff+”,<br />
Line 3: (replace all instances of Bluff with Concentration)</p>
<p dir="auto">I know I can go line by line with find and replace, but this is pretty tedious as well.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/15906/how-to-batch-out-lines-of-code-with-same-code-but-different-variables</link><generator>RSS for Node</generator><lastBuildDate>Wed, 20 May 2026 06:32:31 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/15906.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 09 Jun 2018 15:34:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to batch out lines of code with same code but different variables? on Wed, 20 Jun 2018 14:31:31 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/shadowfire-omega" aria-label="Profile: shadowfire-omega">@<bdi>shadowfire-omega</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Hope you don’t mind my <strong>late</strong> reply ! So, given the <strong><code>8</code></strong> lines <strong><code>"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"</code></strong>, which end, <strong>each</strong>, with a <strong>word</strong>, after the <strong><code>=</code></strong> <strong>separator</strong> sign</p>
<pre><code class="language-diff">"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Appraise
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Bluff
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Concentration
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Test
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Shadowfire
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Omega
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=OK
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=The End
</code></pre>
<p dir="auto">and the <strong>regex</strong> S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-is)Appraise(?=.+=(.+))|=.+</code></strong></p>
<p dir="auto">REPLACE <strong><code>?1\1</code></strong></p>
<ul>
<li>
<p dir="auto">First, the <strong><code>(?-is)</code></strong> forces the regex search to be <strong>sensitive</strong> ( <strong>non-insensitive</strong> !) to the case and the <strong>dot</strong> <strong><code>.</code></strong> regex character to represents any <strong>single standard</strong> character and not an <strong>End of Line</strong> character</p>
</li>
<li>
<p dir="auto">Then it matches any of the <strong>two</strong> alternatives, giving <strong>priority</strong> to the <strong>first</strong> one</p>
<ul>
<li>
<p dir="auto">The regex <strong><code>(?-is)Appraise(?=.+=(.+))</code></strong></p>
</li>
<li>
<p dir="auto">The regex <strong><code>=.+</code></strong></p>
</li>
</ul>
</li>
<li>
<p dir="auto">If the <strong>first</strong> alternative is chosen, it, then, matches the <strong>Appraise</strong> string but <strong>only</strong> if the <strong>look-ahead</strong> feature is <strong>verified</strong>. That is to say if there is, further on, in the <strong>same</strong> line, a <strong><code>=</code></strong> sign, followed by some <strong>standard</strong> characters, which <strong>ends</strong> the current line. As this <strong>condition</strong> is, by construction, always <strong>true</strong>, the part <strong>after</strong> the <strong><code>=</code></strong> sign is, thus, stored as <strong>group <code>1</code></strong></p>
</li>
</ul>
<p dir="auto">As soon as the <strong><code>=</code></strong> <strong>location</strong> is reached, by the regex engine, no more <strong><code>=</code></strong> sign can be found, <strong>afterwards</strong>. So, the <strong>first</strong> alternative <strong>cannot</strong> be matched, anymore, in <strong>current</strong> line !</p>
<ul>
<li>
<p dir="auto">But, now, the <strong>second</strong> alternative <strong><code>=.+</code></strong> matches all the <strong>end</strong> of line, <strong>beginning</strong> with the <strong><code>=</code></strong> sign</p>
</li>
<li>
<p dir="auto">In <strong>replacement</strong>, <strong><code>?1\1</code></strong> is a <strong>conditional</strong> structure, which means :</p>
<ul>
<li>
<p dir="auto">If <strong>group <code>1</code></strong> exists, we replace the string <strong>Appraise</strong> with the contents of <strong>group <code>1</code></strong></p>
</li>
<li>
<p dir="auto">If <strong>group <code>1</code></strong> does <strong>not</strong> exist, we do <strong>not</strong> rewrite anything. So, the range of characters <strong>beginning</strong> with the <strong><code>=</code></strong> sign till the <strong>end</strong> of current line, is <strong>deleted</strong></p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Et voilà !</p>
<p dir="auto">Cheers</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33082</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33082</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 20 Jun 2018 14:31:31 GMT</pubDate></item><item><title><![CDATA[Reply to How to batch out lines of code with same code but different variables? on Fri, 15 Jun 2018 21:50:01 GMT]]></title><description><![CDATA[<p dir="auto">Thank you for the offer, but using what you have provided me is all I currently need. But if you can explain how it works it would be appreciated!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33014</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33014</guid><dc:creator><![CDATA[Shadowfire Omega]]></dc:creator><pubDate>Fri, 15 Jun 2018 21:50:01 GMT</pubDate></item><item><title><![CDATA[Reply to How to batch out lines of code with same code but different variables? on Mon, 11 Jun 2018 00:43:06 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/shadowfire-omega" aria-label="Profile: shadowfire-omega">@<bdi>shadowfire-omega</bdi></a>,</p>
<p dir="auto">Just explain me the <strong>various</strong> operations that you need to perform, and maybe, <strong>some</strong> of them could be <strong>gathered</strong> in a same <strong>regex</strong> S/R ;-))</p>
<p dir="auto">And, of course, I don’t mind explain my <strong>previous</strong> regex , if you would like to !</p>
<p dir="auto">See you later,</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32931</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32931</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 11 Jun 2018 00:43:06 GMT</pubDate></item><item><title><![CDATA[Reply to How to batch out lines of code with same code but different variables? on Sun, 10 Jun 2018 23:46:13 GMT]]></title><description><![CDATA[<p dir="auto">Works like a charm! Already did the long way, but still have at least 10 more operations like this to deal with for this framework, so thank you big time!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32930</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32930</guid><dc:creator><![CDATA[Shadowfire Omega]]></dc:creator><pubDate>Sun, 10 Jun 2018 23:46:13 GMT</pubDate></item><item><title><![CDATA[Reply to How to batch out lines of code with same code but different variables? on Sun, 10 Jun 2018 13:11:44 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/shadowfire-omega" aria-label="Profile: shadowfire-omega">@<bdi>shadowfire-omega</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Again, with a <strong>S/R</strong> using <strong>regular expressions</strong>, there’s a solution ;-))</p>
<ul>
<li>
<p dir="auto">Organize all the <strong>names</strong> of the variables as a <strong>list</strong>, one <strong>per</strong> line, beginning with a <strong>separator</strong> character, <strong>not already</strong> used in your text ( For instance, the <strong><code>#</code></strong>, the <strong><code>=</code></strong> or the <strong><code>@</code></strong> symbol )</p>
<ul>
<li>Choosing the <strong>equal</strong> sign as a <strong>separator</strong>, here is, below, a sample list of <strong><code>8</code></strong>  names :</li>
</ul>
</li>
</ul>
<pre><code class="language-diff">=Appraise
=Bluff
=Concentration
=Test
=Shadowfire
=Omega
=OK
=The End
</code></pre>
<ul>
<li>
<p dir="auto">Then, using the <strong>column mode</strong> ( or <strong>rectangular</strong> selection ), <strong>copy</strong> the selection of names in the <strong>clipboard</strong></p>
</li>
<li>
<p dir="auto">Now, recopy, with the <strong><code>Ctrl + D</code></strong> command, the <strong>first</strong> line which is to be changed, as <strong>many times</strong>, than the number of lines of the <strong>previous</strong> list ( <strong><code>8</code></strong> ), as a <strong>template</strong>, giving :</p>
</li>
</ul>
<pre><code class="language-diff">"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"
</code></pre>
<ul>
<li>Then, placing the cursor at the <strong>end</strong> of the <strong>first</strong> line, simply, <strong>paste</strong> the <strong>rectangular</strong> selection. You should obtain the following list :</li>
</ul>
<pre><code class="language-diff">"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Appraise
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Bluff
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Concentration
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Test
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Shadowfire
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=Omega
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=OK
"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"=The End
</code></pre>
<ul>
<li>
<p dir="auto">Finally, open the <strong><code>Replace</code></strong> panel ( <strong><code>Ctrl + H</code></strong> )</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search mode</p>
</li>
<li>
<p dir="auto">In the <strong>Find what:</strong> and <strong>Replace with:</strong> zones, type the <strong>regexes</strong> below :</p>
</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?-is)Appraise(?=.+=(.+))|=.+</code></strong></p>
<p dir="auto">REPLACE <strong><code>?1\1</code></strong></p>
<ul>
<li>Click on the <strong>Replace</strong> button, as many <strong>times</strong> as necessary</li>
</ul>
<p dir="auto">Et voilà ! You’ll get the <strong>expected</strong> text, below :</p>
<pre><code class="language-diff">"aAppraise|0|Appraise "+Appraise+"/"eval(+mAppraise+)" "+cAppraise+"
"aBluff|0|Bluff "+Bluff+"/"eval(+mBluff+)" "+cBluff+"
"aConcentration|0|Concentration "+Concentration+"/"eval(+mConcentration+)" "+cConcentration+"
"aTest|0|Test "+Test+"/"eval(+mTest+)" "+cTest+"
"aShadowfire|0|Shadowfire "+Shadowfire+"/"eval(+mShadowfire+)" "+cShadowfire+"
"aOmega|0|Omega "+Omega+"/"eval(+mOmega+)" "+cOmega+"
"aOK|0|OK "+OK+"/"eval(+mOK+)" "+cOK+"
"aThe End|0|The End "+The End+"/"eval(+mThe End+)" "+cThe End+"
</code></pre>
<p dir="auto">By this means, you can <strong>customize</strong> any <strong>number</strong> of lines, at <strong>once</strong> !!</p>
<hr />
<p dir="auto">Of course, if you used, for instance, the <strong><code>@</code></strong> separator, instead of the <strong><code>=</code></strong> sign, you must <strong>modify</strong> the regex as below :</p>
<p dir="auto">SEARCH <strong><code>(?-is)Appraise(?=.+@(.+))|@.+</code></strong></p>
<p dir="auto">And if you used the <strong><code>#</code></strong> symbol, the search regex is <strong>changed</strong> into :</p>
<p dir="auto">SEARCH <strong><code>(?-is)Appraise(?=.+#(.+))|#.+</code></strong></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32921</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32921</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 10 Jun 2018 13:11:44 GMT</pubDate></item></channel></rss>