<?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[Other thoughts regarding the "ReWrap Text to (Clipboard or 72) width" of the old "TextFX" plugin]]></title><description><![CDATA[<p dir="auto">Hello, <strong>All</strong>,</p>
<p dir="auto">Quite by chance, I came across a <strong>summary</strong> of the features of the old <strong><code>TextFX</code></strong> plugin, and among them, I took another look at the <strong>Rewrap</strong> feature.</p>
<p dir="auto">First, note that the <strong>rewrap</strong> feature is generally <em>VERY</em> difficult to simulate as it <strong>heavily</strong> depends on <strong>current</strong> text :</p>
<p dir="auto">How do we manage <strong>tables</strong>, <strong>sections</strong>, <strong>lists</strong> with <em>bullets</em> or <em>numbers</em> and possible <strong>leading</strong> indentation of the <strong>folded</strong> lines ?</p>
<p dir="auto">Or do we need to <strong>join</strong> all lines of a text in a single very <strong>looooooooong</strong> line <em>FIRST</em>, before the <strong>wrapping</strong> process ?</p>
<hr />
<p dir="auto">This topic has been discussed <strong>many</strong> times. see, for example, the following posts below :</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/post/62750">https://community.notepad-plus-plus.org/post/62750</a>, from <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a></p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/post/54147">https://community.notepad-plus-plus.org/post/54147</a> from mine, where I proposed a <strong>generic</strong> regex</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/post/78262">https://community.notepad-plus-plus.org/post/78262</a> from <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: ekopalypse">@<bdi>ekopalypse</bdi></a>, where he proposed a <strong>Python</strong> script, created with the <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a>’s help</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/post/58881">https://community.notepad-plus-plus.org/post/58881</a> from <a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: michael-vincent">@<bdi>michael-vincent</bdi></a>, where he proposed a <strong>NppExec</strong> script</p>
<hr />
<p dir="auto">If we look at it from the perspective of the old <strong>TextFX</strong> plugin, it would primarily handle text encoded in <strong>ANSI</strong>. in other words, text where <strong>one</strong> char = <strong>one</strong> byte, for <em>EACH</em> character of the <strong>selected</strong> text !</p>
<p dir="auto">So, before the <strong>wrapping</strong> action, we need to :</p>
<ul>
<li>
<p dir="auto">Use the <strong><code>Edit &gt; Blank Operations &gt; TAB to Space</code></strong> option, in order to replace any <strong>tabulation</strong> with the corresponding amount of <strong>space</strong> chars</p>
</li>
<li>
<p dir="auto">Use the <strong><code>Edit &gt; EOL Conversion &gt; Unix (LF)</code></strong> option. However, I don’t think that a <strong>single</strong> line-ending is really necessary</p>
</li>
<li>
<p dir="auto">Use the <strong><code>Encoding &gt; Convert to ANSI</code></strong> option to get an <strong><code>ANSI</code></strong> text</p>
</li>
</ul>
<p dir="auto">Note that the conversion to <strong><code>ANSI</code></strong> could be a problem if it contains some <strong><code>UNICODE</code></strong> characters, <strong>absent</strong> from the present <strong><code>ANSI</code></strong> encoding. Luckily, the <strong>main</strong> characters are <strong>both</strong> present in the different <strong><code>ANSI</code></strong> encodings and in the <strong><code>Unicode</code></strong> encodings, like <strong>UTF-8</strong> ! Anyway, all the few <strong>non-decoded</strong> characters are generally shown as an <strong>interrogation</strong> mark, within your converted <strong><code>ANSI</code></strong> text !</p>
<ul>
<li>
<p dir="auto">Now, you may use the <strong><code>Edit &gt; Line Operations &gt; Join Lines</code></strong> option, first, <em>ONLY IF</em> you would like a <strong>strict</strong> wraping process throughout all the <strong>selected</strong> text</p>
</li>
<li>
<p dir="auto">Then, you run the <strong>wrapping</strong> process which can be, either, <strong>regex</strong> replacement(s) or a <strong>Python</strong> , <strong>Lua</strong> or <strong>NppExec</strong> script</p>
</li>
</ul>
<hr />
<p dir="auto">So, I created an <strong><code>ANSI</code></strong> file composed of the <strong><code>license.txt</code></strong>, followed with the <strong><code>change.log</code></strong>  file of the <strong><code>N++ v8.9.8</code></strong> release, named <strong><code>ORG_LF_ANSI.txt</code></strong></p>
<p dir="auto">Then I copied this file in some <strong>new</strong> tabs to test the different <strong>scenarios</strong> !</p>
<p dir="auto">In this post <a href="https://community.notepad-plus-plus.org/post/54147">https://community.notepad-plus-plus.org/post/54147</a>, I proposed this <strong>generic</strong> regex replacement :</p>
<p dir="auto">SEARCH <strong><code>(?-s)^(?=.{</code>C<code>})(?:.{1,</code>C-3<code>}\x20|.{</code>C-1<code>})\K</code></strong></p>
<p dir="auto">REPLACE <strong><code>\r\n</code></strong>    ( or <strong><code>\n</code></strong> if <strong>Unix</strong> files )</p>
<p dir="auto">Which <strong>mimics</strong> the <strong><code>Edit &gt; Line Operations &gt; Split Lines</code></strong> option</p>
<p dir="auto">However, it happens that, in <strong>last</strong> N++ releases, this regex replacement should be, rather :</p>
<p dir="auto">SEARCH <strong><code>(?-s)^(?=.{</code>C<code>})(?:.{1,</code>C-2<code>}\x20|.{</code>C-1<code>})\K</code></strong></p>
<p dir="auto">REPLACE <strong><code>\r\n</code></strong>    ( or <strong><code>\n</code></strong> if <strong>Unix</strong> files )</p>
<p dir="auto">If I choose the value <strong><code>78</code></strong> in the <strong><code>Settings &gt; Preferences &gt; Margins/Boder/Edge &gt; Vertical Edge settings</code></strong> dialog, select <strong>all</strong> the text and use the <strong><code>Ctrl + I</code></strong> shortcut, the file is <strong>strictly</strong> identical to the other file using the regex <strong><code>(?-s)^(?=.{78})(?:.{1,76}\x20|.{</code>77<code>})\K</code></strong> with <strong><code>\n</code></strong> as replacement ( Verified with <strong><code>ComparePlus v3.00</code></strong> )</p>
<p dir="auto">Now, it seemed that in these identical files, in many lines the <strong>wrapping</strong> process is done <strong>before</strong> the column <strong><code>78</code></strong>, even considering a <strong>correct</strong> wrapping at <strong>end</strong> of a word !</p>
<p dir="auto">So, I imagined this <strong>new</strong> regex replacement, below :</p>
<p dir="auto">SEARCH <strong><code>(?-s)^(.{1,</code>C<code>})(?:[\x20\r\n]*\z|\x20*\R|\x20+)</code></strong> ( with <strong><code>C = 78</code></strong> in our case )</p>
<p dir="auto">REPLACE <strong><code>\1\r\n</code></strong> if <em>Windows</em> file   <strong><code>\1\n</code></strong> if <em>Unix</em> file   <strong><code>\1\r</code></strong> if <em>Mac</em> file</p>
<p dir="auto">Finally, run an <strong><code>Edit &gt; Blank Operations &gt; Trim Trailing Space</code></strong> operation ( or SEARCH <strong><code>\x20+$</code></strong>  and  REPLACE  with <strong><code>Nothing</code></strong> )</p>
<p dir="auto">And indeed, the <strong><code>New_LF_ANSI.txt</code></strong> file  <strong>better</strong> respects the <strong><code>78</code></strong> limit than the <strong><code>Old_LF_ANSI.txt</code></strong> , as shown below :</p>
<p dir="auto"><strong>BEFORE</strong> :</p>
<p dir="auto"><img src="/assets/uploads/files/1792953195290-6b0ae826-a50a-419a-8a21-329f9224e35a-image.jpeg" alt="6b0ae826-a50a-419a-8a21-329f9224e35a-image.jpeg" class=" img-fluid img-markdown" /></p>
<p dir="auto">And</p>
<p dir="auto"><img src="/assets/uploads/files/1792953215711-c0580d90-481b-4bac-b261-7cb5ea3b7fe4-image.jpeg" alt="c0580d90-481b-4bac-b261-7cb5ea3b7fe4-image.jpeg" class=" img-fluid img-markdown" /></p>
<p dir="auto"><strong>AFTER</strong> :</p>
<p dir="auto"><img src="/assets/uploads/files/1792953231073-7f5f2cad-1f0c-4706-8465-92c7e99d469e-image.jpeg" alt="7f5f2cad-1f0c-4706-8465-92c7e99d469e-image.jpeg" class=" img-fluid img-markdown" /></p>
<p dir="auto">And</p>
<p dir="auto"><img src="/assets/uploads/files/1792953243107-bcdc3a1f-ec28-4bb2-8628-1480a38906ac-image.jpeg" alt="bcdc3a1f-ec28-4bb2-8628-1480a38906ac-image.jpeg" class=" img-fluid img-markdown" /></p>
<hr />
<p dir="auto">I also created a <strong><code>New_CRLF_UTF-8.txt</code></strong> file, using the <strong>last</strong> <strong><code>(?-s)^(.{1,78})(?:[\x20\r\n]*\z|\x20*\R|\x20+)</code></strong> regex and the only differences with the <strong><code>New_LF_ANSI.txt</code></strong> file are :</p>
<p dir="auto"><img src="/assets/uploads/files/1792953266356-a0b14962-d8f6-42f7-9635-726c0b814edf-image.jpeg" alt="a0b14962-d8f6-42f7-9635-726c0b814edf-image.jpeg" class=" img-fluid img-markdown" /></p>
<p dir="auto">Because the two chars <strong><code>“</code></strong> and <strong><code>”</code></strong> are coded with <strong>one</strong> byte ( <strong><code>93</code></strong> and <strong><code>94</code></strong> ) in the <em>ANSI</em> text and coded with <strong>three</strong> bytes ( <strong><code>E2 80 9C</code></strong> and <strong><code>E2 80 9D</code></strong> ) in the <em>UTF-8</em> text</p>
<hr />
<p dir="auto">Now, the <strong>wrapping</strong> process of both the <strong><code>TextFX</code></strong> plugin and the <strong><code>Python</code></strong> script are quite <strong>different</strong> : Here is, <strong>successively</strong>, a screenshot from the <strong><code>TextFX_ANSI.txt</code></strong> file and from the <strong><code>PythonCRLF_UTF-8.txt</code></strong> file :</p>
<p dir="auto"><img src="/assets/uploads/files/1792953314340-ab4e772c-e491-444a-9b50-4139e8a8bfcf-image.jpeg" alt="ab4e772c-e491-444a-9b50-4139e8a8bfcf-image.jpeg" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="/assets/uploads/files/1792953332013-e42ce4e9-dd27-4de5-af34-d9d60e2b66b3-image.jpeg" alt="e42ce4e9-dd27-4de5-af34-d9d60e2b66b3-image.jpeg" class=" img-fluid img-markdown" /></p>
<p dir="auto">You can see, in the <strong>change.log</strong> section, that lines regarding, obviously, <strong>different</strong> points are <strong>badly</strong> concatened in a <strong>single</strong> line !</p>
<p dir="auto">Now, if I compare these two files, ignoring all <strong>spaces</strong> and <strong>line-endings</strong>, <strong><code>ComparePlus v3.00</code></strong> returns the picture, below, with differences <strong>mostly</strong> at <strong>end</strong> of the <strong><code>license.txt</code></strong> section and in the <strong><code>change.log</code></strong> section !</p>
<p dir="auto"><img src="/assets/uploads/files/1792953374856-40d4c827-f326-4b00-9ad0-8f92fd772b00-image.jpeg" alt="40d4c827-f326-4b00-9ad0-8f92fd772b00-image.jpeg" class=" img-fluid img-markdown" /></p>
<hr />
<p dir="auto">Finally, I created the <strong><code>NEW_LF_ANSI_Strict.txt</code></strong> file :</p>
<ul>
<li>
<p dir="auto">I did, <strong>first</strong>, an <strong><code>Edit &gt; Line Operations &gt; Join Lines</code></strong> operation which changed <strong>all</strong> text in a very <strong>long</strong> line ( <strong><code>37,410</code></strong> chars )</p>
</li>
<li>
<p dir="auto">Then, I applied the following <strong>regex</strong> replacement against this file</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?-s)^(.{1,78})(?:[\x20\r\n]*\z|\x20*\R|\x20+)</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>\1\n</code></strong></p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Here is a screenshot of the <strong>resulting</strong> file, showing the <strong>end</strong> of the <strong><code>license.txt</code></strong> section and the <strong>beginning</strong> of the <strong><code>change.log</code></strong> section</p>
<p dir="auto"><img src="/assets/uploads/files/1792954812589-e8139c64-2ec0-45b9-bae7-2a8022451759-image.jpeg" alt="e8139c64-2ec0-45b9-bae7-2a8022451759-image.jpeg" class=" img-fluid img-markdown" /></p>
<p dir="auto">As you can verify, the reading of this text is rather <strong>painful</strong> :-((</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/27693/other-thoughts-regarding-the-rewrap-text-to-clipboard-or-72-width-of-the-old-textfx-plugin</link><generator>RSS for Node</generator><lastBuildDate>Sun, 25 Oct 2026 21:38:49 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/27693.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Oct 2026 18:37:05 GMT</pubDate><ttl>60</ttl></channel></rss>