<?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[Automatic selection of ALL instances of a searched string, in one go]]></title><description><![CDATA[<p dir="auto">Hello, <strong>All</strong>,</p>
<p dir="auto">Here is a simple <strong><code>Python</code></strong> script with <strong>automatically</strong> select <strong>all</strong> instances of a <strong>searched</strong> zone ! It comes from this <strong>initial</strong> <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: scott-sumner">@<bdi>scott-sumner</bdi></a> script, at the location :</p>
<p dir="auto"><a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8203#issuecomment-624124396" rel="nofollow ugc">https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8203#issuecomment-624124396</a></p>
<pre><code class="language-py"># -*- coding: utf-8 -*-

#  Refer to :  https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8203#issuecomment-624124396 ( from @sasumner )

import re
from Npp import editor, notepad

sel_start = editor.getSelectionStart()
sel_end   = editor.getSelectionEnd()

selected = sel_end - sel_start

user_search = notepad.prompt('Use ?(i) if INSENSITIVE search and / or SURROUND with \\b for a WHOLE WORD search', 'Enter the REGEX to search for, on existing STREAM selection :', '(?i)')

if user_search != None and len(user_search) &gt; 0 and selected &gt; 50:  #  For TINY selections this script is USELESS !

    span_match_list = []

    editor.research(user_search, lambda m: span_match_list.append(m.span(0)), 0, sel_start, sel_end)

    if len(span_match_list) &gt; 0:

        if not editor.getMultipleSelection(): editor.setMultipleSelection(True)  #  If NOT enabled in 'Preferences... &gt; Editing'
        
        first = True

        print len(span_match_list)

        for m in span_match_list:

            if first:
                editor.setSelection(m[1], m[0])
                first = False
            else:
                editor.addSelection(m[1], m[0])
</code></pre>
<hr />
<p dir="auto">To use that script, follow these <strong>steps</strong> :</p>
<ul>
<li>
<p dir="auto"><strong>Click</strong> or <strong>open</strong> the document to search for</p>
</li>
<li>
<p dir="auto">Do any <strong>stream</strong> selection, of more than <strong>fifty</strong> chars, within the <strong>current</strong> document</p>
</li>
<li>
<p dir="auto"><strong>Run</strong> the above <strong><code>Python</code></strong> script</p>
</li>
<li>
<p dir="auto"><strong>Choose</strong> the <strong><code>regex</code></strong> string to search for</p>
</li>
<li>
<p dir="auto"><strong>Click</strong> on the <strong><code>OK</code></strong> button and enjoy !</p>
</li>
</ul>
<hr />
<p dir="auto">For instance, let’s use this <em>EXAMPLE</em> text below :</p>
<pre><code class="language-diff">This is a simple test
This is a simple test
This is a simple test
This is a simple test
This is a simple test

This is a simple test
  This is a simple test
    This is a simple test
      This is a simple test
        This is a simple test
          This is a simple test
            This is a simple test
              This is a simple test
                This is a simple test
                  This is a simple test

This is a simple test
This is a simple test
This is a simple test
This is a simple test
This is a simple test
</code></pre>
<ul>
<li>
<p dir="auto">Select the <strong><code>10</code></strong>  <strong>middle</strong> lines, which are <strong>shifted</strong> by two postions</p>
</li>
<li>
<p dir="auto">Run the above script</p>
</li>
<li>
<p dir="auto">Type in the string <strong><code>simple</code></strong></p>
</li>
<li>
<p dir="auto">Click on the <strong><code>OK</code></strong> button</p>
</li>
</ul>
<p dir="auto">=&gt; At once, the <strong>ten</strong> words <strong><code>simple</code></strong> of the <strong>initial</strong> selection are now selected <strong>individually</strong>. This means that you may <strong>delete</strong> them, <strong>add</strong> some text <strong>before</strong> or <strong>after</strong> or even hit the <strong><code>Enter</code></strong> key !</p>
<p dir="auto">Note  that I used, on <strong>purpose</strong>, <strong>shifted</strong> lines to prevent using any <strong><code>rectangular</code></strong> selection !</p>
<hr />
<p dir="auto">As you see, that’s quite easy :</p>
<ul>
<li>
<p dir="auto">Choose a document</p>
</li>
<li>
<p dir="auto">Make a <strong>pre-selection</strong></p>
</li>
<li>
<p dir="auto">Run the script</p>
</li>
</ul>
<p dir="auto">Moreover, as the script asks you for a <strong><code>regex</code></strong> string, you can, <strong>practically</strong>, search for nearly anything ! Of course, <strong>simple</strong> strings are also allowed with the possible <strong>additionnal</strong> zones <strong><code>(?i)</code></strong> and/or <strong><code>\b</code></strong>. For instance :</p>
<ul>
<li>
<p dir="auto">You may search for the string <strong><code>the</code></strong>, <strong>whatever</strong> its case , typing in the string <strong><code>(?i)the</code></strong></p>
</li>
<li>
<p dir="auto">You may search for the <strong>whole word</strong> <strong><code>the</code></strong>, with this <strong>case</strong>, typing in <strong><code>\bthe\b</code></strong></p>
</li>
</ul>
<p dir="auto">But these examples are also correct :</p>
<ul>
<li>
<p dir="auto">You may search for <strong>smallest</strong> ranges of text between <strong>two</strong> lowercase letters <strong><code>t</code></strong>, typing in the string <strong><code>t.*?t</code></strong></p>
</li>
<li>
<p dir="auto">You may search for any <strong>multi</strong>-lignes zones, <strong>beginning</strong> with <strong><code>&lt;td</code></strong> and <strong>ending</strong> with <strong><code>&lt;/td&gt;</code></strong>, typing in the string <strong><code>(?s)&lt;td.+?&lt;/td&gt;</code></strong></p>
</li>
</ul>
<hr />
<p dir="auto">Let’s go back to the <strong>initial</strong> example :</p>
<pre><code class="language-diff">This is a simple test
This is a simple test
This is a simple test
This is a simple test
This is a simple test

This is a simple test
  This is a simple test
    This is a simple test
      This is a simple test
        This is a simple test
          This is a simple test
            This is a simple test
              This is a simple test
                This is a simple test
                  This is a simple test

This is a simple test
This is a simple test
This is a simple test
This is a simple test
This is a simple test
</code></pre>
<p dir="auto">Of course, if we want to replace the text <strong><code>simple test</code></strong> with <strong><code>very simple text to do</code></strong> in the <strong>shifted</strong> lines only, just use the <strong>Replace</strong> dialog and click on the <strong><code>In selection</code></strong> option</p>
<p dir="auto">Now, we can also use the <strong><code>Python</code></strong> script :</p>
<ul>
<li>
<p dir="auto">Do a <strong>normal</strong> selection of the <strong><code>10</code></strong> shifted lines</p>
</li>
<li>
<p dir="auto">Run the <strong><code>Python</code></strong> script</p>
</li>
<li>
<p dir="auto">Enter the string <strong><code>simple</code></strong></p>
</li>
<li>
<p dir="auto">Click on the <strong><code>OK</code></strong> button</p>
</li>
<li>
<p dir="auto">Then, hit the <strong><code>Left arrow</code></strong>  key</p>
</li>
<li>
<p dir="auto">Type in the string <strong><code>very</code></strong>, followed with a <strong><code>space</code></strong> char</p>
</li>
<li>
<p dir="auto">Hit the <strong><code>End</code></strong>  key</p>
</li>
<li>
<p dir="auto">Type in a <strong><code>space</code></strong> char followed with the string <strong><code>to do</code></strong></p>
</li>
</ul>
<hr />
<p dir="auto">A <strong>last</strong> test :</p>
<ul>
<li>
<p dir="auto">As before, select the <strong><code>10</code></strong> <strong>shifted</strong> lines</p>
</li>
<li>
<p dir="auto">Open the <strong>Mark</strong> dialog</p>
</li>
<li>
<p dir="auto">Type in the string <strong><code>simple</code></strong> in the <strong>Find what :</strong> zone</p>
</li>
<li>
<p dir="auto"><strong>Uncheck</strong> all <strong>box</strong> options</p>
</li>
<li>
<p dir="auto"><strong>Check</strong> the <strong><code>In selection</code></strong> box</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Mark All</code></strong> button</p>
</li>
</ul>
<p dir="auto">=&gt; <strong>Ten</strong> <strong><code>red</code></strong> marked zones appear in the <strong>selection</strong></p>
<ul>
<li>
<p dir="auto">Close the <strong>Mark</strong> dialog with the <strong><code>ESC</code></strong> key</p>
</li>
<li>
<p dir="auto">Run the <strong><code>Python</code></strong> script</p>
</li>
<li>
<p dir="auto">Type in the string <strong><code>simple</code></strong></p>
</li>
<li>
<p dir="auto">Click on the <strong><code>OK</code></strong> button</p>
</li>
</ul>
<p dir="auto">=&gt; As you can see, the <strong>marked</strong> regions and the <strong>marked</strong> selections of the script are strictly <strong>identical</strong></p>
<hr />
<p dir="auto">So, I wonder if we should propose an <strong>enhancement</strong> of the <strong><code>Mark</code></strong> dialog, with a <strong>new</strong> box option <strong><code>Selection of the Occurrences</code></strong> or equivalent, using this mechanism ?</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> : This <strong>modified</strong> version is just a first <strong>draft</strong> of the <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: Scott-sumner">@<bdi>Scott-sumner</bdi></a> script and it could certainly be <strong>enhanced</strong> !</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/24549/automatic-selection-of-all-instances-of-a-searched-string-in-one-go</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 18:32:14 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/24549.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Jun 2023 11:12:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Thu, 19 Oct 2023 13:47:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> said in <a href="/post/89958">Automatic selection of ALL instances of a searched string, in one go</a>:</p>
<blockquote>
<p dir="auto">So, here is my updated script, that I called Automatic_Selections_AK.py</p>
</blockquote>
<p dir="auto">Oh no, the script should fully be called <code>Automatic_Selections_GT.py</code> !  :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89962</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89962</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 19 Oct 2023 13:47:54 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Thu, 19 Oct 2023 13:31:30 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">In my <strong>modified</strong> script of my <strong>previous</strong> post, I added the possibility to choose a <strong>single</strong> stream selection and select, by <strong>default</strong>, <strong>all</strong> the file contents as the <strong>scope</strong> of the search</p>
<p dir="auto">I <strong>slightly</strong> improved it : <em>IF NO</em> selection at all is done, it will select the <strong>current</strong> word under the <strong>caret</strong> and will search for this word, <strong>throughout</strong> the file contents !</p>
<p dir="auto">The <strong>concerned</strong> part is :</p>
<pre><code class="language-py">        if editor.getSelections() == 1:                                       # If an UNIQUE stream selection:

            if editor.getSelectionEmpty():                                    # Case : UNIQUE selection EMPTY =&gt; We get the START and END of current word
                sel_tup_list = []
                sel_tup_list.append( (editor.wordStartPosition(editor.getCurrentPos(), True), editor.wordEndPosition(editor.getCurrentPos(), True)) )

            sel_tup_list.append ( (0, 0) )                                    #     LEADING caret is supposed at the VERY BEGINING of current filec
            sel_tup_list.append ( (editor.getLength(), editor.getLength()) )  #     TRAILING caret is supposed at the VERY END of current file
</code></pre>
<p dir="auto">instead of :</p>
<pre><code class="language-py">        if editor.getSelections() == 1:                                       # If an UNIQUE stream selection:

            sel_tup_list.append ( (0, 0) )                                    #     LEADING caret is supposed at the VERY BEGINING of current filec
            sel_tup_list.append ( (editor.getLength(), editor.getLength()) )  #     TRAILING caret is supposed at the VERY END of current file
</code></pre>
<hr />
<p dir="auto">So, here is my <strong>updated</strong> script, that I called <strong><code>Automatic_Selections_AK.py</code></strong>, as all <strong>credits</strong> should be given to you, <strong>Alan</strong>  :</p>
<pre><code class="language-py"># -*- coding: utf-8 -*-

from __future__ import print_function

'''
MultiselectSelectedTextBetweenlEmptyCaretStoppers (MSTBECS)

An @Alan-kilborn's Python script with a @guy038 adaptation !

  Refer to :  https://community.notepad-plus-plus.org/topic/24549/automatic-selection-of-all-instances-of-a-searched-string-in-one-go/29
  
           :  https://community.notepad-plus-plus.org/topic/24549/automatic-selection-of-all-instances-of-a-searched-string-in-one-go/36

           :  https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8203#issuecomment-623136793

           :  https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8203#issuecomment-624124396 ( from @sasumner )


NEWBIES, refer to : https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript


Example :

This is a simple test
This is a simple test
This is a simple test
This is a simple test
This is a simple test

This is a simple test
  This is a simple test
    This is a simple test
      This is a simple test
        This is a simple test
          This is a simple test
            This is a simple test
              This is a simple test
                This is a simple test
                  This is a simple test

This is a simple test
This is a simple test
This is a simple test
This is a simple test
This is a simple test


THREE usages are possible :

1) Do THREE distint STREAM selections :

    - The FIRST one, WITHOUT any hit on the 'CTRL' key, of ALL the text to search for

    - An additional ZERO-LENGTH one, while holding DOWN the 'CTRL' key, to define the BEGINNING of the scope where the search process will START

    - An additional ZERO-LENGTH one, while holding DOWN the 'CTRL' key, to define the END       of the scope where the search proces  will STOP


2) Do a SINGLE stream selection ONLY, WITHOUT any hit on the 'CTRL' key, of ALL the text to search for, throughout the ENTIRE file contents


3) Do a NULL stream selection ONLY, WITHOUT any hit on the 'CTRL' key, =&gt; AUTOMATIC selection of the word under the CARET, throughout the ENTIRE file contents


Finally, run this script

'''

from Npp import *
import os
import inspect

#-----------------------------------------------------------------------------------------------------------------------------------------------------

class MSTBECS(object):

    def __init__(self):

        self.this_script_name = inspect.getframeinfo(inspect.currentframe()).filename.split(os.sep)[-1].rsplit('.', 1)[0]

        # user must make the 3 required selections in any order:

        sel_tup_list = []
        sel_tup_list.append( (editor.getSelectionNStart(0), editor.getSelectionNEnd(0)) )

        if editor.getSelections() &gt;= 2: sel_tup_list.append( (editor.getSelectionNStart(1), editor.getSelectionNEnd(1)) )
        if editor.getSelections() &gt;= 3: sel_tup_list.append( (editor.getSelectionNStart(2), editor.getSelectionNEnd(2)) )

        if editor.getSelections() == 1:                                       # If an UNIQUE stream selection:

            if editor.getSelectionEmpty():                                    # Case : UNIQUE selection EMPTY =&gt; We get the START and END of current word
                sel_tup_list = []
                sel_tup_list.append( (editor.wordStartPosition(editor.getCurrentPos(), True), editor.wordEndPosition(editor.getCurrentPos(), True)) )

            sel_tup_list.append ( (0, 0) )                                    #     LEADING caret is supposed at the VERY BEGINING of current filec
            sel_tup_list.append ( (editor.getLength(), editor.getLength()) )  #     TRAILING caret is supposed at the VERY END of current file

        sel_tup_list.sort()

        # conditions-not-correct checking:

        cnc = False
        if not cnc and not editor.getMultipleSelection(): cnc = True         # 'Multi-editing' option ENABLED in Preferences

        rect_sel_mode = editor.getSelectionMode() in [ SELECTIONMODE.RECTANGLE, SELECTIONMODE.THIN ]
        if not cnc and rect_sel_mode: cnc = True  # can't be in column-block selection mode

        if not cnc and len(sel_tup_list) != 3: cnc = True  # need THREE selections ( Actually, 2 carets and 1 selection )

        if not cnc and sel_tup_list[0][0] != sel_tup_list[0][1]: cnc = True  #  NO LEADING empty caret
        if not cnc and sel_tup_list[1][0] == sel_tup_list[1][1]: cnc = True  #  NO SELECTED text between carets
        if not cnc and sel_tup_list[2][0] != sel_tup_list[2][1]: cnc = True  #  NO TRAILING empty caret

        if cnc:

            cnc_help =\
'''
  The CONDITIONS are NOT met to run this script!
        
  You must have the "Multi-Editing Settings" option ENABLED in 'Settings &gt; Preferences &gt; Editing'
        
  And, either:

  - 1 NON-NULL stream selection ( Text ), between 2 EMPTY selections ( Carets ), which define the SCOPE of the search

  - 1 NON-NULL stream selection ( Text ), with an IMPLICITE scope of ALL the file contents

  - 1 NULL stream selection (Text ) with IMPLICIT selection of word under CARET and IMPLICITE scope of ALL the file contents

'''
            self.mb(cnc_help)
            return

        (start_search_pos, end_search_pos) = (sel_tup_list[0][0], sel_tup_list[2][0])
        search_word = editor.getTextRange(*sel_tup_list[1])
        match_span_tup_list = []

        editor.search(search_word, lambda m: match_span_tup_list.append(m.span(0)), 0, start_search_pos, end_search_pos)     #  SENSITIVE search
        #editor.search(search_word, lambda m: match_span_tup_list.append(m.span(0)), re.I, start_search_pos, end_search_pos)  #  INSENSITIVE search

        if len(match_span_tup_list) &gt; 1:
            editor.setSelection(*match_span_tup_list[0][::-1])  #  Args to 'setSelection' are CARET then ANCHOR

            for (start_match_pos, end_match_pos) in match_span_tup_list[1:]:
                editor.addSelection(end_match_pos, start_match_pos)
            self.sb_output('{} selections made'.format(len(match_span_tup_list)))

    def mb(self, msg, flags=0, title=''):  #  A MESSAGE-BOX function
        return notepad.messageBox(msg, title if title else self.this_script_name, flags)
        
    def sb_output(self, *args):  # output to N++'s STATUS bar ( will be overwritten by N++, e.g. when ACTIVE tab is changed )
        notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, ' '.join(map(str, args)))        

#-----------------------------------------------------------------------------------------------------------------------------------------------------

if __name__ == '__main__': MSTBECS()
</code></pre>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89958</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89958</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 19 Oct 2023 13:31:30 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Wed, 18 Oct 2023 20:37:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a></p>
<p dir="auto">I think it is about “different ways of working”.<br />
Each way has its advantages/disadvantages – isn’t everything like that, pretty much?<br />
Pros and cons…pros and cons…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89942</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89942</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 18 Oct 2023 20:37:37 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Thu, 19 Oct 2023 09:20:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">In you <strong>previous</strong> post, you said :</p>
<blockquote>
<p dir="auto">Again, the empty carets for scoping are there for safety in this “quick” replacement method. If you’re looking for something with wider scope, just use Notepad++ 's own Replace All functionality.</p>
</blockquote>
<p dir="auto">At the time, I felt rather <strong>silly</strong> for <strong>not</strong> having thought of it ! But, on <strong>reflection</strong>, I think we should consider these scripts as, either :</p>
<ul>
<li>
<p dir="auto">An <strong>interactive</strong> replacement in <strong>selection</strong> feature ( for our <strong>two</strong> scripts )</p>
</li>
<li>
<p dir="auto">An <strong>interactive global</strong> replacement feature ( for my <strong>derived</strong> script )</p>
</li>
</ul>
<hr />
<ul>
<li>
<p dir="auto">For example, let’s imagine this scenario :</p>
<ul>
<li>
<p dir="auto">I <strong>first</strong> decide to change any <strong><code>simple</code></strong> word with the word <strong><code>difficult</code></strong></p>
</li>
<li>
<p dir="auto">Then, I changed my mind and prefer to change the word <strong><code>difficult</code></strong> with the expression <strong><code>very difficult</code></strong></p>
</li>
<li>
<p dir="auto">Again , I changed my mind and <strong>finally</strong> decide to replace from the word <strong><code>very</code></strong> to the <strong>end</strong> of current line with the expression <strong><code>good old method</code></strong></p>
</li>
</ul>
</li>
</ul>
<hr />
<ul>
<li>
<p dir="auto">With the <strong>Replace</strong> dialog, we would do <strong><code>3</code></strong> <strong>successive</strong> regex S/R :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?-i)simple</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>difficult</code></strong></p>
</li>
<li>
<p dir="auto">SEARCH <strong><code>(?-i)difficult</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>very $0</code></strong></p>
</li>
<li>
<p dir="auto">SEARCH <strong><code>(?-si)very difficult.+</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>good old method</code></strong></p>
</li>
</ul>
</li>
</ul>
<hr />
<ul>
<li>
<p dir="auto">with our <strong>scripts</strong>, we would :</p>
<ul>
<li>
<p dir="auto">Select the word <strong><code>simple</code></strong> and, possibly, the <strong>scope</strong> of search</p>
</li>
<li>
<p dir="auto">Run the script</p>
</li>
<li>
<p dir="auto">Type in the word <strong><code>difficult</code></strong></p>
</li>
<li>
<p dir="auto">Use the <strong><code>Ctrl</code></strong> + <strong><code>Left Arrow</code></strong> shortcut</p>
</li>
<li>
<p dir="auto">Type in the word <strong><code>very</code></strong>, followed with a <strong>space</strong> char</p>
</li>
<li>
<p dir="auto">Use, again, the <strong><code>Ctrl</code></strong> + <strong><code>Left Arrow</code></strong> shortcut</p>
</li>
<li>
<p dir="auto">Use the <strong><code>Shift + End</code></strong> shortcut</p>
</li>
<li>
<p dir="auto">Finally type in the <strong><code>good old method</code></strong> expression</p>
</li>
</ul>
</li>
</ul>
<hr />
<p dir="auto">As you can see, for <strong>most</strong> of the replacements, the <strong>script</strong> way seems more <strong>intuitive</strong> than using <strong>successive</strong> replacements !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89941</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89941</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 19 Oct 2023 09:20:32 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Wed, 18 Oct 2023 14:01:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> said in <a href="/post/89939">Automatic selection of ALL instances of a searched string, in one go</a>:</p>
<blockquote>
<p dir="auto">I personally think that the logical method is :</p>
<p dir="auto">Do the stream selection of the text first, without holding down the Ctrl key</p>
<p dir="auto">Then, do the two caret zero-length selections, with the Ctrl key pressed</p>
</blockquote>
<p dir="auto">The “beauty” of the design is that you can do these 3 things in ANY order that you like.</p>
<hr />
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> said in <a href="/post/89939">Automatic selection of ALL instances of a searched string, in one go</a>:</p>
<blockquote>
<p dir="auto">If you prefer an insensitive search</p>
</blockquote>
<p dir="auto">Yes, but for the utmost in safety, I prefer a <em>sensitive</em>, i.e, match case, design.  I don’t want to have to consider it, I just want to know I am getting exactly and only what I’ve asked for.</p>
<hr />
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> said in <a href="/post/89939">Automatic selection of ALL instances of a searched string, in one go</a>:</p>
<blockquote>
<p dir="auto">…and that the scope of the search would be, automatically, the complete file contents ?</p>
</blockquote>
<p dir="auto">Again, the empty carets for scoping are there for safety in this “quick” replacement method.  If you’re looking for something with wider scope, just use Notepad++ 's own <em>Replace All</em> functionality.</p>
<hr />
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> said in <a href="/post/89939">Automatic selection of ALL instances of a searched string, in one go</a>:</p>
<blockquote>
<p dir="auto">if this is the best formulation</p>
</blockquote>
<p dir="auto">It seems reasonable to me! :-)<br />
There’s rarely one and only one best way with a block of code…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89940</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89940</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 18 Oct 2023 14:01:34 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Wed, 18 Oct 2023 16:20:04 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Ah… yes, your proposed script is quite <strong>clever</strong> and very <strong>intuitive</strong> ;-)) I didn’t think about <strong>invisible</strong> caret boundaries for the <strong>defined</strong> scope</p>
<p dir="auto">Remark that, at <strong>first</strong> glance, I thought that the <strong>carets</strong> did represent the true <strong><code>|</code></strong> character ( with code <strong><code>\x7C</code></strong> ). But, thanks to the <strong>error</strong> message, I quickly understood the problem !</p>
<p dir="auto">I personally think that the <strong>logical</strong> method is :</p>
<ul>
<li>
<p dir="auto">Do the <strong>stream</strong> selection of the text <strong>first</strong>, <strong>without</strong> holding down the <strong><code>Ctrl</code></strong> key</p>
</li>
<li>
<p dir="auto">Then, do the <strong>two</strong> caret <strong><code>zero-length</code></strong> selections, with the <strong><code>Ctrl</code></strong> key <strong>pressed</strong></p>
</li>
</ul>
<hr />
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>If you prefer an <strong>insensitive</strong> search, simply add the <strong><code>import re</code></strong> command, below the <strong><code>import inspect</code></strong> one and change the line :</li>
</ul>
<pre><code class="language-py">editor.search(search_word, lambda m: match_span_tup_list.append(m.span(0)), 0, start_search_pos, end_search_pos)  #  SENSITIVE search
</code></pre>
<p dir="auto">As :</p>
<pre><code>editor.search(search_word, lambda m: match_span_tup_list.append(m.span(0)), re.I, start_search_pos, end_search_pos)  #  INSENSITIVE search
</code></pre>
<hr />
<ul>
<li>
<p dir="auto">Now, I also found out a <strong>trick</strong> to simulate a <strong>whole-word</strong> search  :</p>
<ul>
<li>
<p dir="auto">Do a <strong>stream</strong> selection of the word, <strong>including</strong> its surrounding <strong><code>space</code></strong> chars</p>
</li>
<li>
<p dir="auto">Do the <strong>two</strong> caret selections</p>
</li>
<li>
<p dir="auto">Run the script</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Right arrow</code></strong> key</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Left arrow</code></strong> key</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Ctrl</code></strong> + <strong><code>Left arrow</code></strong> shortcut</p>
</li>
</ul>
</li>
</ul>
<hr />
<p dir="auto">Playing around with your script, after a while, I asked myself :</p>
<p dir="auto">Could it be possible to just do the <strong>text</strong> selection and that the <strong>scope</strong> of the search would be, <strong>automatically</strong>, the <strong>complete</strong> file contents ?</p>
<p dir="auto">After some tries, I ended up with this <strong>modified</strong> part of the script which, indeed, does the job !</p>
<pre><code class="language-py">        sel_tup_list = []
        sel_tup_list.append( (editor.getSelectionNStart(0), editor.getSelectionNEnd(0)) )
        if editor.getSelections() &gt;= 2: sel_tup_list.append( (editor.getSelectionNStart(1), editor.getSelectionNEnd(1)) )
        if editor.getSelections() &gt;= 3: sel_tup_list.append( (editor.getSelectionNStart(2), editor.getSelectionNEnd(2)) )
        if editor.getSelections() == 1:                                          # If an unique stream selection:
            sel_tup_list.append ( (0, 0) )                                       #     Leading caret is supposed to be at the very begining of current filec
            sel_tup_list.append ( (editor.getLength(), editor.getLength()) )     #     Trailing caret is supposed to be at the very end of current file
        sel_tup_list.sort()
</code></pre>
<p dir="auto">instead of :</p>
<pre><code class="language-py">        sel_tup_list = []
        sel_tup_list.append( (editor.getSelectionNStart(0), editor.getSelectionNEnd(0)) )
        if editor.getSelections() &gt;= 2: sel_tup_list.append( (editor.getSelectionNStart(1), editor.getSelectionNEnd(1)) )
        if editor.getSelections() &gt;= 3: sel_tup_list.append( (editor.getSelectionNStart(2), editor.getSelectionNEnd(2)) )
        sel_tup_list.sort()
</code></pre>
<p dir="auto">Now, although this modification seems quite <strong>functional</strong>, I would like to know, <strong>Alan</strong>, if this is the <strong>best</strong> formulation !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto">A <strong>last</strong> observation :</p>
<p dir="auto">If you do the <strong>three</strong> needed selections, in <strong>any</strong> order and that you decide to add <strong>additional</strong> selections ( either <strong>non-null</strong> text or <strong>null</strong> caret selections ), <strong>no</strong> error message is displayed : these <strong>additional</strong> selections are simply <strong>ignored</strong>. To my mind, it’s the <strong>best</strong> way to proceed !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89939</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89939</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 18 Oct 2023 16:20:04 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sun, 15 Oct 2023 15:21:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mark-olson" aria-label="Profile: Mark-Olson">@<bdi>Mark-Olson</bdi></a></p>
<p dir="auto">I didn’t exactly forget, I just streamlined out some of my usual debug code, before posting.<br />
It appears I got too heavy with my edits. :-(</p>
<p dir="auto">I still have time to edit the script; I’ll fix it. :-)<br />
Thanks for pointing it out.</p>
<p dir="auto"><strong>EDIT</strong>: I updated the above script listing to fix the problems <a class="plugin-mentions-user plugin-mentions-a" href="/user/mark-olson" aria-label="Profile: Mark-Olson">@<bdi>Mark-Olson</bdi></a> pointed out.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89906</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89906</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 15 Oct 2023 15:21:47 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sun, 15 Oct 2023 15:03:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a><br />
Getting this error:</p>
<pre><code>Traceback (most recent call last):
  File "%AppData%\Roaming\Notepad++\plugins\Config\PythonScript\scripts\multiSelectBetweenEmptyCaretSelections.py", line 65, in &lt;module&gt;
    if __name__ == '__main__': MSTBECS()
  File "%AppData%\Roaming\Notepad++\plugins\Config\PythonScript\scripts\multiSelectBetweenEmptyCaretSelections.py", line 61, in __init__
    self.sb_output('{} selections made'.format(len(match_span_tup_list)))
AttributeError: 'MSTBECS' object has no attribute 'sb_output'
</code></pre>
<p dir="auto">Eyeballing the code, it looks like calling <code>self.mb</code> will probably cause the same problem. I guess you forgot to define those methods.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89905</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89905</guid><dc:creator><![CDATA[Mark Olson]]></dc:creator><pubDate>Sun, 15 Oct 2023 15:03:52 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sun, 15 Oct 2023 15:21:00 GMT]]></title><description><![CDATA[<p dir="auto">Here’s my entry for a script for this topic.</p>
<p dir="auto"><strong>NOTE</strong>: This is probably NOT of any use for dedicated keyboardists as there is really no way to make use of it without touching the mouse.  (Of course, the same can be said of most (but not all) “mulit-edit” operations.</p>
<p dir="auto">What it does is a “scoped multiselect”.  For myself, I find this very useful to quickly rename a poorly-named script variable in a localized section of code.  Often when I’m coding I need a variable to do something, so maybe I’ll just call it <code>zz</code> until I get its code correct, and only then will I give it a good permanent name, one that suits its (perhaps evolved) function.</p>
<p dir="auto">Anyway, to use the script, you define two empty carets (to say “only act in the range between them”) and then a non-empty selection between the empties (to define the source text to be replaced), and then you run the script.  The empty carets defining scope give me confidence that I won’t be changing text outside of my defined area.</p>
<p dir="auto">An example helps; take the original example in this thread, and set up the following two empty carets and selection, which is very quick and easy to do with the mouse (just click on line 6, ctrl+click on line 17, and ctrl+doubleclick on <code>simple</code> in line 13):</p>
<p dir="auto"><img src="/assets/uploads/files/1697371506480-f8d9f854-2964-4796-bf3b-e24da9e393bb-image.png" alt="f8d9f854-2964-4796-bf3b-e24da9e393bb-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Run the script to obtain:</p>
<p dir="auto"><img src="/assets/uploads/files/1697371850208-34852a6f-582c-42fb-a651-25b73e3e99d0-image.png" alt="34852a6f-582c-42fb-a651-25b73e3e99d0-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I bind the running of this script to a keycombo, and find this is quicker than Notepad++'s replace function when I need to rename something: No prompts and no typing to get the text I need selected; all I have to do after running the script is type the desired replacement text.</p>
<p dir="auto">I named this script the somewhat lengthy <code>MultiselectSelectedTextBetweenlEmptyCaretStoppers.py</code> and here is its listing:</p>
<pre><code class="language-py"># -*- coding: utf-8 -*-
from __future__ import print_function

#########################################
#
#  MultiselectSelectedTextBetweenlEmptyCaretStoppers (MSTBECS)
#
#########################################

# references:
#  https://community.notepad-plus-plus.org/topic/24549  &lt;-- this script posted here
#  inspiration:
#   https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8203#issuecomment-623136793
#  for newbie info on PythonScripts, see https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript

#-------------------------------------------------------------------------------

from Npp import *
import os
import inspect

#-------------------------------------------------------------------------------

class MSTBECS(object):

    def __init__(self):

        self.this_script_name = inspect.getframeinfo(inspect.currentframe()).filename.split(os.sep)[-1].rsplit('.', 1)[0]

        # user must make the 3 required selections in any order:
        sel_tup_list = []
        sel_tup_list.append( (editor.getSelectionNStart(0), editor.getSelectionNEnd(0)) )
        if editor.getSelections() &gt;= 2: sel_tup_list.append( (editor.getSelectionNStart(1), editor.getSelectionNEnd(1)) )
        if editor.getSelections() &gt;= 3: sel_tup_list.append( (editor.getSelectionNStart(2), editor.getSelectionNEnd(2)) )
        sel_tup_list.sort()

        # conditions-not-correct checking:
        cnc = False
        if not cnc and not editor.getMultipleSelection(): cnc = True  # must have "Multi-editing" enabled in Preferences
        rect_sel_mode = editor.getSelectionMode() in [ SELECTIONMODE.RECTANGLE, SELECTIONMODE.THIN ]
        if not cnc and rect_sel_mode: cnc = True  # can't be in column-block selection mode
        if not cnc and len(sel_tup_list) != 3: cnc = True  # need 3 selections (actually 2 carets and one selection)
        if not cnc and sel_tup_list[0][0] != sel_tup_list[0][1]: cnc = True  # no leading empty caret
        if not cnc and sel_tup_list[1][0] == sel_tup_list[1][1]: cnc = True  # no text selected between carets
        if not cnc and sel_tup_list[2][0] != sel_tup_list[2][1]: cnc = True  # no trailing empty caret
        if cnc:
            cnc_help = '''
            Conditions are not correct for running the script.
            You must have:
            - "Multi-Editing" enabled in Preferences
            - Two empty carets with a stream selection in between
            '''
            self.mb(cnc_help)
            return

        (start_search_pos, end_search_pos) = (sel_tup_list[0][0], sel_tup_list[2][0])
        search_word = editor.getTextRange(*sel_tup_list[1])
        match_span_tup_list = []
        editor.search(search_word, lambda m: match_span_tup_list.append(m.span(0)), 0, start_search_pos, end_search_pos)

        if len(match_span_tup_list) &gt; 1:
            editor.setSelection(*match_span_tup_list[0][::-1])  # args to setSelection are caret then anchor
            for (start_match_pos, end_match_pos) in match_span_tup_list[1:]:
                editor.addSelection(end_match_pos, start_match_pos)
            self.sb_output('{} selections made'.format(len(match_span_tup_list)))

    def mb(self, msg, flags=0, title=''):  # a message-box function
        return notepad.messageBox(msg, title if title else self.this_script_name, flags)
        
    def sb_output(self, *args):  # output to N++'s status bar (will be overwritten by N++ e.g. when active tab is changed)
        notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, ' '.join(map(str, args)))

#-------------------------------------------------------------------------------

if __name__ == '__main__': MSTBECS()
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/89899</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89899</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 15 Oct 2023 15:21:00 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Mon, 19 Jun 2023 11:31:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a></p>
<blockquote>
<blockquote>
<p dir="auto">And the big advantage to that is…?</p>
</blockquote>
</blockquote>
<blockquote>
<p dir="auto">To be able to work with multiple cursors.</p>
</blockquote>
<p dir="auto">Sure, one can just keep <em>saying</em> that over and over again, but I for one haven’t been convinced about any great usefulness gain coming from it.</p>
<p dir="auto">Of course, my opinion doesn’t matter, but if I feel that way, probably others do, too.  No idea how the author of Notepad++ feels about it, but unless someone creates a PR for it, that doesn’t matter, either.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87206</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87206</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 19 Jun 2023 11:31:58 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Mon, 19 Jun 2023 07:18:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/87175">Automatic selection of ALL instances of a searched string, in one go</a>:</p>
<blockquote>
<p dir="auto">And the big advantage to that is…?</p>
</blockquote>
<p dir="auto">To be able to work with multiple cursors.</p>
<p dir="auto">On the rest of the arguments against such a feature.<br />
I don’t think it takes a genius to figure out what “select whatever” would mean in such a case,<br />
and if it’s documented, those unfamiliar with or accustomed to the concept of “multiple cursors/carets/editors/whatever” will understand its purpose.<br />
Does this mean that all potential users are using it correctly,<br />
no, but are all users also using regexes correctly? Backup? …<br />
Someone who wants to test beforehand whether the results of his search will give only the desired result can run <code>mark</code> beforehand …<br />
Whether such an extension is implemented in the <code>find</code> tab as a checkbox,<br />
or gets its own tab or dialog, is in my opinion irrelevant for this discussion,<br />
because it is ONLY about whether Don finds it good or not.<br />
No matter what comes out of this discussion in the end,<br />
if Don has a different opinion on it, and that should be respected because it’s his project,<br />
that and only that will be the deciding factor.<br />
So, I’ve given enough mustard on this subject now, wouldn’t know what more input I could provide.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87195</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87195</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 19 Jun 2023 07:18:23 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sun, 18 Jun 2023 14:13:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/87186">Automatic selection of ALL instances of a searched string, in one go</a>:</p>
<blockquote>
<p dir="auto">Or, it could be an additional action button, not replacing an existing one that users could be used to using.</p>
</blockquote>
<p dir="auto">I had suggested replacing the button to declutter the user interface.</p>
<p dir="auto">The action would still be available but would take an extra step which is select-all-marked and then copy.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87190</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87190</guid><dc:creator><![CDATA[mkupper]]></dc:creator><pubDate>Sun, 18 Jun 2023 14:13:07 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sun, 18 Jun 2023 10:47:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mkupper" aria-label="Profile: mkupper">@<bdi>mkupper</bdi></a> said:</p>
<blockquote>
<p dir="auto">An alternative is to use marking and to add a Select Marked Text button.  This button likely could replace the Copy Marked Text button on the Mark dialog box.</p>
</blockquote>
<p dir="auto">Or, it could be an additional action button, not replacing an existing one that users could be used to using.</p>
<hr />
<blockquote>
<p dir="auto">At present, unmarking is moderately awkward but is possible. Ideally, the Mark dialog box was a little more consistent. The Mark All button marks using a combination of the search pattern…</p>
</blockquote>
<p dir="auto">So what I think you’re saying here is that it would be nice to be able to unmark text based on the <em>Find what</em> expression as well.  That makes a good deal of sense.  Maybe an additional action button could be added for this case.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87186</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87186</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 18 Jun 2023 10:47:33 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sat, 17 Jun 2023 22:16:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> ,</p>
<p dir="auto">I’m glad you did this, because I was thinking the same thing. I don’t know why his Undo didn’t work, perhaps because it was a script that did other things in addition, but whenever I do a change or search/replace, I feel it’s on me, to make sure I really want that change, as <a class="plugin-mentions-user plugin-mentions-a" href="/user/mkupper" aria-label="Profile: mkupper">@<bdi>mkupper</bdi></a> suggests.</p>
<p dir="auto">For that, the usefulness of the Mark comes into play and allows one to see what they’ll be changing ahead of time using the supplied regex. Using these things in bulk text changes is always a risk so again, these changes need to be tempered with good reason, as <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a>  suggests, rather than willly-nilly giving users more complex operations than they truly need which just adds to more confusion, support problems and trying to explain to people how to properly use it which will benefit, what? Maybe 1% of the total users?</p>
<p dir="auto">That’s what the scripting option is supposed to be for, so that the 1% (which most likely will also be superusers with the skills, anyways) can craft custom capabilities that the other 99% don’t need to be able to use or heaven forbid, stumble into and send them straight here looking for people to unscrew their lack of understanding of what “Don’t push the red button” means. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87181</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87181</guid><dc:creator><![CDATA[Lycan Thrope]]></dc:creator><pubDate>Sat, 17 Jun 2023 22:16:46 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sat, 17 Jun 2023 16:49:33 GMT]]></title><description><![CDATA[<p dir="auto">I have always thought of selections as being temporary and fragile things and don’t think I would be comfortable with constructing selections using a search expression. I like to be able to look things over before I perform some action… One click of a mouse or keyboard can wipe out a carefully constructed selection.</p>
<p dir="auto">An alternative is to use marking and to add a <code>Select Marked Text</code> button.  This button likely could replace the <code>Copy Marked Text</code> button on the <code>Mark</code> dialog box.</p>
<p dir="auto">Once the marked text is selected then people could then copy it, replace it, delete it, convert to upper/lower case, etc.</p>
<p dir="auto">At present, unmarking is moderately awkward but is possible. Ideally, the <code>Mark</code> dialog box was a little more consistent. The <code>Mark All</code> button marks using a combination of the search pattern plus the <code>In selection</code> checkbox. The <code>Clear all marks</code> button though ignores the search pattern field but does honor <code>In selection</code>.</p>
<p dir="auto">That leads me to thinking about adding a <code>Mark selected text</code> button so that I can drag-select some text, mark it, drag-select something else and mark it without needing to use the search pattern field.</p>
<p dir="auto">A potential downside to the idea is that because selecting and marking do not make changes to the text that the activity related to setting up the marked area(s) or selection(s) never show up in the undo/redo history. Someone could loose chunk of time.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87180</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87180</guid><dc:creator><![CDATA[mkupper]]></dc:creator><pubDate>Sat, 17 Jun 2023 16:49:33 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sat, 17 Jun 2023 11:24:08 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>,</p>
<p dir="auto">Of course, you’re <strong>right</strong> about it ! Don’t know which manipulation I did before ! I confirm that after <strong>deleting</strong> the <strong><code>10</code></strong> words <strong>simple</strong> of my test, with the script, adding a <strong>line-break</strong> then some <strong>dummy</strong> text, the <strong><code>Ctrl + Z</code></strong> actions did <strong>delete</strong> the <strong>added</strong> text as well as the <strong>line-breaks</strong> and get the words <strong><code>simple</code></strong> <strong>back</strong>  ! The status of the file was also <strong>back</strong> to <strong><code>unchanged</code></strong> !</p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87179</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87179</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 17 Jun 2023 11:24:08 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sat, 17 Jun 2023 12:03:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> said in <a href="/post/87176">Automatic selection of ALL instances of a searched string, in one go</a>:</p>
<blockquote>
<p dir="auto">BTW, once I selected the ten lines of my test and used the Multiple_Selections.py script to select the ten words simple and deleted them with the Del key, I tried a Ctrl + Z action in the hope of get the words simple back. But no success ! I suppose that my last version should include a sequence editor.beginUndoAction() and editor.endUndoAction()</p>
</blockquote>
<p dir="auto">I didn’t try your script, but setting up a similar test, where <em>Delete</em> is done with multiple selections active and then doing <em>Undo</em> <strong>DID</strong> achieve the undo for me.  I see no reason why it should be different with a script pre-selecting data that you manually press the <em>Delete</em> key on post-script.</p>
<p dir="auto">In your script, <code>editor.beginUndoAction()</code> and <code>editor.endUndoAction()</code> aren’t going to do anything, because your script doesn’t <em>change</em> the text…so there’s nothing to undo.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87178</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87178</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 17 Jun 2023 12:03:04 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sat, 17 Jun 2023 10:59:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a></p>
<p dir="auto">No worries; it was merely my attempt to point out that it probably wouldn’t be as useful as people think on first consideration.</p>
<p dir="auto">Now consider the <code>Select all only</code> checkbox in the <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> UI mockup.  How is one to know which actions this applies to?  Does one need it for <em>Find Next</em>? (no).  <em>Count</em>? (maybe?).  <em>Find All in Current Document</em>? (certainly).  <em>Find All in All Opened…</em>? (probably?).</p>
<p dir="auto">The historical way of options that apply to only certain actions is to put them in a box that groups those actions; here we see <em>In selection</em> as the example of that.  How would something like that best be done here, or is the <code>Select All Only</code> checkbox left floating out on its own?</p>
<p dir="auto">Would this apply to <em>Find in Files</em> as well, for documents that are already open?</p>
<p dir="auto">Is there any effect for <em>Mark</em>?  Maybe the new checkbox <em>only</em> appears on the marking tab, as this has some logical commonality.</p>
<p dir="auto">It’s good to want things, but it is also good to consider why you want them, and then all the downstream concerns.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87177</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87177</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 17 Jun 2023 10:59:15 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sat, 17 Jun 2023 11:28:48 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto"><strong>Alan</strong>, you asked <a class="plugin-mentions-user plugin-mentions-a" href="/user/wonkawilly" aria-label="Profile: wonkawilly">@<bdi>wonkawilly</bdi></a> to describe the <strong>benefits</strong> of this potential <strong>new</strong> feature but, to be <strong>honest</strong>, I said exactly the <strong>same</strong> thing in my <strong>first</strong> post when I added, at the end :</p>
<blockquote>
<p dir="auto">So, I wonder if we should propose an <strong>enhancement</strong> of the <strong><code>Mark</code></strong> dialog, with a <strong>new</strong> box option <strong><code>Selection of the Occurrences</code></strong> or equivalent, using this mechanism ?</p>
</blockquote>
<p dir="auto">So, you would also be <strong>entitled</strong> to level the <strong>same</strong> criticism at me and ask me to <strong>justify</strong> the need for <strong>multiple</strong> cursors !</p>
<p dir="auto">Thus, I read your <strong>last</strong> post <strong>carefully</strong> and, of course, your arguments seem <strong>relevant</strong>. However, I have an <strong>intuitive</strong> feeling that this <strong>new</strong> functionality would be very <strong>powerful</strong>, especially when you decide to take <strong>consecutive</strong> actions on this selection of <strong>cursors</strong> !</p>
<p dir="auto">For example, considering the text :</p>
<pre><code class="language-diff">This is a simple test
  This is a simple test
    This is a simple test
      This is a simple test
        This is a simple test
          This is a simple test
            This is a simple test
              This is a simple test
                This is a simple test
                  This is a simple test
</code></pre>
<ul>
<li>
<p dir="auto">Let’s say we’ve selected the <strong>ten</strong> words <strong><code>simple</code></strong>, using the <strong>latest</strong> version of the <strong><code>Mutliple-Selections.py</code></strong> script.</p>
</li>
<li>
<p dir="auto"><strong>First</strong>, we decide to <strong>delete</strong> the word <strong><code>simple</code></strong> : We could use the <strong>Replace</strong> dialog with the search of <strong><code>simple</code></strong>, <strong><code>Nothing</code></strong> as the replacement and with the <strong><code>In selection</code></strong> box <strong>ticked</strong>, to obtain the following text :</p>
</li>
</ul>
<pre><code class="language-diff">This is a  test
  This is a  test
    This is a  test
      This is a  test
        This is a  test
          This is a  test
            This is a  test
              This is a  test
                This is a  test
                  This is a  test
</code></pre>
<ul>
<li>However, suppose we change our mind and we want to add <strong><code>10</code></strong> <strong>line-breaks</strong>, <em>AFTER</em> deleting those <strong><code>10</code></strong> <strong>simple</strong> words. Now, using the <strong>Replace</strong> dialogue is <strong>not</strong> so easy, because we have to search for the string <strong><code>a  test</code></strong> and change it to the string <strong><code>a \r\n test</code></strong>, just for those <strong>ten</strong> lines ! If we had used the <strong>multiple cursors’</strong> technique, we would <strong>only</strong> have had to press the <strong><code>Enter</code></strong> key :-)</li>
</ul>
<p dir="auto">And then, after all: if <strong><code>Neil Hodgson</code></strong>, and his <strong>team</strong> of devs, have added the <strong><code>SCI_MULTIPLESELECTADDNEXT</code></strong> and <strong><code>SCI_MULTIPLESELECTADDEACH</code></strong> commands, in the <strong>Scintilla</strong> project, there must be <strong>some</strong> point in using them !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto">BTW, once I selected the <strong>ten</strong> lines of my test and used the <strong><code>Multiple_Selections.py</code></strong> script to select the <strong>ten</strong> words <strong><code>simple</code></strong> and <strong>deleted</strong> them with the <strong><code>Del</code></strong> key, I tried a <strong><code>Ctrl + Z</code></strong> action in the hope of get the words <strong><code>simple</code></strong> <strong>back</strong>. But <strong>no</strong> success ! I suppose that my <strong>last</strong> version should include a <strong>sequence</strong> <strong><code>editor.beginUndoAction()</code></strong> and <strong><code>editor.endUndoAction()</code></strong> …</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87176</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87176</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 17 Jun 2023 11:28:48 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sat, 17 Jun 2023 10:38:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/87174">Automatic selection of ALL instances of a searched string, in one go</a>:</p>
<blockquote>
<p dir="auto">in the end you have several cursors to work with</p>
</blockquote>
<p dir="auto">And the big advantage to that is…?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87175</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87175</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 17 Jun 2023 10:38:00 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Sat, 17 Jun 2023 06:31:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a></p>
<p dir="auto">It serves a similar but different purpose, in the end you have several cursors to work with. At the moment, the Find and Replace dialog cannot do this and the options mentioned are, for this case, also no options, because they leave only one cursor after the actions.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87174</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87174</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Sat, 17 Jun 2023 06:31:46 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Fri, 16 Jun 2023 11:14:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/87163">Automatic selection of ALL instances of a searched string, in one go</a>:</p>
<blockquote>
<p dir="auto">If I understand you correctly, you want something like this mock?</p>
</blockquote>
<p dir="auto">For the record, I understand exactly what <a class="plugin-mentions-user plugin-mentions-a" href="/user/wonkawilly" aria-label="Profile: wonkawilly">@<bdi>wonkawilly</bdi></a> wants.<br />
But I wanted him to explain why he thinks having such a capability is so advantageous.  I wanted him to do this on his own, so I wasn’t leading him, but he couldn’t figure out what I was asking for, so…</p>
<p dir="auto">What are you going to do when you have all these matches as selected text, that you can’t do already in the N++ search/replace/mark interface, without having text selected as a result of a search?</p>
<p dir="auto">Your choices are:</p>
<ul>
<li>
<p dir="auto">start typing (this will replace the selected text with what you type; hmmm, there’s already a <em>Replace</em> function that will do this)</p>
</li>
<li>
<p dir="auto">copy (there’s already a <em>Copy Marked Text</em> function – ok, you have to mark text first)</p>
</li>
<li>
<p dir="auto">delete (just a <em>Replace</em> with nothing, use that function)</p>
</li>
<li>
<p dir="auto">cut (copy plus delete, a <em>bit</em> laborious with existing functionality, but is this a really common need?)</p>
</li>
<li>
<p dir="auto">scroll around post-search to “eyeball” all the matches (just use <em>Mark All</em>; also, if text was selected and you do this, be careful that you don’t do a keyboard/mouse action that causes all of your selected text to become immediately unselected)</p>
</li>
</ul>
<p dir="auto">In short, no big advantage that I see to having text selected as a result of a search.  Sure, it is fine to want it, but perhaps there is a reason it doesn’t already exist.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87166</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87166</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 16 Jun 2023 11:14:44 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Fri, 16 Jun 2023 12:56:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a><br />
Yes that would be beneficial indeed IMHO too.</p>
<p dir="auto">IMHO no need of the “only” word, just <strong>Select all</strong> will work fine</p>
<p dir="auto">Of course everything could have drawbacks when used improperly: even regular expressions if improperly used can open not just one but multiple cans or worms.</p>
<p dir="auto">Also into the dialog the button Count can help to prevent problems. And I suppose that the tools present into the tab <strong>Mark</strong> will help too for the same reason to check before act.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87164</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87164</guid><dc:creator><![CDATA[wonkawilly]]></dc:creator><pubDate>Fri, 16 Jun 2023 12:56:58 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic selection of ALL instances of a searched string, in one go on Fri, 16 Jun 2023 07:00:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/wonkawilly" aria-label="Profile: wonkawilly">@<bdi>wonkawilly</bdi></a></p>
<p dir="auto">If I understand you correctly, you want something like this mock?</p>
<p dir="auto"><img src="/assets/uploads/files/1686898515728-79fc909f-2ff9-4d10-9404-38bbd110e81c-image.png" alt="79fc909f-2ff9-4d10-9404-38bbd110e81c-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">A way to find and select each instance to work in multi-editor/instance mode, right?<br />
Yes, that would be beneficial, but I think it would also open a can of worms. I already see that some select 1_000_000 instances of a word.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87163</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87163</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 16 Jun 2023 07:00:14 GMT</pubDate></item></channel></rss>