<?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[Macro to add symbol before and after text]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I am working on a lot of German text which uses „this type of quotation marks“ to mark direct speech. I find it extremely tedious to copy-paste them again and again because the symbol on a standard German keyboard results in “this”, so I cannot just type it like that.</p>
<p dir="auto">I made a macro a year ago that would automagically add „these quotation marks“ before and after a selected text. However, due to a reinstallation of Windows, my precious macro is gone and I can’t figure out how I did it.</p>
<p dir="auto">Can someone point me into the right direction?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/21446/macro-to-add-symbol-before-and-after-text</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 08:29:00 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/21446.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Jul 2021 11:39:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 12 Jul 2021 20:05:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mathlete2" aria-label="Profile: mathlete2">@<bdi>mathlete2</bdi></a> said in <a href="/post/67817">Macro to add symbol before and after text</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> thanks for putting that together!  Unfortunately, I’m not familiar with how to work such scripts into NP++. Where is this documented?</p>
</blockquote>
<p dir="auto"><a href="https://github.com/sieukrem/jn-npp-plugin" rel="nofollow ugc">https://github.com/sieukrem/jn-npp-plugin</a><br />
My developments are based on this plugin.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/67823</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67823</guid><dc:creator><![CDATA[TroshinDV]]></dc:creator><pubDate>Mon, 12 Jul 2021 20:05:23 GMT</pubDate></item><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 12 Jul 2021 20:03:08 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/67812">Macro to add symbol before and after text</a>:</p>
<blockquote>
<p dir="auto">What does your screenshot add to the conversation?</p>
</blockquote>
<p dir="auto">I hinted a person that there is another solution. If he became interested, he would ask. And his silence indicates a lack of interest.<br />
Я намекнул человеку что есть и другое решение. Если бы он заинтересовался, он бы спросил. А его молчание указывает на отсутствие интереса.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/67822</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67822</guid><dc:creator><![CDATA[TroshinDV]]></dc:creator><pubDate>Mon, 12 Jul 2021 20:03:08 GMT</pubDate></item><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 12 Jul 2021 17:52:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mathlete2" aria-label="Profile: mathlete2">@<bdi>mathlete2</bdi></a> ,</p>
<p dir="auto">PythonScript is a plugin, which you install through <strong>Plugins &gt; Plugins Admin</strong> interface.</p>
<p dir="auto">It comes with its own documentation available thru the <strong>Plugins &gt; PythonScript &gt; Context-help</strong> menu entry</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/post/62027">This post</a> gives a run-through for how to get the script into the plugin, and how to run the script</p>
]]></description><link>https://community.notepad-plus-plus.org/post/67818</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67818</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 12 Jul 2021 17:52:24 GMT</pubDate></item><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 12 Jul 2021 17:41:00 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> thanks for putting that together!  Unfortunately, I’m not familiar with how to work such scripts into NP++. Where is this documented?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/67817</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67817</guid><dc:creator><![CDATA[mathlete2]]></dc:creator><pubDate>Mon, 12 Jul 2021 17:41:00 GMT</pubDate></item><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 12 Jul 2021 15:56:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mathlete2" aria-label="Profile: mathlete2">@<bdi>mathlete2</bdi></a> ,</p>
<p dir="auto">The problem with trying to do an “in-selection” search-and-replace in a multi-selection region is that the search-and-replace engine navigates through the matches by changing the selection… which would break the multi-selection.</p>
<p dir="auto">In fact, if you try to do a multi-selection region and then run <strong>Search &gt; Replace</strong>, you will see that the “☐ In Selection” checkbox is greyed out, so that you cannot use it.  A multi-selection is a different beast than a normal selection, and there are some things that don’t work the same.</p>
<p dir="auto">It might be that you have to go deeper into one of the scripting languages (like the jN-NPP that <a class="plugin-mentions-user plugin-mentions-a" href="/user/troshindv" aria-label="Profile: TroshinDV">@<bdi>TroshinDV</bdi></a> uses, or the PythonScript that many of the regulars use)… Looking through the scintilla docs, I found <a href="https://www.scintilla.org/ScintillaDoc.html#MultipleSelectionAndVirtualSpace" rel="nofollow ugc">“Multiple Selection and Virtual Space”</a> – these messages should all have corresponding methods in the PythonScript <code>editor</code> object (or equivalent in other scripting plugins).  So I pieced together this script which does multi-selection replacement, where it doesn’t matter what the contents of the multi-selection are: it will just surround them by the <code>**</code>:</p>
<pre><code class="language-python"># encoding=utf-8
"""in response to https://community.notepad-plus-plus.org/topic/21446/ multi-selection request

the comments show my debug code, or alternative methods

this will loop through all N sections of the multi-selection
for each section:
* find the start and end locations
* grab the original text from that section
* replace the original by surrounding it with **

Notes:
* it allows a single undo for the whole group of replacements, but if you do UNDO,
    it will clear the multi-selection
* at the end of the replacement, the multi-selection goes down to a zero-length
    selection at the start of each of the original words;
        shift+arrows or shift+ctrl+arrow will allow you to extend the multi-selection again

"""

from Npp import *

editor.beginUndoAction()

for mSel in range(editor.getSelections()):
    selStart = editor.getSelectionNStart(mSel)
    selEnd = editor.getSelectionNEnd(mSel)
    orig = editor.getTextRange(selStart, selEnd)
    #console.write("loop #{}: {}..{} = \"{}\"\n".format(mSel,selStart,selEnd,orig))
    txt = "**" + orig + "**"
    editor.replace(orig,txt,0,selStart,selEnd)



editor.endUndoAction()
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/67814</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67814</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 12 Jul 2021 15:56:51 GMT</pubDate></item><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 12 Jul 2021 14:56:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/troshindv" aria-label="Profile: TroshinDV">@<bdi>TroshinDV</bdi></a> ,</p>
<p dir="auto">What does your screenshot add to the conversation?  With no explanation in the text of your post, it is very hard to tell what you are trying to say.  While the old saying is that “a picture is worth 1000 words”, I don’t think that’s true when there is no context given to the picture.</p>
<p dir="auto">It looks like you were showing an alternative to using the built-in macro language, which is fine (but unnecessary, since the OP had a solution already, which doesn’t require external installs)… but explaining that this is an alternative solution will help.</p>
<p dir="auto">Does your trdmBrackets.js script address the OP’s additional request of wanting to handle multi-selection?  Your example screenshot only shows a single selection, and you didn’t explain, so we cannot know.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/67812</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67812</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 12 Jul 2021 14:56:59 GMT</pubDate></item><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 12 Jul 2021 14:46:56 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://github.com/trdm/jn-npp-scripts" rel="nofollow ugc">https://github.com/trdm/jn-npp-scripts</a><br />
trdmBrackets.js<br />
<img src="https://raw.githubusercontent.com/trdm/jn-npp-scripts/master/Doc/trdmBrackets.js.gif" alt="alt text" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/67811</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67811</guid><dc:creator><![CDATA[TroshinDV]]></dc:creator><pubDate>Mon, 12 Jul 2021 14:46:56 GMT</pubDate></item><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 12 Jul 2021 13:53:20 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> thanks for the solution!  I was able to use it to create the following macro for markup coding that I will be doing frequently (among others):</p>
<pre><code>        &lt;Macro name="bold" Ctrl="yes" Alt="no" Shift="no" Key="66"&gt;
            &lt;Action type="3" message="1700" wParam="0" lParam="0" sParam="" /&gt;
            &lt;Action type="3" message="1601" wParam="0" lParam="0" sParam="(?s).+" /&gt;
            &lt;Action type="3" message="1625" wParam="0" lParam="2" sParam="" /&gt;
            &lt;Action type="3" message="1602" wParam="0" lParam="0" sParam="**${0}**" /&gt;
            &lt;Action type="3" message="1702" wParam="0" lParam="898" sParam="" /&gt;
            &lt;Action type="3" message="1701" wParam="0" lParam="1609" sParam="" /&gt;
        &lt;/Macro&gt;
</code></pre>
<p dir="auto">Unfortunately, when I do a multi-select, only the last selection is modified by the macro.  Is there a way to modify the macro code to support multiple selections?  For example, in the sentence <code>I want this, this, and this to be modified.</code>, I want to be able to Ctrl+double-click each <code>this</code>, apply the shortcut once, and have all 3 changed to <code>**this**</code> (i.e. <code>I want **this**, **this**, and **this** to be modified.</code>).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/67810</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67810</guid><dc:creator><![CDATA[mathlete2]]></dc:creator><pubDate>Mon, 12 Jul 2021 13:53:20 GMT</pubDate></item><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 05 Jul 2021 20:10:03 GMT]]></title><description><![CDATA[<p dir="auto">What a cool forum!</p>
<p dir="auto">Thank you for your suggestions. I love Ekopalypse’s approach for the simplicity, but Alan is right about the clipboard issue. And I use the clipboard a ton. So I’ve tried Alan’s solution and it works beautifully.</p>
<p dir="auto">Thank you!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/67705</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67705</guid><dc:creator><![CDATA[JP A.]]></dc:creator><pubDate>Mon, 05 Jul 2021 20:10:03 GMT</pubDate></item><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 05 Jul 2021 12:45:01 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/67701">Macro to add symbol before and after text</a>:</p>
<blockquote>
<p dir="auto">record a macro by keyboard actions like</p>
</blockquote>
<p dir="auto">Potential downsides:</p>
<ul>
<li>destroys clipboard contents</li>
<li>doesn’t work for those without numeric keypad on their keyboard (and yes, there are those of us for which a keyboard with a numeric keyboard is a hinderance; thus mine):</li>
</ul>
<p dir="auto"><img src="/assets/uploads/files/1625489075797-074bcbd7-c967-4923-8aa0-fad5d50dc965-image.png" alt="074bcbd7-c967-4923-8aa0-fad5d50dc965-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/67702</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67702</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 05 Jul 2021 12:45:01 GMT</pubDate></item><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 05 Jul 2021 11:53:32 GMT]]></title><description><![CDATA[<p dir="auto">@JP-A said in <a href="/post/67698">Macro to add symbol before and after text</a>:</p>
<blockquote>
<p dir="auto">„this type of quotation marks“</p>
</blockquote>
<p dir="auto">record a macro by keyboard actions like</p>
<p dir="auto"><code>ctrl+x</code><br />
<code>alt+0132</code><br />
<code>ctrl+v</code><br />
<code>alt+0148</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/67701</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67701</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 05 Jul 2021 11:53:32 GMT</pubDate></item><item><title><![CDATA[Reply to Macro to add symbol before and after text on Mon, 05 Jul 2021 11:48:17 GMT]]></title><description><![CDATA[<p dir="auto">@JP-A</p>
<p dir="auto">It seems like you’d want an “in-selection” replacement.  Record this as a macro:</p>
<p dir="auto">Search for <code>(?s).+</code><br />
Replace with <code>a${0}b</code> (where <code>a</code> is your opening quotes, <code>b</code> is your closing)<br />
Tick <em>In selection</em> checkbox<br />
Tick <em>Regular expression</em> search mode.<br />
Press <em>Replace All</em></p>
]]></description><link>https://community.notepad-plus-plus.org/post/67700</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/67700</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 05 Jul 2021 11:48:17 GMT</pubDate></item></channel></rss>