<?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[Status bar to display selected word count]]></title><description><![CDATA[<p dir="auto">Continuation to:</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/topic/14144/is-there-a-way-to-customize-the-status-bar-to-display-more-helpful-information">https://community.notepad-plus-plus.org/topic/14144/is-there-a-way-to-customize-the-status-bar-to-display-more-helpful-information</a></p>
<p dir="auto">I am trying to use the python script, however unable to make it work on Notepadd++ 64-bit version.</p>
<p dir="auto">I am getting below error when I select texts</p>
<pre><code class="language-Traceback">  File "C:\Users\XXX\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts\StatusBarReportingOfSelectionMatchCount.py", line 12, in SBROSMC
    editor.research(escape(editor.getSelText()), match_found)
  File "C:\Users\XXX\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts\StatusBarReportingOfSelectionMatchCount.py", line 11, in escape
    return re.sub(search_str, repl_str, s)
NameError: global name 're' is not defined</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/topic/22101/status-bar-to-display-selected-word-count</link><generator>RSS for Node</generator><lastBuildDate>Fri, 08 May 2026 08:41:11 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22101.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 Nov 2021 11:01:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Status bar to display selected word count on Tue, 09 Nov 2021 12:36:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sharkwsk" aria-label="Profile: sharkwsk">@<bdi>sharkwsk</bdi></a></p>
<p dir="auto">I took the title of this thread to mean that you wanted to count the words in the current selection, but the script counts the number of occurrences of selected text throughout the entire document.  Just pointing out the difference in my interpretation in case any future readers do the same.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/71178</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/71178</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 09 Nov 2021 12:36:29 GMT</pubDate></item><item><title><![CDATA[Reply to Status bar to display selected word count on Tue, 09 Nov 2021 00:32:29 GMT]]></title><description><![CDATA[<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: Neil-Schipper">@<bdi>Neil-Schipper</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> for your feedback.</p>
<p dir="auto">I continued with my search and was able to use the below snippet and copied directly into <a href="http://startup.py" rel="nofollow ugc">startup.py</a> script. I also set initialization to ATSTARTUP to automatically load this python script. I am not sure if its elegant, but it works</p>
<pre><code>def callback_sci_UPDATEUI(args):
        if args['updated'] &amp; UPDATE.SELECTION:
            matches = []
            if editor.getTextLength() &lt; 100000:  # don't search "big" files
                if editor.getSelections() == 1 and not editor.getSelectionEmpty():
                    try:
                        editor.research(r'\Q' + editor.getSelText() + r'\E', lambda m: matches.append(1))
                    except:
                        matches = []
            l = len(matches)
            notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, ' ' if l == 0 else '{} occurrence(s) of selected text'.format(l))
editor.callback(callback_sci_UPDATEUI, [SCINTILLANOTIFICATION.UPDATEUI])
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/71170</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/71170</guid><dc:creator><![CDATA[sharkwsk]]></dc:creator><pubDate>Tue, 09 Nov 2021 00:32:29 GMT</pubDate></item><item><title><![CDATA[Reply to Status bar to display selected word count on Mon, 08 Nov 2021 14:32:28 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/71155">Status bar to display selected word count</a>:</p>
<blockquote>
<p dir="auto">we still will likely forget the occasional import in the example scripts.)</p>
</blockquote>
<p dir="auto">Lately I’ve been testing any scripts I post here in a fresh-portable-plus-Pythonscript extract.  It helps to point out such missing things.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/71157</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/71157</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 08 Nov 2021 14:32:28 GMT</pubDate></item><item><title><![CDATA[Reply to Status bar to display selected word count on Mon, 08 Nov 2021 14:11:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sharkwsk" aria-label="Profile: sharkwsk">@<bdi>sharkwsk</bdi></a> ,</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: Neil-Schipper">@<bdi>Neil-Schipper</bdi></a> is right on.  Looking at Scott’s script from that old discussion, it is using the <code>re</code> object, so the script definitely requires <code>import re</code></p>
<p dir="auto">Many of the regulars here have customized their PythonScript <code>startup.py</code> to automatically import certain libraries, like <code>import sys</code> and <code>import re</code>, which means that we don’t have to have them in all of our individual scripts… but then we forget when publishing an individual script to help a user that they won’t necessarily have those already imported.  I think we’ve gotten better at remembering those imports over time, but four years ago was before some of those lessons-learned were taken to heart.  (And since we’re human, we still will likely forget the occasional <code>import</code> in the example scripts.)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/71155</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/71155</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 08 Nov 2021 14:11:17 GMT</pubDate></item><item><title><![CDATA[Reply to Status bar to display selected word count on Mon, 08 Nov 2021 11:36:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sharkwsk" aria-label="Profile: sharkwsk">@<bdi>sharkwsk</bdi></a> Others are probably better informed than I about the details of the code and what you’re trying to do, but that error typically shows up when a needed python package has not been imported, and so you may need to place the line <code>import re</code> before the first code block that contains <code>re.whatever()</code>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/71153</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/71153</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Mon, 08 Nov 2021 11:36:31 GMT</pubDate></item></channel></rss>