<?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[search and highlight 2 or more words with different colors]]></title><description><![CDATA[<p dir="auto">it would be very useful to search and highlight 2 or more words with different colors … especially useful in log analysis</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20620/search-and-highlight-2-or-more-words-with-different-colors</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 08:53:16 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20620.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 Jan 2021 10:39:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to search and highlight 2 or more words with different colors on Thu, 21 Jan 2021 14:29:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3182">@gstavi</a> said in <a href="/post/62090">search and highlight 2 or more words with different colors</a>:</p>
<blockquote>
<p dir="auto">In what way does this improve over right click -&gt; Style token?</p>
</blockquote>
<p dir="auto">It really doesn’t.  :-)<br />
Except that you don’t have to find an occurrence (by hand or search) of your “token” first, in order to rclick it.<br />
The script is really just a demo that someone could build something related upon.<br />
I can’t see someone typing all those “tokens” very often…</p>
<p dir="auto">It really makes way more sense to use a UDL for such a purpose (OP’s original “log analysis”).  And that was my first suggestion to OP.</p>
<p dir="auto">But everyone has their own workflow.<br />
And their own likes, dislikes, and "I want"s.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62092</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62092</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 21 Jan 2021 14:29:29 GMT</pubDate></item><item><title><![CDATA[Reply to search and highlight 2 or more words with different colors on Thu, 21 Jan 2021 13:59:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/20970">@Alberto-Bongiorni</a> said in <a href="/post/62049">search and highlight 2 or more words with different colors</a>:</p>
<blockquote>
<p dir="auto">it would be very useful to search and highlight 2 or more words with different colors … especially useful in log analysis</p>
</blockquote>
<p dir="auto">In what way does this improve over right click -&gt; Style token?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62090</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62090</guid><dc:creator><![CDATA[gstavi]]></dc:creator><pubDate>Thu, 21 Jan 2021 13:59:35 GMT</pubDate></item><item><title><![CDATA[Reply to search and highlight 2 or more words with different colors on Thu, 21 Jan 2021 13:15:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/20970">@Alberto-Bongiorni</a> said in <a href="/post/62086">search and highlight 2 or more words with different colors</a>:</p>
<blockquote>
<p dir="auto">can I change the background color depending on the position of the search term? For example 1st blue term, 2nd yellow term</p>
</blockquote>
<p dir="auto">Not sure what you mean by that, in context of how the script works.<br />
Can you re-ask that question with a concrete example?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62089</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62089</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 21 Jan 2021 13:15:02 GMT</pubDate></item><item><title><![CDATA[Reply to search and highlight 2 or more words with different colors on Thu, 21 Jan 2021 14:13:49 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/20970">@alberto-bongiorni</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> and <strong>All</strong>,</p>
<p dir="auto">Thanks again, <strong>Alan</strong> for this <strong>new</strong> script ! After some testing ,I preferred to use the <strong>regex</strong> mode. So I simply changed the line :</p>
<pre><code class="language-py">            editor.search(inp, lambda m: matches.append(m.span(0)))
</code></pre>
<p dir="auto">by the line</p>
<pre><code class="language-py">            editor.research(inp, lambda m: matches.append(m.span(0)))
</code></pre>
<p dir="auto">This modification provides <strong>two</strong> advantages :</p>
<ul>
<li>
<p dir="auto">Firstly, we can <strong>simulate</strong> the <strong><code>Match whole word only</code></strong> and <strong><code>Match case</code></strong> options of the <strong>Find/Replace/Find in Files/Mark</strong> dialogs. For instance :</p>
<ul>
<li>
<p dir="auto"><strong><code>Program</code></strong> will mark this string, with this <strong>exact</strong> case ( <strong>Default</strong> case )</p>
</li>
<li>
<p dir="auto"><strong><code>(?i)Program</code></strong> will mark this string, <strong>wahtever</strong> its case</p>
</li>
<li>
<p dir="auto"><strong><code>\bProgram\b</code></strong> will mark this <strong>word</strong>, with this <strong>exact</strong> case</p>
</li>
<li>
<p dir="auto"><strong><code>(?i)\bProgram\b</code></strong> will mark this <strong>word</strong>, <strong>whatever</strong> its case</p>
</li>
</ul>
</li>
<li>
<p dir="auto">Secondly, it allows us to mark areas of <strong>differents</strong> lengths ! Test, against the well-known <strong><code>license.txt</code></strong> file, the <strong>two</strong> regexes below :</p>
<ul>
<li>
<p dir="auto"><strong><code>b.*q</code></strong></p>
</li>
<li>
<p dir="auto"><strong><code>(?s)b.*q</code></strong></p>
</li>
</ul>
</li>
</ul>
<p dir="auto"><strong>Nice</strong>, as this kind of marking is <strong>impossible</strong> with the <strong><code>Search &gt; Mark All &gt;....</code></strong> <strong>native</strong> N++ options ;-))</p>
<hr />
<p dir="auto">One more <strong>tip</strong> :</p>
<p dir="auto">If you use a <strong>same</strong> expression for <strong>two</strong> or <strong>more</strong> styles, you can mark these expressions with the <strong>blend</strong> of all the styles involved ! For instance, the picture, below, shows the <strong>default</strong> style colors and the blend of <strong>two</strong> styles :</p>
<p dir="auto"><img src="/assets/uploads/files/1611234865275-f56816eb-3c69-489b-8fef-012f57c9c4b1-image.png" alt="f56816eb-3c69-489b-8fef-012f57c9c4b1-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">In the picture below, I added the <strong>combinations</strong> with <strong><code>3</code></strong> styles !</p>
<p dir="auto"><img src="/assets/uploads/files/1611238340150-d6001d87-6c32-46ac-8d39-970afc0b3c34-image.png" alt="d6001d87-6c32-46ac-8d39-970afc0b3c34-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/62088</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62088</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 21 Jan 2021 14:13:49 GMT</pubDate></item><item><title><![CDATA[Reply to search and highlight 2 or more words with different colors on Thu, 21 Jan 2021 09:28:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> said in <a href="/post/62072">search and highlight 2 or more words with different colors</a>:</p>
<blockquote>
<h1>-<em>- coding: utf-8 -</em>-</h1>
<p dir="auto">from Npp import editor, notepad</p>
<p dir="auto">for indic in [25, 24, 23, 22, 21]:<br />
user_input = notepad.prompt(‘\r\nEnter comma separated terms to show in Style #{}:’.format(25 - indic + 1), ‘’, ‘’)<br />
if user_input == None: break<br />
if len(user_input) &gt; 0:<br />
input_list = user_input.split(‘,’)<br />
for inp in input_list:<br />
matches = []<br />
editor.search(inp, lambda m: matches.append(m.span(0)))<br />
for m in matches:<br />
editor.setIndicatorCurrent(indic)<br />
editor.indicatorFillRange(m[0], m[1] - m[0])</p>
</blockquote>
<p dir="auto">thanks, it’s almost perfect, can I change the background color depending on the position of the search term? For example 1st blue term, 2nd yellow term etc … ?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62086</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62086</guid><dc:creator><![CDATA[Alberto Bongiorni]]></dc:creator><pubDate>Thu, 21 Jan 2021 09:28:49 GMT</pubDate></item><item><title><![CDATA[Reply to search and highlight 2 or more words with different colors on Wed, 20 Jan 2021 19:12:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/20970">@Alberto-Bongiorni</a></p>
<p dir="auto">Here’s a little Pythonscript demo of the functionality:</p>
<pre><code class="language-z"># -*- coding: utf-8 -*-

from Npp import editor, notepad

for indic in [25, 24, 23, 22, 21]:
    user_input = notepad.prompt('\r\nEnter comma separated terms to show in Style #{}:'.format(25 - indic + 1), '', '')
    if user_input == None: break
    if len(user_input) &gt; 0:
        input_list = user_input.split(',')
        for inp in input_list:
            matches = []
            editor.search(inp, lambda m: matches.append(m.span(0)))
            for m in matches:
                editor.setIndicatorCurrent(indic)
                editor.indicatorFillRange(m[0], m[1] - m[0])
</code></pre>
<p dir="auto">Some nice instructions for how to acquire the Pythonscript plugin and set up a script are found <a href="https://community.notepad-plus-plus.org/post/62027">HERE</a>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62072</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62072</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 20 Jan 2021 19:12:48 GMT</pubDate></item><item><title><![CDATA[Reply to search and highlight 2 or more words with different colors on Wed, 20 Jan 2021 16:43:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> said in <a href="/post/62066">search and highlight 2 or more words with different colors</a>:</p>
<blockquote>
<p dir="auto">Another thought is that something could be scripted for this if you’re willing to use a scripting plugin, e.g. Pythonscript.<br />
Let us know what you think about that.</p>
</blockquote>
<p dir="auto">Sounds like a great idea to me. If anyone can realize it I would appreciate it, otherwise where can I learn how to write a python plugin for notepad ++?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62067</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62067</guid><dc:creator><![CDATA[Alberto Bongiorni]]></dc:creator><pubDate>Wed, 20 Jan 2021 16:43:29 GMT</pubDate></item><item><title><![CDATA[Reply to search and highlight 2 or more words with different colors on Wed, 20 Jan 2021 16:02:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/20970">@Alberto-Bongiorni</a></p>
<p dir="auto">Another thought is that something could be scripted for this if you’re willing to use a scripting plugin, e.g. Pythonscript.<br />
Let us know what you think about that.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62066</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62066</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 20 Jan 2021 16:02:47 GMT</pubDate></item><item><title><![CDATA[Reply to search and highlight 2 or more words with different colors on Wed, 20 Jan 2021 15:46:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/20970">@Alberto-Bongiorni</a> said in <a href="/post/62063">search and highlight 2 or more words with different colors</a>:</p>
<blockquote>
<p dir="auto">If instead there was a dialog that allows you to specify 3-5 terms and highlight each with a color, that would be great!</p>
</blockquote>
<p dir="auto">Probably the closest you can get to this is putting your caret on a term and then invoking <em>Search</em> menu &gt; <em>Mark All</em> &gt; and selecting a color.  You could assign a keycombo to that so that it is faster than mousing around in the menus (for the coloring part).</p>
<p dir="auto">You could “macroize” the whole thing, but that would require having your terms “fixed”, which it doesn’t sound like something you want to have.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62064</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62064</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 20 Jan 2021 15:46:44 GMT</pubDate></item><item><title><![CDATA[Reply to search and highlight 2 or more words with different colors on Wed, 20 Jan 2021 15:40:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a><br />
Thanks Alan,<br />
but I would like to have a dynamic search tool such as a non-language specific find.<br />
With your solution I should create a specific language for each type of analysis.<br />
If instead there was a dialog that allows you to specify 3-5 terms and highlight each with a color, that would be great!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62063</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62063</guid><dc:creator><![CDATA[Alberto Bongiorni]]></dc:creator><pubDate>Wed, 20 Jan 2021 15:40:24 GMT</pubDate></item><item><title><![CDATA[Reply to search and highlight 2 or more words with different colors on Wed, 20 Jan 2021 12:42:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/20970">@Alberto-Bongiorni</a></p>
<p dir="auto">Maybe you wanna look into User Defined Language (UDL) setup for your log-analysis needs, as it can “color” such things very well.  If you choose to look into it and need help, feel free to post back here.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62053</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62053</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 20 Jan 2021 12:42:08 GMT</pubDate></item></channel></rss>