<?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[Mixed Line Ending Detection. Possible?]]></title><description><![CDATA[<p dir="auto">I learned that it is possible to have files with mixed line endings. I made a file with 3 different line endings (LF, CRLF, CR).<br />
Results: LF has the priority and the file will be recognized as an LF ending file, even if it has other ones in there, (the user can not know unless if he has line endings display turned on and is going through line by line)<br />
CRLF has the priority over CR, and CR is last.</p>
<p dir="auto">This order makes perfect sense and is the way it should be. And, I understand that no file is supposed to have mixed line endings like this and operating systems do not use anything mixed (windows uses CRLF, mac and linux use LF)</p>
<p dir="auto">BUT, it is possible to have files with mixed line endings, thus I would like to be able to detect if a file is in such a condition (without having to turn on line ending display and going through line by line)</p>
<p dir="auto">Does anyone know if this is possible programmatically?</p>
<p dir="auto">(ps. thanks claudia and scott sumner for all the help)</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/15746/mixed-line-ending-detection-possible</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 10:11:16 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/15746.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 08 May 2018 16:48:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mixed Line Ending Detection. Possible? on Mon, 23 Jul 2018 20:00:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: Scott-Sumner">@<bdi>Scott-Sumner</bdi></a> said:</p>
<blockquote>
<p dir="auto">normally it is a difficult task to get a wrong line-ending in your editor buffer</p>
</blockquote>
<p dir="auto">Apparently I shouldn’t have made that statement, as I keep proving it wrong…</p>
<p dir="auto">I normally work with Windows formatted files with <code>\r\n</code> line-endings.  I just noticed that pressing <strong>ctrl+m</strong> (which got done when my fingers got tangled up) will insert a Mac format line-ending <code>\r</code> in my Windows files–blech!.</p>
<h1>:-(</h1>
]]></description><link>https://community.notepad-plus-plus.org/post/33686</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33686</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Mon, 23 Jul 2018 20:00:37 GMT</pubDate></item><item><title><![CDATA[Reply to Mixed Line Ending Detection. Possible? on Thu, 24 May 2018 16:06:55 GMT]]></title><description><![CDATA[<p dir="auto">Oh, so when I paste things into scintilla, scintilla automatically converts whatever eol my paste has to what the document is set to, (which I Can see in the statusbar)</p>
<p dir="auto">I didn’t know that but I guess that makes sense and protects me from mixed line endings.<br />
I like that.</p>
<p dir="auto">I still would like a script to be able to highlight my mixed EOLs though (just the same way I highlight my line final whitespace), or at the least turn on the EOL displays like how your script has.  (which you aren’t pasting here = (       )</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32470</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32470</guid><dc:creator><![CDATA[SalviaSage]]></dc:creator><pubDate>Thu, 24 May 2018 16:06:55 GMT</pubDate></item><item><title><![CDATA[Reply to Mixed Line Ending Detection. Possible? on Wed, 23 May 2018 13:55:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: Scott-Sumner">@<bdi>Scott-Sumner</bdi></a> said:</p>
<blockquote>
<p dir="auto">normally it is a difficult task to get a wrong line-ending in your editor buffer</p>
</blockquote>
<p dir="auto">I just thought I’d point out that with an errant regular-expression replacement, it is actually quite easy to get wrong line-endings in your buffer.  For example, if your <a href="https://notepad-plus-plus.org/community/topic/15811/how-to-find-numbers-and-start-new-lines-with-the-numbers" rel="nofollow ugc">replacement expression involves line-ending characters</a>, make sure you get it correct for your file-type, as shown above.  Scintilla does nothing to protect you from messing up your files in this case (like it does when pasting).  Absolute power (regex) corrupts absolutely!  :-)  Or maybe I should say that it <em>can</em> !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32449</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32449</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Wed, 23 May 2018 13:55:30 GMT</pubDate></item><item><title><![CDATA[Reply to Mixed Line Ending Detection. Possible? on Thu, 10 May 2018 00:23:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: Scott-Sumner">@<bdi>Scott-Sumner</bdi></a></p>
<p dir="auto">Dear Scott, thanks for your input.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32184</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32184</guid><dc:creator><![CDATA[SalviaSage]]></dc:creator><pubDate>Thu, 10 May 2018 00:23:11 GMT</pubDate></item><item><title><![CDATA[Reply to Mixed Line Ending Detection. Possible? on Wed, 09 May 2018 20:53:29 GMT]]></title><description><![CDATA[<p dir="auto">If it is all about <strong>knowing</strong> that a file uses mixed eols only,<br />
then my ¢¢ (CiYrm)</p>
<p dir="auto">Behind the curtant you must see<br />
The dark side never the strength in number it reveal<br />
Don’t hestitate to break out of the loop you must do<br />
if wasting time is not good for you</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32181</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32181</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Wed, 09 May 2018 20:53:29 GMT</pubDate></item><item><title><![CDATA[Reply to Mixed Line Ending Detection. Possible? on Wed, 09 May 2018 19:13:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/salviasage" aria-label="Profile: SalviaSage">@<bdi>SalviaSage</bdi></a></p>
<p dir="auto">That code is wrapped up into something “bigger” that I have–not worth it to me to extract it.  In general, I share code here in a couple of cases:</p>
<ol>
<li>I already have the code done to do a certain specific thing when people post asking how it can be accomplished</li>
<li>Somebody posts an idea (that I hadn’t previously thought of) that can be of use to me; thus I write the code that implements it and share it</li>
</ol>
<p dir="auto">An example of case #2 is your request for <a href="https://notepad-plus-plus.org/community/topic/15507/feature-request-show-only-line-final-whitespace" rel="nofollow ugc">this</a>.  I hadn’t thought of that previously, but when you brought it up, I thought <em>“I can benefit from having that”</em>…and now that it’s done I like it even more than I thought I would.</p>
<p dir="auto">So…yea, if you wanna work on coding it yourself, I can give you hints if you get stuck, but with the framework from that other code a lot of the “hard” part is done already.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a></p>
<p dir="auto">Hi Guy, yea, this comes up a lot it seems, but people seem to want something that runs <em><strong>automagically</strong></em>–and unfortunately running a regular-expression replacement doesn’t fit in that scheme (hmmm, maybe a regex replacement macro that is run at save time–can NppExec do that? dunno…).  However, take heart in that the regexs from your posting above do appear in the code for this, here’s a sample:</p>
<pre><code class="language-z">editor.research(r'\r(?!\n)|(?&lt;!\r)\n', bad_line_ending_callback, 0, start_pos, end_pos)
</code></pre>
<h3>:-D</h3>
]]></description><link>https://community.notepad-plus-plus.org/post/32180</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32180</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Wed, 09 May 2018 19:13:11 GMT</pubDate></item><item><title><![CDATA[Reply to Mixed Line Ending Detection. Possible? on Sat, 19 Nov 2022 01:49:46 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/salviasage" aria-label="Profile: salviasage">@<bdi>salviasage</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: scott-sumner">@<bdi>scott-sumner</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Once more, with a simple <strong>regex</strong>, it’s not that hard to find out if <strong>bad line-endings</strong> exist in a <strong>specific</strong> file ;-)</p>
<ul>
<li>
<p dir="auto">Open the <strong>Find/Replace</strong> dialog and select the <strong><code>Regular expression</code></strong> search mode</p>
</li>
<li>
<p dir="auto">Just click on the <strong><code>Count</code></strong> button to get the <strong>number</strong> of occurrences of the following regexes, depending of the <strong>final</strong> status, wanted for <strong>that</strong> file</p>
</li>
<li>
<p dir="auto">Fill up the <strong><code>Replace with:</code></strong> zone, as well, to get rid of <strong>all wrong</strong> line-endings, and  click on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
<hr />
<p dir="auto">So, <strong>whatever</strong> the <strong>present</strong> status of the file, regarding its <strong>line-endings</strong>, if you want to get a <strong>final</strong> :</p>
<pre><code class="language-a">• WINDOWS file, with line-endings = CRLF  =&gt;    SEARCH =  \r(?!\n)|(?&lt;!\r)\n    REPLACE =  \r\n

• UNIX    file, with line-endings = LF    =&gt;    SEARCH =  \r\n?                 REPLACE =  \n

• MAC     file, with line-ending  = CR    =&gt;    SEARCH =  \r?\n                 REPLACE =  \r
</code></pre>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32179</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32179</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 19 Nov 2022 01:49:46 GMT</pubDate></item><item><title><![CDATA[Reply to Mixed Line Ending Detection. Possible? on Wed, 09 May 2018 18:32:58 GMT]]></title><description><![CDATA[<p dir="auto">Oh, umm… You do know I will be asking for that end-of-line detection code… right?</p>
<p dir="auto">xD xD</p>
<p dir="auto">too bad, you shouldn’t have been such a nice open-source guy.</p>
<p dir="auto">hehehehehehe…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32178</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32178</guid><dc:creator><![CDATA[SalviaSage]]></dc:creator><pubDate>Wed, 09 May 2018 18:32:58 GMT</pubDate></item><item><title><![CDATA[Reply to Mixed Line Ending Detection. Possible? on Wed, 09 May 2018 18:17:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/salviasage" aria-label="Profile: SalviaSage">@<bdi>SalviaSage</bdi></a></p>
<blockquote>
<p dir="auto">If it is that hard to determine that there are bad line endings, then we might as well not bother with it at all!</p>
</blockquote>
<p dir="auto">It’s not necessarily hard, there just isn’t some magic that makes it especially easy.</p>
<p dir="auto">I actually <em>do</em> this line-ending mismatch detection for myself, using pretty much the same technique used in <a href="https://notepad-plus-plus.org/community/topic/15507/feature-request-show-only-line-final-whitespace" rel="nofollow ugc">this thread</a>.  I monitor what is happening in the currently viewable area, figuring that this is the likeliest place for a mismatched line ending to get inserted.  If it is detected, the code turns on visible line-endings (normally I have that turned off) to really hit me with the problem.</p>
<p dir="auto">Perfect?  No.  Really easy? No.  Really hard? No.  Acceptable? Yes.</p>
<p dir="auto">By the way, here is a good way to get Unix line-endings in your Windows files:  Copy some multiline text from the <strong>Pythonscript</strong> console window, then use the <strong>Clipboard History</strong> panel to paste it into a Windows editor tab!  BOOM!  LF(only) line-endings in your Windows buffer.  Note that this series of events goes around Scintilla’s watchful paste protection.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32177</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32177</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Wed, 09 May 2018 18:17:17 GMT</pubDate></item><item><title><![CDATA[Reply to Mixed Line Ending Detection. Possible? on Tue, 08 May 2018 17:29:28 GMT]]></title><description><![CDATA[<p dir="auto">Yes, that is true, it is not a big issue, since they can easily be fixed with notepad++ auto convert feature anyway, by clicking the status bar.</p>
<p dir="auto">If it is that hard to determine that there are bad line endings, then we might as well not bother with it at all!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32158</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32158</guid><dc:creator><![CDATA[SalviaSage]]></dc:creator><pubDate>Tue, 08 May 2018 17:29:28 GMT</pubDate></item><item><title><![CDATA[Reply to Mixed Line Ending Detection. Possible? on Tue, 08 May 2018 17:22:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/salviasage" aria-label="Profile: SalviaSage">@<bdi>SalviaSage</bdi></a></p>
<p dir="auto">So ideally you’d have some code watching to see if you ever get a “bad” line ending in your editor tab buffer.  “bad” is defined as:</p>
<ul>
<li>Your file is <strong>Windows (CR LF)</strong> (see status bar) and you get either a <strong>LF</strong> line-ending or a <strong>CR</strong> line-ending (somehow) in its editing buffer</li>
<li>Your file is <strong>UNIX (LF)</strong> and you get either a <strong>CR LF</strong> line-ending or a <strong>CR</strong> line-ending in its editing buffer</li>
<li>Your file is <strong>MAC (CR)</strong> and you get either a <strong>CR LF</strong> line-ending or a <strong>LF</strong> line-ending in its editing buffer</li>
</ul>
<p dir="auto">However, one of the problems with doing this, at least with one of the scripting languages, is what’s known as the “big file problem”.  As long as your files are relatively small, scanning them often (like when you make a change that could <em>potentially</em> put a wrong line-ending in) runs fairly quickly, but if your files are large then you start to see the time it takes to scan a file because it shows up in a sluggish user interface.</p>
<p dir="auto">So then you make compromises.  You can scan a file for mismatches when it is first opened.  You can scan it at save time.  You can come up with some complex algorithm to scan pieces of it at different times.  Your choice.</p>
<p dir="auto">That being said, normally it is a difficult task to get a wrong line-ending in your editor buffer.  Scintilla normally takes care of keeping the line-endings consistent and correct.  For example, if you copy lines out of a UNIX file buffer and into a Windows file buffer, Scintilla will convert the line endings from LF to CRLF during the paste.  So…is it a really big issue after all?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32156</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32156</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Tue, 08 May 2018 17:22:42 GMT</pubDate></item></channel></rss>