<?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[One line per 1000 items in a macro?]]></title><description><![CDATA[<p dir="auto">I have a macro that separates every line with a comma and ’ ’ around it and put everything on one line.</p>
<p dir="auto">111<br />
222<br />
333</p>
<p dir="auto">…becomes ‘111’, ‘222’, ‘333’. I use this with SQL IN to do stuff like “select * from table1 where name in (‘111’,‘222’,'333)”. The problem is that Oracle gives ORA-01795 error if there are more than 1000 items. A workaround is this:</p>
<p dir="auto">select field1, field2, field3 from table1<br />
where  name in (‘value1’, ‘value2’, …, ‘value999’)<br />
or name in (‘value1000’, …, ‘value1999’)<br />
or …;</p>
<p dir="auto">Is anyone able to modify my macro to separate the result into one line per 1000 items?</p>
<pre><code>    &lt;Macro name="Comma separate lists with '' in front and behind" Ctrl="no" Alt="no" Shift="no" Key="0"&gt;
        &lt;Action type="3" message="1700" wParam="0" lParam="0" sParam="" /&gt;
        &lt;Action type="3" message="1601" wParam="0" lParam="0" sParam="(.+)" /&gt;
        &lt;Action type="3" message="1625" wParam="0" lParam="2" sParam="" /&gt;
        &lt;Action type="3" message="1602" wParam="0" lParam="0" sParam="&amp;apos;\1&amp;apos;" /&gt;
        &lt;Action type="3" message="1702" wParam="0" lParam="770" sParam="" /&gt;
        &lt;Action type="3" message="1701" wParam="0" lParam="1609" sParam="" /&gt;
        &lt;Action type="3" message="1700" wParam="0" lParam="0" sParam="" /&gt;
        &lt;Action type="3" message="1601" wParam="0" lParam="0" sParam="\r\n" /&gt;
        &lt;Action type="3" message="1625" wParam="0" lParam="1" sParam="" /&gt;
        &lt;Action type="3" message="1602" wParam="0" lParam="0" sParam="," /&gt;
        &lt;Action type="3" message="1702" wParam="0" lParam="770" sParam="" /&gt;
        &lt;Action type="3" message="1701" wParam="0" lParam="1609" sParam="" /&gt;
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/topic/18843/one-line-per-1000-items-in-a-macro</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 03:25:59 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/18843.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 31 Jan 2020 12:36:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Mon, 10 Feb 2020 08:41:37 GMT]]></title><description><![CDATA[<p dir="auto">Great stuff guys. It works like a charm! Thank you! :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50483</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50483</guid><dc:creator><![CDATA[sepodele]]></dc:creator><pubDate>Mon, 10 Feb 2020 08:41:37 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 07 Feb 2020 21:17:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said in <a href="/post/50404">One line per 1000 items in a macro?</a>:</p>
<blockquote>
<p dir="auto">Add a final line-break ( IMPORTANT )</p>
</blockquote>
<p dir="auto">This is the better solution when dealing with files that you “own”.  Don’t beat your head against the wall trying to come up with the perfect regex for the end-of-file oddity…</p>
<p dir="auto">Editorial:  …Especially since Notepad++ has no native way to force adding of a line-ending right before end-of-file…grrrr…</p>
<p dir="auto">But sometimes it (the regex EOF technique) IS worth thinking about when you have to process files that you either don’t “own” (meaning you can’t change them), or you have to deal with files you receive on a continual basis that maybe don’t end “well”.</p>
<p dir="auto">So this is a good lead-in to a plugin I discovered recently (well, I knew about it for a long time, but just lately had a need for it):  “EditorConfig”  It has the ability to make it so that there is always a line-ending at end-of-file when you save (as well as some other nice features – “how many spaces is a tab”, etc.), so, at least for your own files, worrying about the right regex for handling an oddball bottom-of-file situation becomes moot.  The plugin allows settings on a “project by project” (or file-by-file) basis, so it is much more encompassing than some of Notepad++'s native configuration-by-extension settings.</p>
<p dir="auto">I quickly decided I love EditorConfig, for many reasons.  OT: I even noticed that Visual Studio respects the configuration files I made for EditorConfig, automatically – nice.  Except I noticed this when I was hacking Notepad++ source (which uses tab characters) and since my config files (created for other projects) said “no tabs!”, VS was also inserting spaces when I hit the Tab key.</p>
<p dir="auto">Bottom line:  EditorConfig is a good plugin, and can easily give you the “insert-line-ending-before-end-of-file” capability that Notepad++ doesn’t natively provide – in case you don’t always want to think about what happens when doing regex searches/replacements at end-of-file.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50405</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50405</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 07 Feb 2020 21:17:21 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 07 Feb 2020 21:00:10 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/17627">@sepodele</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a>,</p>
<p dir="auto"><strong>Peter</strong>, you’re <strong>right</strong> about that;-)) In fact, <strong>after</strong> posting, I wondered how the regex would react if the <strong>last</strong> item, in the list, did <strong>not</strong> end with a <strong>line-break</strong>…And, unfortunately, the <strong>last</strong> closing <strong>parenthesis</strong> was <strong>missing</strong> :-((</p>
<p dir="auto">So, out of laziness, rather than <strong>reworking</strong> my <strong>second</strong> S/R, which, obviously, does not cover <strong>all</strong> cases, I admit that I opted for the <strong>easy</strong> way out, simply <strong>adding</strong> the line, below, to my <strong>previous</strong> post :</p>
<ul>
<li>Add a final <strong>line-break</strong> ( IMPORTANT )</li>
</ul>
<p dir="auto">But, <strong>Peter</strong>, you found a <strong>nice</strong> and correct solution by modifying the <strong>first</strong> S/R, which is <strong>easier</strong> to grasp. Thanks !</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50404</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50404</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 07 Feb 2020 21:00:10 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 07 Feb 2020 14:45:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said in <a href="/post/50381">One line per 1000 items in a macro?</a>:</p>
<blockquote>
<p dir="auto">Add a final line-break ( IMPORTANT )</p>
</blockquote>
<p dir="auto">Hmm.  You just issued a challenge, because it’s not like you to make one of the critical steps be outside of a regex. :-)</p>
<ul>
<li>SEARCH <code>^(.+(\R|(\z))){1,10}</code> (or <code>1000</code> for the OP requirements)</li>
<li>REPLACE <code>\r\n$0(?3\r\n)</code></li>
</ul>
<p dir="auto">If the last line in the file doesn’t contain a newline, it will still match for the 1-10 (or 1-1000) line groups; if there is the end-of-file instead of newline, it will add a newline at the end as well; and if the final line is an empty line, it won’t bother putting the extra newline at the end.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50388</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50388</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 07 Feb 2020 14:45:56 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 07 Feb 2020 20:59:31 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/17627">@sepodele</a> and <strong>All</strong>,</p>
<p dir="auto">Ah…, Indeed ! I was a bit <strong>annoyed</strong> to process your <strong>two</strong> lists, below, <strong>simultaneously</strong>, as I needed a way to know <strong>where</strong> to finish one line <strong><code>or name in(..., ...)</code></strong> and begin a <strong>new</strong> one and I decided, on my own, to do the change on any <strong>blank</strong> line</p>
<pre><code class="language-z">512141
123123
129391

ASDKJASD-222
ASDLKJ 222
ASDLKJASD
</code></pre>
<p dir="auto">Now, I understand that you have, <strong>only</strong>, <strong><code>1</code></strong> list, which contains, generally, over <strong><code>1,000</code></strong> items, with <strong>various</strong> characters and that you certainly do <strong>not</strong> need any <strong>comment</strong> line at all ! So, everything is much more <strong>simple</strong> ;-))</p>
<p dir="auto">We just have to consider a <strong>single</strong> list, pasted in a <strong>new</strong> N++ tab, which does <strong>not</strong> contain any <strong>line-break</strong> !</p>
<hr />
<p dir="auto">Now, let’s suppose, for instance, that you have the list of <strong>states of America</strong> ( <strong><code>51</code></strong> states ) and that you want to make a <strong>break</strong> every <strong><code>10</code></strong> lines</p>
<ul>
<li>
<p dir="auto">Open a <strong>new</strong> N++ tab ( <strong><code>Ctrl + N</code></strong> )</p>
</li>
<li>
<p dir="auto">Paste your <strong>list</strong> in this <strong>new</strong> tab</p>
</li>
<li>
<p dir="auto">Add a final <strong>line-break</strong> ( IMPORTANT )</p>
</li>
<li>
<p dir="auto">SEARCH <strong><code>^(.+\R){1,10}</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>\r\n$0</code></strong></p>
</li>
</ul>
<p dir="auto">You should get the text below, with a <strong>line break</strong> added <strong>before</strong> each block of <strong><code>10</code></strong> lines <strong>maximum</strong> :</p>
<pre><code class="language-diff">
Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida
Georgia

Hawaii
Idaho
Illinois
Indiana
Iowa
Kansas
Kentucky
Louisiana
Maine
Maryland

Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey

New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina

South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
Washington D.C.
West Virginia
Wisconsin

Wyoming
</code></pre>
<p dir="auto"><strong>Remark</strong> : If you don’t want to <strong>bother</strong> about adding a <strong>final</strong> line-break, prefer the <strong>Peter</strong>’s solution, in the <strong>next</strong> post !</p>
<hr />
<p dir="auto">Then using this second <strong>regex</strong> S/R :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?-s)\h*(.+?)\h*\R(\R+)?(\z)?|(^\R)</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>(?4select field1, field2, field3 from table1\r\nwhere name in \(:'\1'(?3\)\r\n:(?2\)\r\nor name in \(:,)))</code></strong></p>
</li>
</ul>
<p dir="auto">You’ll get your <strong>expected</strong> text :</p>
<pre><code class="language-diff">select field1, field2, field3 from table1
where name in ('Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','Florida','Georgia')
or name in ('Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland')
or name in ('Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey')
or name in ('New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina')
or name in ('South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','Washington D.C.','West Virginia','Wisconsin')
or name in ('Wyoming')
</code></pre>
<hr />
<p dir="auto"><strong>IMPORTANT</strong> : Of course, in your case, the <strong>break</strong> must occur <strong>after</strong> <strong><code>1,000</code></strong> lines. Then, simply change the <strong>first</strong> regex S/R as below :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>^(.+\R){1,1000}</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>\r\n$0</code></strong></p>
</li>
</ul>
<p dir="auto"><strong>Note</strong> : You may also decide to make the <strong>break</strong> after <strong><code>100</code></strong> or <strong><code>500</code></strong> lines. Just change the <strong>first</strong> regex, <strong>accordingly</strong> ;-))</p>
<p dir="auto">If everything works as you like to, I’ll explain, the regexes, <strong>next</strong> time !</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50381</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50381</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 07 Feb 2020 20:59:31 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 07 Feb 2020 10:33:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> Forgive me. I see I’ve failed to explain my wish accurately again. &lt;insert gif of facepalm here&gt;</p>
<p dir="auto">When I wrote my two examples I didn’t mean that there would be two different lists in one N++ tab. It was just to illustrate that it would sometimes be numbers and sometimes characters. I still need it to separate into a new line for every 1000 items and not after a blank line.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50380</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50380</guid><dc:creator><![CDATA[sepodele]]></dc:creator><pubDate>Fri, 07 Feb 2020 10:33:30 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Thu, 06 Feb 2020 10:22:25 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/17627">@sepodele</a> and <strong>All</strong>,</p>
<p dir="auto">Sorry for my <strong>late</strong> reply (Yesterday, I accompanied an instructor from the <strong>French Ski School</strong> with children from <strong>6-7</strong> years old, all <strong>beginners</strong>… And… it’s <strong>not</strong> as easy as it seems ;-)) Most of them seem to be a bit in the moonlight, looking everywhere else… except the monitor ! They are also quickly <strong>tired</strong>, with many <strong>falls</strong> without gravity, luckily !)</p>
<hr />
<p dir="auto">So, here is my <strong>second</strong>, more <strong>general</strong>, attempt, with the following <strong>rules</strong> :</p>
<ul>
<li>
<p dir="auto">To begin the <strong><code>select ..........</code></strong> section, place the <strong>caret</strong>, at least, <strong><code>2</code></strong> <strong>blank</strong> lines above the <strong>comments</strong> line or above the <strong>first</strong> element of list(s)</p>
</li>
<li>
<p dir="auto">You may add some <strong>comment</strong> lines to identify the different lists. A <strong>comment</strong> line will always <strong>begins</strong> a line with <strong><code>3</code></strong> <strong>sharp</strong> symbols. These possible <strong><code>###....</code></strong> comments must be <strong>preceded</strong> with a <strong>blank</strong> line and may be <strong>followed</strong> by <strong>any</strong> number of <strong>blank</strong> lines, even <strong>none</strong></p>
</li>
<li>
<p dir="auto">To begin a <strong>new</strong> <strong><code>or name in(..., ..., ..., ...)</code></strong> line, simply <strong>add</strong>, at least,  <strong><code>1</code></strong> <strong>blank</strong> line <strong>between</strong> items of <strong>current</strong> list</p>
</li>
<li>
<p dir="auto">The <strong>last</strong> element, of the <strong>last</strong> list, must be <strong>followed</strong> with a final <strong>blank</strong> line</p>
</li>
</ul>
<hr />
<p dir="auto">For instance, let’s imagine the <strong>input</strong> text, below :</p>
<pre><code class="language-diff">

### Your examples :

512141
123123
129391

ASDKJASD-222
ASDLKJ 222
ASDLKJASD


### A TEST :
This is
just a
small test

### French regions :

Auvergne-Rhône-Alpes
Bourgogne-Franche-Comté
Bretagne
Centre-Val de Loire
Corse
Grand Est
Hauts-de-France
Île-de-France
Normandie
Nouvelle-Aquitaine
Occitanie
Pays de la Loire
Provence-Alpes-Côte d'Azur
Guadeloupe
Martinique
Guyane
La Réunion
Mayotte

### List of numbers

37
38
39
40
41
42
43
44
45
46

47
48
49
50
51

52
53
54
55
56
57


### States of America :

Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida
Georgia
Hawaii
Idaho
Illinois
Indiana
Iowa
Kansas
Kentucky
Louisiana
Maine
Maryland
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey
New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
Washington D.C.
West Virginia
Wisconsin
Wyoming
</code></pre>
<p dir="auto">With the following <strong>regex</strong> S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-s)(###.*\R+)|\h*(.+?)\h*\R(\R+)?(\z)?|(^\R){2,}</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?1:(?5select field1, field2, field3 from table1\r\nwhere name in \(:'\2'(?4\)\r\n:(?3\)\r\nor name in \(:,))))</code></strong></p>
<p dir="auto">It would result the following <strong>output</strong> text :</p>
<pre><code class="language-diff">select field1, field2, field3 from table1
where name in ('512141','123123','129391')
or name in ('ASDKJASD-222','ASDLKJ 222','ASDLKJASD')
or name in ('This is','just a','small test')
or name in ('Auvergne-Rhône-Alpes','Bourgogne-Franche-Comté','Bretagne','Centre-Val de Loire','Corse','Grand Est','Hauts-de-France','Île-de-France','Normandie','Nouvelle-Aquitaine','Occitanie','Pays de la Loire','Provence-Alpes-Côte d'Azur','Guadeloupe','Martinique','Guyane','La Réunion','Mayotte')
or name in ('37','38','39','40','41','42','43','44','45','46')
or name in ('47','48','49','50','51')
or name in ('52','53','54','55','56','57')
or name in ('Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','Washington D.C.','West Virginia','Wisconsin','Wyoming')
</code></pre>
<p dir="auto">I hope my example speaks for itself !</p>
<p dir="auto"><strong>Remark</strong> : If you want, in my example, to process, <strong>only</strong>, the <strong>last</strong> list of the <strong>states of America</strong>, simply put the caret <strong><code>2</code></strong> <strong>blank</strong> lines, <strong>above</strong> that list ( so, <strong>right under</strong> number <strong><code>57</code></strong> ) and run the <strong>regex</strong> S/R. Of course, in that case, the <strong><code>Wrap around</code></strong> option will be <strong>un-ticked</strong>, to prevent  for processing from <strong>beginning</strong> of file !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50353</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50353</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 06 Feb 2020 10:22:25 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Tue, 04 Feb 2020 14:57:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> I’m quite overwhelmed by the response to my question but I’d like to try your approach first since it was regex I used to get my macro in the first place.</p>
<p dir="auto">I realize now that I should have specified my wish better in the original post because your solution is made for only digits. What I want/need is for it to comma separate any value on one line. Here are two examples:</p>
<p dir="auto">512141<br />
123123<br />
129391</p>
<p dir="auto">ASDKJASD-222<br />
ASDLKJ 222<br />
ASDLKJASD</p>
<p dir="auto">Should become:</p>
<p dir="auto">‘512141’, ‘123123’, ‘129391’<br />
‘ASDKJASD-222’, ‘ASDLKJ 222’, ‘ASDLKJASD’</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50312</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50312</guid><dc:creator><![CDATA[sepodele]]></dc:creator><pubDate>Tue, 04 Feb 2020 14:57:46 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 11 Nov 2022 17:41:06 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/17627">@sepodele</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@ekopalypse</a> and <strong>All</strong>,</p>
<p dir="auto">Many <strong>thanks</strong>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a> and <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@ekopalypse</a>, for finding a solution to the <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/17627">@sepodele</a> <strong>problem</strong>, in your area of <strong>expertise</strong> ;-))</p>
<p dir="auto">Also, I will try to find a <strong>search/replacement</strong> in my <strong>field</strong>, as well !</p>
<hr />
<p dir="auto">First, let’s build our list of <strong>numbers</strong> :</p>
<ul>
<li>
<p dir="auto">Open a new tab ( <strong><code>Ctrl + N</code></strong> )</p>
</li>
<li>
<p dir="auto">Hit the <strong><code>Enter</code></strong> key <strong>once</strong></p>
</li>
<li>
<p dir="auto">Move <strong>back</strong> to the <strong>very beginning</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">SEARCH <strong><code>(\R)</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>$0$0</code></strong></p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search mode</p>
</li>
<li>
<p dir="auto">Hit, <strong>repeatedly</strong>, on the <strong><code>Replace All</code></strong> button or use <strong>several</strong> times the <strong><code>Alt + A</code></strong> shortcut</p>
</li>
</ul>
<p dir="auto">=&gt; Each time, the number of <strong>empty</strong> lines created increases by a <strong>power of 2</strong>. That is to say that, after <strong><code>10</code></strong> processes, you should get <strong><code>1024</code></strong> <strong>empty</strong> lines ( = <strong><code>2^10</code></strong> )</p>
<ul>
<li>
<p dir="auto">Move <strong>back</strong> to the <strong>very beginning</strong>, if necessary</p>
</li>
<li>
<p dir="auto">Open the <strong>Column Editor</strong> ( <strong><code>Edit &gt; Column Editor...</code></strong> ) or ( <strong><code>Alt + C</code></strong> )</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Number to insert</code></strong> option</p>
</li>
<li>
<p dir="auto">Type in the value <strong><code>1</code></strong> in the <strong><code>3</code></strong> fields</p>
</li>
<li>
<p dir="auto">Do <strong>not</strong> tick the <strong><code>Leading zeros</code></strong> option ( IMPORTANT )</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Dec</code></strong> format</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>OK</code></strong> button</p>
</li>
</ul>
<p dir="auto">=&gt; You get a list of <strong>numbers</strong> from <strong><code>1</code></strong> to <strong><code>1025</code></strong></p>
<hr />
<p dir="auto">Now, let’s build the suitable <strong>regex</strong> S/R to <strong>mimic</strong> the <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a> and <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@ekopalypse</a> solutions. Let’s suppose that you want to <strong>separate</strong> this list in <strong>blocks</strong> of <strong><code>99</code></strong> elements. Then, use the following <strong>regex</strong> S/R :</p>
<p dir="auto">SEARCH <strong><code>((1)|(\d*99)|\d+)\x20*(\R\Z|\z|(\R))</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?2select field1, field2, field3 from table1\5where name in \()'\1'(?5(?3\)\5or name in \(:,):\)\r\n)</code></strong></p>
<ul>
<li>
<p dir="auto">Tick the <strong><code>Wrap Around</code></strong> option</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expresion</code></strong> search mode</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All </code></strong> button</p>
</li>
</ul>
<p dir="auto">Et voilà, <strong>magic</strong>, isn’t it !!!</p>
<p dir="auto">For people using <strong>Unix</strong> files, simply delete the <strong><code>\r</code></strong>, at the <strong>end</strong> of the <strong>replace</strong> expression</p>
<p dir="auto">To <strong>split</strong> the list in blocks of <strong><code>100</code></strong> elements use the <strong>search</strong> regex <strong><code>((1)|(\d*00)|\d+)\x20*(\R\Z|\z|(\R))</code></strong></p>
<p dir="auto">To <strong>split</strong> the list in blocks of <strong><code>999</code></strong> elements use the <strong>search</strong> regex <strong><code>((1)|(\d*999)|\d+)\x20*(\R\Z|\z|(\R))</code></strong></p>
<p dir="auto">To <strong>split</strong> the list in blocks of <strong><code>1,000</code></strong> elements use the <strong>search</strong> regex <strong><code>((1)|(\d*000)|\d+)\x20*(\R\Z|\z|(\R))</code></strong></p>
<p dir="auto">To <strong>split</strong> in blocks of <strong><code>499</code></strong> elements, use the <strong>search</strong> regex <strong><code>((1)|(\d*499|\d*999)|\d+)\x20*(\R\Z|\z|(\R))</code></strong></p>
<p dir="auto">To <strong>split</strong> in blocks of <strong><code>500</code></strong> elements, use the <strong>search</strong> regex <strong><code>((1)|(\d*500|\d*000)|\d+)\x20*(\R\Z|\z|(\R))</code></strong></p>
<p dir="auto">Whatever the <strong>search</strong> regex used, the <strong>replace</strong> regex does <strong>not</strong> change !</p>
<hr />
<p dir="auto"><strong>Notes</strong> :</p>
<pre><code class="language-z">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Search ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
((1)|(\d*99)|\d+)\x20*(\R\Z|\z|(\R))


Group 1 = ((1)|(\d*99)|\d+) = CURRENT number, without POSSIBLE trailing SPACE characters

    Group 2 = (1)           = The number '1', ONLY

    Group 3 = (\d*99)       = CURRENT number, with the LAST TWO digits = '9'

    \d+                     = CURRENT number, WITHOUT the LAST TWO digits = '9'

\x20*                       = Possible SPACE characters, after CURRENT number

Group 4 = (\R\Z|\z|(\R))    = Any kind of Line ENDING

    \R\Z                    = Any Line-BREAK at END of the list

    \z                      = The VERY END of the file, after the LAST number

    Group 5 = (\R)          = Any Line-BREAK, NOT at END of the list

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Replacement ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(?2select field1, field2, field3 from table1\5where name in \()'\1'(?5(?3\)\5or name in \(:,):\)\r\n)


(?2                                                         # IF group 2 ( Number 1 )
select field1, field2, field3 from table1\5where name in \( #     WRITE 'select .... table1' + Line BREAK + 'where name in ('
)                                                           # END group 2

'\1'                                                        # Then, in ALL cases, WRITE a SINGLE quote + CURRENT number + SINGLE quote

(?5                                                         # IF group 5 (Line-BREAK, NOT at END of the list )
(?3                                                         #     IF group 3 ( CURRENT number with the LAST TWO digits are '9' )
\)\5or name in \(                                           #         WRITE ')' + Line BREAK + 'or name in ('
:                                                           #     ELSE
,                                                           #        WRITE ','
)                                                           #     END group 3
:                                                           # ELSE
\)\r\n                                                      #     WRITE ')' + Line BREAK
)                                                           # END group 5
</code></pre>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50225</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50225</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 11 Nov 2022 17:41:06 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 31 Jan 2020 21:47:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a> said in <a href="/post/50217">One line per 1000 items in a macro?</a>:</p>
<blockquote>
<p dir="auto">If I can find time today</p>
</blockquote>
<p dir="auto">For Perl users: install <a href="https://github.com/pryrt/Win32-Mechanize-NotepadPlusPlus" rel="nofollow ugc">Win32::Mechanize:;NotepadPlusPlus</a> into your Perl instance from the github repo (sorry, not quite ready for official CPAN release). (Note that Perl 32-vs-64bit must match Notepad++ 32-vs-64bit)</p>
<p dir="auto">Run the following script with your list of lines (doesn’t even have to be a named or saved file) in the active Notepad++ editor window. Results are equivalent to <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@Ekopalypse</a>’s PythonScript.</p>
<pre><code>use warnings;
use strict;

use Win32::Mechanize::NotepadPlusPlus qw/:main/;

my @lines = split /\R|\0/, editor()-&gt;getText();

my $max_lines = 5;  # change this to 1000 or whatever value you want to have
my $sql = "select field1, field2, field3 from table1\n";
my $template = "where name in (%s)\n";

my $i = 0;
while ($i &lt;= $#lines) {
    my $j = $i + $max_lines - 1;
    $j = $#lines if $j &gt; $#lines;

    $sql .= sprintf $template, join ',', map {qq('$_')} @lines[$i .. $j];
    $template = "or name in (%s)\n" if $i==0;
    $i += $max_lines;
}
print STDERR $sql;

editor-&gt;beginUndoAction();
editor-&gt;setText($sql);
editor-&gt;endUndoAction();
</code></pre>
<p dir="auto">(sorry for the deleted post; my first copy still had <code>editor1</code> (which I was using for debug – so it didn’t matter if I left my script editor as the focus, it would always go to the left editor) rather than <code>editor</code> (which will always use the active editor window)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50223</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50223</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 31 Jan 2020 21:47:32 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 31 Jan 2020 16:21:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> said in <a href="/post/50215">One line per 1000 items in a macro?</a>:</p>
<blockquote>
<p dir="auto">LOL, what’s with all the base64?</p>
</blockquote>
<p dir="auto">This time, primarily for space, and because my Perl solution was technically off-topic for the Forum (*), so didn’t want to clutter for others.  Often, I will also use base64 when I think the OP hasn’t shown any effort, but since <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/17627">@sepodele</a> is a first-time poster, and showed effort by pasting the existing macro, that wasn’t the case here.</p>
<p dir="auto">(*: if I’d had the time to polish it up with my nearly-ready <a href="https://github.com/pryrt/Win32-Mechanize-NotepadPlusPlus" rel="nofollow ugc">Win32::Mechanize::NotepadPlusPlus Perl module</a> commands, and make it work with the files inside Notepad++, rather than just a command-line Perl script, it would’ve been more on-topic.  If I can find time today or this weekend to do that, I will post it here and use it as an example of how to use my Perl module.)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50217</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50217</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 31 Jan 2020 16:21:51 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 31 Jan 2020 15:53:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a></p>
<p dir="auto">:-D if it is not of interest then we minimized wasting space :-D</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50216</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50216</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 31 Jan 2020 15:53:30 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 31 Jan 2020 15:42:31 GMT]]></title><description><![CDATA[<p dir="auto">LOL, what’s with all the base64?<br />
Make 'em demonstrate some thinking?<br />
Gotta push the lever to get the reward?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50215</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50215</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 31 Jan 2020 15:42:31 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 31 Jan 2020 15:36:32 GMT]]></title><description><![CDATA[<p dir="auto">A PS solution might be this</p>
<pre><code>ZnJvbSBOcHAgaW1wb3J0IGVkaXRvcg0KbGluZXMgPSBlZGl0b3IuZ2V0VGV4dCgpLnNwbGl0bGluZXMoKQ0KbWF4X2xpbmVzID0gNSAgIyBjaGFuZ2UgdGhpcyB0byAxMDAwIG9yIHdoYXRldmVyIHZhbHVlIHlvdSB3YW50IHRvIGhhdmUNCnNxbF90ZW1wbGF0ZSA9ICIiIg0Kc2VsZWN0IGZpZWxkMSwgZmllbGQyLCBmaWVsZDMgZnJvbSB0YWJsZTENCiIiIg0KDQpmb3IgaSBpbiByYW5nZSgwLCBsZW4obGluZXMpLCBtYXhfbGluZXMpOg0KICAgIGlmIGkgPT0gMDoNCiAgICAgICAgc3FsX3RlbXBsYXRlICs9ICd3aGVyZSBuYW1lIGluICh7fSlcclxuJy5mb3JtYXQoJywnLmpvaW4oWyIne30nIi5mb3JtYXQoeCkgZm9yIHggaW4gbGluZXNbaTppK21heF9saW5lc11dKSkNCiAgICBlbHNlOg0KICAgICAgICBzcWxfdGVtcGxhdGUgKz0gJ29yIG5hbWUgaW4gKHt9KVxyXG4nLmZvcm1hdCgnLCcuam9pbihbIid7fSciLmZvcm1hdCh4KSBmb3IgeCBpbiBsaW5lc1tpOmkrbWF4X2xpbmVzXV0pKQ0KDQplZGl0b3IuYmVnaW5VbmRvQWN0aW9uKCkNCmVkaXRvci5zZXRUZXh0KHNxbF90ZW1wbGF0ZSkNCmVkaXRvci5lbmRVbmRvQWN0aW9uKCk
</code></pre>
<p dir="auto">It would convert a current document</p>
<pre><code>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</code></pre>
<p dir="auto">to</p>
<pre><code>select field1, field2, field3 from table1
where name in ('1','2','3','4','5')
or name in ('6','7','8','9','10')
or name in ('11','12','13','14','15')
or name in ('16','17')
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/50214</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50214</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 31 Jan 2020 15:36:32 GMT</pubDate></item><item><title><![CDATA[Reply to One line per 1000 items in a macro? on Fri, 31 Jan 2020 14:29:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/17627">@sepodele</a> said in <a href="/post/50204">One line per 1000 items in a macro?</a>:</p>
<blockquote>
<p dir="auto">macro to separate the result into one line per 1000 items?</p>
</blockquote>
<p dir="auto">The macro “language” does not have any idea of decisions, counters, indexes, and the like.  It is just a list of windows messages / command IDs that are sent to Notepad++.</p>
<p dir="auto">If you want “decisions” or “counters”, then the Notepad++ macro feature is not what you are looking for.  What you’re really looking for is a script; there are multiple scripting plugins available for Notepad++, including PythonScript and LuaScript.  Or you could use any programming language (compiled, interpreted, or otherwise) to edit a file that’s not inside Notepad++ at the moment.</p>
<p dir="auto">base64-encoded external solution in perl; someone with better python intuition than I have could probably come up with similar for use in the PythonScript plugin.</p>
<pre><code>SWYgeW91IGhhdmUgU3RyYXdiZXJyeSBvciBBY3RpdmVTdGF0ZSBwZXJsIG9uIHlvdXIgbWFjaGluZSwgeW91IGNvdWxkIHJ1biBgcGVybCBxdW90ZWNvbW1hMWsucGwgaW5wdXQudHh0YCB1c2luZyB0aGUgYmFzZTY0LWVuY29kZWQgc2NyaXB0IGJlbG93LCB3aGVyZSBpbnB1dC50eHQgaGFzIHlvdXIgaW5kaXZpZHVhbCBsaW5lcyB0aGF0IHlvdSB3YW50IHRvIHF1b3RlLWFuZC1jb21tYSwgYW5kIGl0IHdvdWxkIHByaW50IHRoZSBjb21tYS1zZXBhcmF0ZWQgbGlzdCB0byBTVERPVVQuDQpgYGANCndoaWxlICg8Pikgew0KICAgIGNob21wOw0KICAgICR4IC49ICcsJyBpZiBsZW5ndGgoJHgpPjA7DQogICAgJHggLj0gc3ByaW50ZiBxcSgnJXMnKSwgJF87DQogICAgaWYoMD09JC4lMTAwMCkgew0KICAgICAgICBwcmludCAkeCwgIlxuIjsNCiAgICAgICAgdW5kZWYgJHg7DQogICAgfQ0KfQ0KcHJpbnQgJHggaWYgbGVuZ3RoKCR4KT4wOw0KYGBgDQo
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/50213</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50213</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 31 Jan 2020 14:29:32 GMT</pubDate></item></channel></rss>