<?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 replace multiple &quot;variables&quot; vs a template]]></title><description><![CDATA[<p dir="auto">I’ve a certain configuration template i have to replicate N times where N is the number of lines in a file replacing certain “words” with the ones present in the source line, a sort of mail merge I’d like to obtain in NPP… Hope the example is more clear:<br />
Template text/file:</p>
<pre><code>conf conf %VAR1% conf
conf  %VAR1% conf %VAR1%
conf conf %VAR1% conf conf %VAR2%
conf %VAR2%
</code></pre>
<p dir="auto">file with list of variables:</p>
<pre><code>*var1*,*var2*
*test,*merge*
*mail*,*MERGE*
</code></pre>
<p dir="auto">desired result:</p>
<pre><code>conf conf *var1* conf
conf  *var1* conf *var1*
conf conf *var1* conf conf *var2*
conf *var2*
conf conf *test* conf
conf  *test* conf *test*
conf conf *test* conf conf *merge*
conf *merge*
conf conf *mail* conf
conf  *mail* conf *mail*
conf conf *mail* conf conf *MERGE*
conf *MERGE*
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/topic/22666/how-to-replace-multiple-variables-vs-a-template</link><generator>RSS for Node</generator><lastBuildDate>Fri, 12 Jun 2026 08:49:44 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22666.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 Mar 2022 14:04:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to replace multiple &quot;variables&quot; vs a template on Fri, 04 Mar 2022 18:01:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: michael-vincent">@<bdi>michael-vincent</bdi></a> said in <a href="/post/74919">How to replace multiple "variables" vs a template</a>:</p>
<blockquote>
<p dir="auto">conf\nconf</p>
</blockquote>
<p dir="auto">And you’d want to be careful about what <em>type</em> of “newlines” you put in; specifically on Windows you are likely to want <code>\r\n</code> instead of <code>\n</code>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/74920</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/74920</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 04 Mar 2022 18:01:31 GMT</pubDate></item><item><title><![CDATA[Reply to How to replace multiple &quot;variables&quot; vs a template on Fri, 04 Mar 2022 17:35:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a> said in <a href="/post/74840">How to replace multiple "variables" vs a template</a>:</p>
<blockquote>
<p dir="auto">I think that does what you want.</p>
</blockquote>
<p dir="auto">You <em>could</em> do this with Notepad++ regular expression Find/Replace, you just need to put the newlines in the “Replace” text box:</p>
<pre><code>conf conf $1 conf\nconf $1 conf $1\nconf conf $1 conf conf $2\nconf $2
</code></pre>
<p dir="auto">In case you don’t want (or can’t install) the plugin.  The plugin text box does make it much more obvious, intuitive, visually appealing for the multi-line search and replace.</p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/74919</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/74919</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Fri, 04 Mar 2022 17:35:43 GMT</pubDate></item><item><title><![CDATA[Reply to How to replace multiple &quot;variables&quot; vs a template on Thu, 03 Mar 2022 18:16:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/andrea-zaccheroni" aria-label="Profile: andrea-zaccheroni">@<bdi>andrea-zaccheroni</bdi></a> ,</p>
<p dir="auto">Normally I would say that mail merge is something that should be done with a purpose-built tool (and I’m surprised no one has written a mailmerge plugin, that I can find, for Notepad++).  But your example is easy enough (and since you went to the trouble to actually present your question with the data marked up, I am happy to help).</p>
<p dir="auto">I was recently reminded of the ToolBucket plugin (<strong>Plugins &gt; Plugins Admin</strong>, checkmark <code>ToolBucket</code>, and <strong>Install</strong>), which has a multi-line FIND and REPLACE box, which makes search/replace like this much easier.</p>
<ol>
<li>active file =<pre><code>*var1*,*var2*
*test,*merge*
*mail*,*MERGE*
PETER,JONES
</code></pre>
</li>
<li><strong>Plugins &gt; ToolBucket &gt; Multiline Find and Replace</strong></li>
<li>FIND = <code>(?-s)^(.*?),(.*)$</code></li>
<li>REPLACE =<pre><code>conf conf $1 conf
conf $1 conf $1
conf conf $1 conf conf $2
conf $2
</code></pre>
(you can just copy that from the forum and paste it in the box)</li>
<li>checkmark the “Use regular expression” checkbox</li>
<li><strong>Replace</strong> and/or <strong>Replace All</strong><br />
<img src="/assets/uploads/files/1646329959227-112a4e5c-9d27-4815-b243-d3bedafd209a-image.png" alt="112a4e5c-9d27-4815-b243-d3bedafd209a-image.png" class=" img-fluid img-markdown" /> 7. With my example, the results were<pre><code>conf conf *var1* conf
conf *var1* conf *var1*
conf conf *var1* conf conf *var2*
conf *var2*
conf conf *test conf
conf *test conf *test
conf conf *test conf conf *merge*
conf *merge*
conf conf *mail* conf
conf *mail* conf *mail*
conf conf *mail* conf conf *MERGE*
conf *MERGE*
conf conf PETER conf
conf PETER conf PETER
conf conf PETER conf conf JONES
conf JONES
</code></pre>
</li>
</ol>
<p dir="auto">I think that does what you want.</p>
<p dir="auto">-—</p>
<h3>Useful References</h3>
<ul>
<li><a href="https://community.notepad-plus-plus.org/topic/21965/please-read-before-posting">Please Read Before Posting</a></li>
<li><a href="https://community.notepad-plus-plus.org/topic/22022/template-for-search-replace-questions">Template for Search/Replace Questions</a></li>
<li><a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regular-expressions-regex-documentation">FAQ: Where to find regular expressions (regex) documentation</a></li>
<li><a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">Notepad++ Online User Manual: Searching/Regex</a></li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/74840</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/74840</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 03 Mar 2022 18:16:43 GMT</pubDate></item></channel></rss>