<?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 not behaving the same as keystrokes]]></title><description><![CDATA[<p dir="auto">So here’s an odd one; while writing code (html in this case), I like to use auto-complete to save having to type ending tags.  However, what I don’t like is after typing the text between tags, having to move my fingers from the home row, type &lt;END&gt;, return to the home row and press &lt;ENTER&gt;.  So I created a macro with just those two keystrokes: &lt;END&gt;&lt;ENTER&gt;.  I saved it to the &lt;Ctrl-ENTER&gt; combination (after clearing the existing macro which just filled in auto-complete because &lt;TAB&gt; does the same thing.)</p>
<p dir="auto">This works really well EXCEPT when the line I’m on is indented.  If I press the keys &lt;END&gt; and &lt;ENTER&gt; separately, the cursor goes to the end of the line, then creates a new line below it and auto indents.  If I execute the macro instead, the new line is created, but the cursor is at the BEGINNING of the line.  It doesn’t auto-indent.  This is somewhat of a pain.  I have worked around it by assigning &lt;Ctrl-E&gt; to a macro that just takes me to the end of line, then I press &lt;ENTER&gt; - one more keystroke that I shouldn’t have to make.</p>
<p dir="auto">Is this an undocumented feature (bug), or am I missing something?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/16194/macro-not-behaving-the-same-as-keystrokes</link><generator>RSS for Node</generator><lastBuildDate>Tue, 16 Jun 2026 08:47:30 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/16194.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Aug 2018 23:20:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Macro not behaving the same as keystrokes on Fri, 07 Sep 2018 01:03:44 GMT]]></title><description><![CDATA[<p dir="auto">Thank you Peter and guy038,</p>
<p dir="auto">Both solutions are very elegant, but I chose to use guy038’s - it <strong>works like a champ!</strong> This make coding with auto-complete symbols and tags <strong>so</strong> much easier.</p>
<p dir="auto">I cut my programming teeth editing in <strong>Wordstar</strong> on <strong>CP/M</strong> machines (ok, my age is showing and many of you young folks have no clue what I’m talking about.)  This was before there were cursor directional keys and all cursor movements were done with <strong>&lt;Ctrl&gt;-?</strong> sequences.  I’m a relatively fast touch typist and hate leaving the home row to find <strong>&lt;End&gt;, &lt;Home&gt;, &lt;Left-arrow&gt;</strong> etc.  I’ve also swapped the position of the <strong>&lt;Ctrl&gt;</strong> and <strong>&lt;Caps lock&gt;</strong> keys (registry hack) to put <strong>&lt;Ctrl&gt;</strong> back where God (and IBM) intended to be.</p>
<p dir="auto">Thanks again for your help.<br />
Cheers,<br />
Russ</p>
]]></description><link>https://community.notepad-plus-plus.org/post/34694</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/34694</guid><dc:creator><![CDATA[Russ Fisher]]></dc:creator><pubDate>Fri, 07 Sep 2018 01:03:44 GMT</pubDate></item><item><title><![CDATA[Reply to Macro not behaving the same as keystrokes on Fri, 07 Sep 2018 13:22:52 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/russ-fisher" aria-label="Profile: russ-fisher">@<bdi>russ-fisher</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: scott-sumner">@<bdi>scott-sumner</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">I found an <strong>other</strong> sequence of keys, <a class="plugin-mentions-user plugin-mentions-a" href="/user/russ-fisher" aria-label="Profile: russ-fisher">@<bdi>russ-fisher</bdi></a>, which :</p>
<ul>
<li>
<p dir="auto">Whatever the <strong>location</strong> of the <strong>cursor</strong>, on the <strong>current</strong> line</p>
</li>
<li>
<p dir="auto">Whatever the <strong>current</strong> line is  <strong>wrapped</strong> or <strong>not</strong></p>
</li>
<li>
<p dir="auto">Whatever the <strong>current</strong> line is <strong>indented</strong> or <strong>not</strong></p>
</li>
<li>
<p dir="auto">Whatever the <strong><code>Word wrap</code></strong> option is <strong>on</strong> or <strong>off</strong></p>
</li>
</ul>
<p dir="auto">is able to create a <strong>new</strong> line, right <strong>below</strong> the current one, with its <strong>indentation</strong> !</p>
<p dir="auto">Indeed, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a>, when the <strong><code>View &gt; Word wrap</code></strong> option is <strong>set</strong> AND the <strong>current</strong> line is split on <strong>several</strong> lines, your macro does <strong>not</strong> seem to work :-((</p>
<p dir="auto">So, I propose this <strong>new</strong> keys sequence :</p>
<pre><code class="language-xml">        &lt;Macro name="AddLineAutoIndented" Ctrl="no" Alt="no" Shift="no" Key="0"&gt;
            &lt;Action type="0" message="2451" wParam="0" lParam="0" sParam="" /&gt;    &lt;!-- SCI_LINEENDWRAP          =  End            --&gt;
            &lt;Action type="0" message="2451" wParam="0" lParam="0" sParam="" /&gt;    &lt;!-- SCI_LINEENDWRAP          =  End            --&gt;
            &lt;Action type="0" message="2469" wParam="0" lParam="0" sParam="" /&gt;    &lt;!-- SCI_SELECTION DUPLICATE  =  Ctrl-D         --&gt;
            &lt;Action type="0" message="2306" wParam="0" lParam="0" sParam="" /&gt;    &lt;!-- SCI_CHARRIGHT            =  Right          --&gt;
            &lt;Action type="0" message="2453" wParam="0" lParam="0" sParam="" /&gt;    &lt;!-- SCI_LINEHOMEWRAP         =  Home           --&gt;
            &lt;Action type="0" message="2396" wParam="0" lParam="0" sParam="" /&gt;    &lt;!-- SCI_DELLINERIGHT         =  Ctrl-Shift-Del --&gt;
        &lt;/Macro&gt;
</code></pre>
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">After the <strong>two</strong> <strong><code>End</code></strong> sequences, you are sure that the cursor is at the <strong>true end</strong> of the <strong>current</strong> line, whatever its <strong>previous</strong> location</p>
</li>
<li>
<p dir="auto">The <strong><code>Right</code></strong> sequence, after <strong>duplication</strong> of the <strong>current</strong> line, places the cursor at the <strong>very beginning</strong> of the <strong>duplicated</strong> line ( at column <strong><code>1</code></strong> )</p>
</li>
<li>
<p dir="auto">Then the <strong><code>Home</code></strong> sequence move the cursor after <strong>any possible</strong> indentation of the <strong>duplicated</strong> line or leave it at position <strong><code>1</code></strong> if the line is <strong>not</strong>  indented</p>
</li>
<li>
<p dir="auto">Finally, the <strong><code>Ctrl-Shift-Del</code></strong> sequence <strong>delete any</strong> character, from <strong>current</strong> position to the <strong>very end</strong> of the <strong>duplicated</strong> line</p>
</li>
</ul>
<p dir="auto">You may <strong>test</strong> my macro against the <strong>example</strong> text, below, from the <strong>license.txt</strong> file :</p>
<pre><code class="language-diff">The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
		The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
The licenses for most software are designed to take away your freedom to share and change it.
		The licenses for most software are designed to take away your freedom to share and change it.
</code></pre>
<p dir="auto">Of course, select the <strong><code>Word wrap</code></strong> option, if you want to <strong>easily</strong>  see the different <strong>steps</strong>, during <strong>manual</strong> execution</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/34592</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/34592</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 07 Sep 2018 13:22:52 GMT</pubDate></item><item><title><![CDATA[Reply to Macro not behaving the same as keystrokes on Thu, 23 Aug 2018 20:20:12 GMT]]></title><description><![CDATA[<p dir="auto">Interesting.</p>
<p dir="auto">So, if you record the macro, it inserts the actual characters:</p>
<pre><code>    &lt;Macro name="EndEnter" Ctrl="no" Alt="no" Shift="no" Key="0"&gt;
        &lt;Action type="0" message="2451" wParam="0" lParam="0" sParam="" /&gt;
        &lt;Action type="1" message="2170" wParam="0" lParam="0" sParam="&amp;#x000D;" /&gt;
        &lt;Action type="1" message="2170" wParam="0" lParam="0" sParam="&amp;#x000A;" /&gt;
    &lt;/Macro&gt;
</code></pre>
<p dir="auto">Looking at <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/scintilla/include/Scintilla.h" rel="nofollow ugc">scintilla.h messages</a>: 2451 is SCI_LINEENDWRAP; then, when you hit ENTER, it inserts the CR and LF characters using the 2170 = SCI_REPLACESEL (it replaces the empty selection with the character 13=CR, then replaces the empty selection with the character 10=LF).</p>
<p dir="auto">I tried replacing both of those 2170’s with a single SCI_NEWLINE=2329</p>
<pre><code>    &lt;Macro name="EndSciNewLine" Ctrl="no" Alt="no" Shift="no" Key="0"&gt;
        &lt;Action type="0" message="2451" wParam="0" lParam="0" sParam="" /&gt;
        &lt;Action type="0" message="2329" wParam="0" lParam="0" sParam="" /&gt;
    &lt;/Macro&gt;
</code></pre>
<p dir="auto">but it behaved identically to the CR and LF inserts.</p>
<p dir="auto">While looking for more ideas, I came across <a href="http://docs.notepad-plus-plus.org/index.php/Useful_Macros#New_line_with_exact_indentation" rel="nofollow ugc">Useful Macros: New line with exact indentation</a>, which I was able to tweak into:</p>
<pre><code>    &lt;Macro name="AddLineAutoIndent" Ctrl="no" Alt="no" Shift="no" Key="0"&gt;
        &lt;Action type="0" message="2469" wParam="0" lParam="0" sParam="" /&gt;&lt;!-- SCI_SELECTIONDUPLICATE           == Ctrl-D --&gt;
        &lt;Action type="0" message="2300" wParam="0" lParam="0" sParam="" /&gt;&lt;!-- SCI_LINEDOWN                     == DownArrow --&gt;
        &lt;Action type="0" message="2451" wParam="0" lParam="0" sParam="" /&gt;&lt;!-- SCI_LINEENDWRAP                  == END Key --&gt;
        &lt;Action type="1" message="2170" wParam="0" lParam="0" sParam="a" /&gt;&lt;!-- SCI_REPLACESEL                  == a key --&gt;
        &lt;Action type="0" message="2453" wParam="0" lParam="0" sParam="" /&gt;&lt;!-- SCI_VCHOMEWRAP                   == HOME or Alt+Home, depending on settings: go to first non-space character on the line --&gt;
        &lt;Action type="0" message="2396" wParam="0" lParam="0" sParam="" /&gt;&lt;!-- SCI_DELLINERIGHT                 == Ctrl+Shift+DEL: delete from that to the right end of the line --&gt;
    &lt;/Macro&gt;
</code></pre>
<p dir="auto">So, it’s a much more tedious sequence to enter if you’re recording the macro, but it is possible to get the same functionality into a recorded macro.  (Or you can edit the 2451/2170/2170 to the 2469/2300/… after the fact).</p>
<p dir="auto">IOt doesn’t really explain the “why” however.  My is that in order to capture all the events for the the macro-record, it (intentionally or unintentionally) bypasses normal filters which would send the auto-indent sequence to scintilla instead of just the CR+LF characters. (Not that it helps you.  Sorry.)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/34290</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/34290</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 23 Aug 2018 20:20:12 GMT</pubDate></item><item><title><![CDATA[Reply to Macro not behaving the same as keystrokes on Thu, 23 Aug 2018 18:11:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/russ-fisher" aria-label="Profile: Russ-Fisher">@<bdi>Russ-Fisher</bdi></a></p>
<p dir="auto">I can’t offer up a solution at the moment, but I agree with your assessment.</p>
<p dir="auto">When trying this without macro-recording turned on, <em>End</em> followed by <em>Enter</em> causes the newly created line to be indented (with auto-indent turned on).</p>
<p dir="auto">When trying it during macro recording the <em>Enter</em> press causes the new line below to <em>NOT</em> be indented.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/34274</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/34274</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Thu, 23 Aug 2018 18:11:37 GMT</pubDate></item></channel></rss>