<?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[Inserting g code using replace]]></title><description><![CDATA[<p dir="auto">Hello, everyone, I’m having a bit of trouble inserting a code program thingy into my file if I search;LAYER:  and want to insert this code on separate lines it will only put it on one line, and so it will not run, where I want it to list as below so the machine can recognise the actions I want it to do, I then have to copy and paste it under;Layer: on every layer, which is very time consuming if there are over a 1000 layers, any and all help very much appreciated with this,<br />
G91 ; USE RELATIVE POSITION<br />
G1 E-3 F1800 ; RETRACT 3MM<br />
G1 Z2 F2000 ; MOVE UP 2 MM<br />
G90 ; ABSOLUTE POSITION<br />
G1 F13000 X200 Y200 ; QUICK MOVE REAR RIGHT<br />
G1 F1000 X205 ; PRESS SWITCH<br />
G1 F9000 X199 ; MOVE SLIGHT LEFT<br />
G4 P500 ; PAUSE FOR 0.5 SECS<br />
G91 ; RELATIVE POSITION<br />
G1 E9 F1800 ; RESTORE FILAMENT<br />
G1 Z-2 F2000 ; RETURN Z TO CURRENT LAYER<br />
G90 ; GO BACK TO ABSOLUTE CORDS</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/19741/inserting-g-code-using-replace</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 12:28:51 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/19741.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Jul 2020 18:13:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Inserting g code using replace on Thu, 23 Jul 2020 17:18:46 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/crafty-crafty" aria-label="Profile: crafty-crafty">@<bdi>crafty-crafty</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: ekopalypse">@<bdi>ekopalypse</bdi></a>, and <strong>All</strong>,</p>
<p dir="auto">From the <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: ekopalypse">@<bdi>ekopalypse</bdi></a> macro solution, here is an <strong>similar</strong> solution which can be <strong>generalized</strong> to :</p>
<ul>
<li>
<p dir="auto"><strong>Any</strong> number of lines which are to be <strong>replaced</strong>, in the limit of <strong><code>2,048</code></strong> characters</p>
</li>
<li>
<p dir="auto"><strong>Any</strong> number of lines which are to be <strong>inserted</strong>, during the <strong>replacement</strong></p>
</li>
</ul>
<hr />
<p dir="auto">But, first, let’s suppose that you simply have a <strong>specific</strong> line, repeated <strong>many</strong> times in your file, which must be <strong>replaced</strong> with a <strong>specific</strong> block of lines. Assuming that this line is named  <strong><code>#Line#</code></strong> :</p>
<ul>
<li>
<p dir="auto">Open a <strong>new</strong> tab ( <strong><code>Ctrl+ N</code></strong> )</p>
</li>
<li>
<p dir="auto">Type in the <strong>specific</strong> line <strong><code>#Line#</code></strong> line, followed with a <strong>line-break</strong></p>
</li>
<li>
<p dir="auto">Select the <strong>entire</strong> line <strong><code>#Line#</code></strong>, with its <strong>line-break</strong></p>
</li>
<li>
<p dir="auto">Open the <strong>Find</strong> dialog  ( <strong><code>CTRL + F</code></strong> )</p>
<ul>
<li>
<p dir="auto">Select, if necessary, the <strong><code>Normal</code></strong>  search mode</p>
</li>
<li>
<p dir="auto">Leave <strong>all</strong> the other options <strong>unchecked</strong></p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Find Next</code></strong> button ( Of course, <strong>no</strong> other occurrence is found, but it does <strong>not</strong> matter ! )</p>
</li>
<li>
<p dir="auto">Close the <strong>Find</strong> dialog ( <strong><code>Esc</code></strong> )</p>
</li>
</ul>
</li>
<li>
<p dir="auto">Run the option <strong><code>Macro &gt; Start Recording</code></strong></p>
<ul>
<li>
<p dir="auto">Hit the <strong><code>F3</code></strong> key ( Whatever an occurrence is <strong>found</strong>, or <strong>not</strong>, does <strong>not</strong> matter ! )</p>
</li>
<li>
<p dir="auto">Hit the <strong><code>Ctrl + V</code></strong> shortcut ( The <strong>present</strong> contents of clipboard do <strong>not</strong> matter, too ! )</p>
</li>
</ul>
</li>
<li>
<p dir="auto">Run the option <strong><code>Macro &gt; Stop Recording</code></strong></p>
</li>
<li>
<p dir="auto">Then, run the option <strong><code>Macro &gt; Save Currently Recorded Macro...</code></strong></p>
<ul>
<li>
<p dir="auto">Type in <strong><code>Replace Next Occurrence with Clipboard Contents</code></strong>, in the <strong><code>Name </code></strong> zone</p>
</li>
<li>
<p dir="auto">Preferably, create a <strong>shortcut</strong> for this <strong>macro</strong></p>
</li>
<li>
<p dir="auto">Click on the <strong><code>OK</code></strong> button to <strong>valid</strong> the dialog</p>
</li>
</ul>
</li>
<li>
<p dir="auto"><strong>Create</strong> or select the <strong>block</strong> of lines, in any file, which must replace the <strong><code>#Line#</code></strong> line</p>
</li>
<li>
<p dir="auto"><strong>Copy</strong> this block of lines in the <strong>clipboard</strong> ( <strong><code>Ctrl + C</code></strong> )</p>
</li>
<li>
<p dir="auto">Now, open or select your <strong>specific</strong> file</p>
</li>
<li>
<p dir="auto">If necessary, move to the <strong>very beginning</strong> of file ( <strong><code>Ctrl + Home</code></strong> )</p>
</li>
<li>
<p dir="auto">Run the option <strong><code>Macro &gt; Run a Macro Multiple Times...</code></strong></p>
<ul>
<li>
<p dir="auto">Select the <strong><code>Replace Next Occurrence with Clipboard Contents </code></strong> macro</p>
</li>
<li>
<p dir="auto">Tick the <strong><code>Run until the end of file</code></strong> option</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Run</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Voila ;-))</p>
<p dir="auto"><strong>Remark</strong> :</p>
<p dir="auto">After finding <strong>all</strong> the occurrences of the <strong>specific</strong> line, a <strong>last</strong> search operation is carried on, <strong>without</strong> success. So, the <strong>last</strong> <strong><code>#Line#</code></strong> line is replaced by <strong>two</strong> or <strong>more</strong> consecutive contents of the <strong>clipboard</strong>. Thus, a <strong>last</strong> task has to be done :</p>
<ul>
<li><strong>Delete</strong> the few <strong>extra</strong> blocks of text that have been <strong>wrongly</strong> inserted, after the <strong>last</strong> match !</li>
</ul>
<hr />
<p dir="auto">As said above, this <strong>macro</strong> is <strong>not</strong> specific and can be used to insert any <strong>contents</strong> of the <strong>clipboard</strong>, in <strong>replacement</strong> of any <strong>specific</strong> text, even split on <strong>several</strong> lines, as long as the <strong>total</strong> amount of text is <strong>smaller</strong> than <strong><code>2,048</code></strong> characters ( <strong><code>Max</code></strong> size of the <strong>Find what:</strong> zone )</p>
<p dir="auto">So, now that the macro <strong><code>Replace Next Occurrence with Clipboard Contents</code></strong> has been created, the <strong>road map</strong> becomes :</p>
<ul>
<li>
<p dir="auto"><strong>Create</strong> and <strong>select</strong> the text <strong>range</strong> which is to be <strong>replaced</strong></p>
</li>
<li>
<p dir="auto">Open the <strong>Find</strong> dialog  ( <strong><code>CTRL + F</code></strong> )</p>
<ul>
<li>
<p dir="auto">Select, if necessary, the <strong><code>Normal</code></strong>  search mode</p>
</li>
<li>
<p dir="auto">Leave <strong>all</strong> the other options <strong>unchecked</strong></p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Find Next </code></strong> button ( Whatever an occurrence of the range is <strong>found</strong> or <strong>not</strong> does <strong>not</strong> matter ! )</p>
</li>
<li>
<p dir="auto">Close the <strong>Find</strong> dialog ( <strong><code>Esc</code></strong> )</p>
</li>
</ul>
</li>
<li>
<p dir="auto"><strong>Create</strong> and <strong>select</strong> the text <strong>range</strong>, in any file, even split on <strong>several</strong> lines, which will <strong>replace</strong> the <strong>initial</strong> range</p>
</li>
<li>
<p dir="auto">Copy this text range in the <strong>clipboard</strong> ( <strong><code>Ctrl + C</code></strong> )</p>
</li>
<li>
<p dir="auto">Now, open or select the <strong>specific</strong> file, where the <strong>replacements</strong> must occur</p>
<ul>
<li>
<p dir="auto">If necessary, move to the <strong>very beginning</strong> of the file ( <strong><code>Ctrl + Home</code></strong> )</p>
</li>
<li>
<p dir="auto">Run the option <strong><code>Macro &gt; Run a Macro Multiple Times...</code></strong></p>
<ul>
<li>
<p dir="auto">Select the <strong><code>Replace Next Occurrence with Clipboard Contents </code></strong> <strong>macro</strong></p>
</li>
<li>
<p dir="auto"><strong>Tick</strong> the <strong><code>Run until the end of file</code></strong> option</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Run</code></strong> button</p>
</li>
</ul>
</li>
<li>
<p dir="auto">Finally, <strong>delete</strong> the few <strong>extra</strong> range of text that have been <strong>wrongly</strong> inserted, after the <strong>last</strong> matched range !</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Best Regards</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/56194</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/56194</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 23 Jul 2020 17:18:46 GMT</pubDate></item><item><title><![CDATA[Reply to Inserting g code using replace on Tue, 21 Jul 2020 10:27:08 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> - hahaha of course you are right the missing part is for step 2 and 7</p>
<ol start="2">
<li>… and <strong>Copy</strong> the new text</li>
<li>press <strong>ENTER</strong> and <strong>paste in</strong> the new text -&gt; Now you should have the layout you want to have</li>
</ol>
]]></description><link>https://community.notepad-plus-plus.org/post/56126</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/56126</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Tue, 21 Jul 2020 10:27:08 GMT</pubDate></item><item><title><![CDATA[Reply to Inserting g code using replace on Mon, 20 Jul 2020 20:50:58 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/crafty-crafty" aria-label="Profile: crafty-crafty">@<bdi>crafty-crafty</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: ekopalypse">@<bdi>ekopalypse</bdi></a>, and <strong>All</strong>,</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: ekopalypse">@<bdi>ekopalypse</bdi></a> : May be I’m <strong>missing</strong> something but your macro just inserts a <strong>new</strong> line and <strong>not</strong> all the lines of <strong><code>G-code</code></strong> ?</p>
<hr />
<p dir="auto">Here is my solution :</p>
<ul>
<li>
<p dir="auto">Open a <strong>new</strong> tab ( <strong><code>Ctrl + N</code></strong> )</p>
</li>
<li>
<p dir="auto">Select your <strong>block</strong> of code and <strong>copy</strong> it in <strong>clipboard</strong> ( <strong><code>Ctrl + C</code></strong> )</p>
</li>
<li>
<p dir="auto">Paste this <strong>block</strong> in the <strong>new</strong> tab ( <strong><code>Ctrl + V</code></strong> )</p>
</li>
</ul>
<pre><code class="language-diff">G91 ; USE RELATIVE POSITION
G1 E-3 F1800 ; RETRACT 3MM
G1 Z2 F2000 ; MOVE UP 2 MM
G90 ; ABSOLUTE POSITION
G1 F13000 X200 Y200 ; QUICK MOVE REAR RIGHT
G1 F1000 X205 ; PRESS SWITCH
G1 F9000 X199 ; MOVE SLIGHT LEFT
G4 P500 ; PAUSE FOR 0.5 SECS
G91 ; RELATIVE POSITION
G1 E9 F1800 ; RESTORE FILAMENT
G1 Z-2 F2000 ; RETURN Z TO CURRENT LAYER
G90 ; GO BACK TO ABSOLUTE CORDS
</code></pre>
<ul>
<li>
<p dir="auto">Move again to <strong>beginning</strong> of file ( <strong><code>Ctrl + Home</code></strong> )</p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
</li>
<li>
<p dir="auto">Run the following regex S/R :</p>
<ul>
<li>
<p dir="auto">SEARCH  <strong><code>\R</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>\\r\\n</code></strong></p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search mode</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; It should change that code into the <strong>single</strong> line, below :</p>
<pre><code class="language-diff">G91 ; USE RELATIVE POSITION\r\nG1 E-3 F1800 ; RETRACT 3MM\r\nG1 Z2 F2000 ; MOVE UP 2 MM\r\nG90 ; ABSOLUTE POSITION\r\nG1 F13000 X200 Y200 ; QUICK MOVE REAR RIGHT\r\nG1 F1000 X205 ; PRESS SWITCH\r\nG1 F9000 X199 ; MOVE SLIGHT LEFT\r\nG4 P500 ; PAUSE FOR 0.5 SECS\r\nG91 ; RELATIVE POSITION\r\nG1 E9 F1800 ; RESTORE FILAMENT\r\nG1 Z-2 F2000 ; RETURN Z TO CURRENT LAYER\r\nG90 ; GO BACK TO ABSOLUTE CORDS
</code></pre>
<ul>
<li>If necessary, <strong>delete</strong> the <strong>last</strong> string <strong><code>\r\n</code></strong> at the <strong>end</strong> of this <strong>single</strong> line</li>
</ul>
<p dir="auto">As you can see, it simply <strong>adds</strong> the string <strong><code>\r\n</code></strong> after <strong>each</strong> line of your <strong><code>G-code</code></strong> and <strong>join</strong> them in a <strong>single</strong> line !</p>
<hr />
<p dir="auto">Now, assuming, for instance, this <strong>test</strong> data, below :</p>
<pre><code class="language-diff">========
;LAYER:
========

########
;LAYER:
########

@@@@@@@@
;LAYER:
@@@@@@@@
</code></pre>
<ul>
<li>
<p dir="auto">Run this <strong>regex</strong> S/R :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?-i);LAYER:</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>G91 ; USE RELATIVE POSITION\r\nG1 E-3 F1800 ; RETRACT 3MM\r\nG1 Z2 F2000 ; MOVE UP 2 MM\r\nG90 ; ABSOLUTE POSITION\r\nG1 F13000 X200 Y200 ; QUICK MOVE REAR RIGHT\r\nG1 F1000 X205 ; PRESS SWITCH\r\nG1 F9000 X199 ; MOVE SLIGHT LEFT\r\nG4 P500 ; PAUSE FOR 0.5 SECS\r\nG91 ; RELATIVE POSITION\r\nG1 E9 F1800 ; RESTORE FILAMENT\r\nG1 Z-2 F2000 ; RETURN Z TO CURRENT LAYER\r\nG90 ; GO BACK TO ABSOLUTE CORDS</code></strong></p>
</li>
</ul>
</li>
<li>
<p dir="auto">Note that we inserted, in the <strong><code>Replace with:</code></strong> zone, <strong>all</strong> the contents of the <strong>single</strong> line, created before by the <strong>first</strong> regex S/R !</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
<p dir="auto">=&gt; Any line <strong><code>;LAYER:</code></strong>, with its <strong>exact</strong> case, is replaced with the <strong><code>G-Code</code></strong> block and gives the <strong>expected</strong> text, below :</p>
<pre><code class="language-diff">========
G91 ; USE RELATIVE POSITION
G1 E-3 F1800 ; RETRACT 3MM
G1 Z2 F2000 ; MOVE UP 2 MM
G90 ; ABSOLUTE POSITION
G1 F13000 X200 Y200 ; QUICK MOVE REAR RIGHT
G1 F1000 X205 ; PRESS SWITCH
G1 F9000 X199 ; MOVE SLIGHT LEFT
G4 P500 ; PAUSE FOR 0.5 SECS
G91 ; RELATIVE POSITION
G1 E9 F1800 ; RESTORE FILAMENT
G1 Z-2 F2000 ; RETURN Z TO CURRENT LAYER
G90 ; GO BACK TO ABSOLUTE CORDS
========

########
G91 ; USE RELATIVE POSITION
G1 E-3 F1800 ; RETRACT 3MM
G1 Z2 F2000 ; MOVE UP 2 MM
G90 ; ABSOLUTE POSITION
G1 F13000 X200 Y200 ; QUICK MOVE REAR RIGHT
G1 F1000 X205 ; PRESS SWITCH
G1 F9000 X199 ; MOVE SLIGHT LEFT
G4 P500 ; PAUSE FOR 0.5 SECS
G91 ; RELATIVE POSITION
G1 E9 F1800 ; RESTORE FILAMENT
G1 Z-2 F2000 ; RETURN Z TO CURRENT LAYER
G90 ; GO BACK TO ABSOLUTE CORDS
########

@@@@@@@@
G91 ; USE RELATIVE POSITION
G1 E-3 F1800 ; RETRACT 3MM
G1 Z2 F2000 ; MOVE UP 2 MM
G90 ; ABSOLUTE POSITION
G1 F13000 X200 Y200 ; QUICK MOVE REAR RIGHT
G1 F1000 X205 ; PRESS SWITCH
G1 F9000 X199 ; MOVE SLIGHT LEFT
G4 P500 ; PAUSE FOR 0.5 SECS
G91 ; RELATIVE POSITION
G1 E9 F1800 ; RESTORE FILAMENT
G1 Z-2 F2000 ; RETURN Z TO CURRENT LAYER
G90 ; GO BACK TO ABSOLUTE CORDS
@@@@@@@@
</code></pre>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/56115</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/56115</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 20 Jul 2020 20:50:58 GMT</pubDate></item><item><title><![CDATA[Reply to Inserting g code using replace on Mon, 20 Jul 2020 19:41:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/crafty-crafty" aria-label="Profile: Crafty-Crafty">@<bdi>Crafty-Crafty</bdi></a> said in <a href="/post/56106">Inserting g code using replace</a>:</p>
<p dir="auto">In such a case I would record a macro with these steps.</p>
<ol>
<li>
<p dir="auto">make sure your find dialog has only <strong>normal</strong> search mode enabled.<br />
Everything else unchecked. -&gt; Close File dialog</p>
</li>
<li>
<p dir="auto">On top of your file create the needed layout</p>
</li>
</ol>
<pre><code class="language-z">;Layer:
G91 ; USE RELATIVE POSITION
G1 E-3 F1800 ; RETRACT 3MM
G1 Z2 F2000 ; MOVE UP 2 MM
G90 ; ABSOLUTE POSITION
G1 F13000 X200 Y200 ; QUICK MOVE REAR RIGHT
G1 F1000 X205 ; PRESS SWITCH
G1 F9000 X199 ; MOVE SLIGHT LEFT
G4 P500 ; PAUSE FOR 0.5 SECS
G91 ; RELATIVE POSITION
G1 E9 F1800 ; RESTORE FILAMENT
G1 Z-2 F2000 ; RETURN Z TO CURRENT LAYER
G90 ; GO BACK TO ABSOLUTE CORDS
</code></pre>
<ol start="3">
<li>
<p dir="auto">Select <code>;Layer:</code></p>
</li>
<li>
<p dir="auto">Macro-&gt;start recording</p>
</li>
<li>
<p dir="auto">Press F3 (assuming you do not have remapped this shortcut, see menu <strong>Search-&gt;Find Next</strong>)</p>
</li>
<li>
<p dir="auto">press <strong>End</strong> key (you should see that the word is deselected and at the end of the line)</p>
</li>
<li>
<p dir="auto">press <strong>ENTER</strong> -&gt; Now you should have the layout you want to have</p>
</li>
<li>
<p dir="auto">Stop recording</p>
</li>
<li>
<p dir="auto">Now you can test if it does what it should by executing <strong>Macro-&gt;Playback</strong> if it does, run <strong>Macro-&gt;Run a macro multiple times</strong>, check <strong>Run until end of file</strong> and press <strong>OK</strong>.</p>
</li>
<li>
<p dir="auto">Undo step 2</p>
</li>
</ol>
<p dir="auto">Sounds like a lot to do but in reality it just take 10 seconds.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/56110</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/56110</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 20 Jul 2020 19:41:27 GMT</pubDate></item></channel></rss>