Important changes on CotEditor 4.2

Prior to version 4.2.0, all line ending codes were internally treated as LF (U+000A). From version 4.2.0, the actual line ending codes in document files are treated as they are. Therefore, users, especially those who have used earlier versions, require awareness of this change and may need manual migration for some settings.

This page summarizes points that users should be aware of regarding this specification change. You can find the same information in the Help bundled to CotEditor 4.2.0.

Whole Release Notes for CotEditor 4.2.0

Line ending code in the regular expression pattern

Because the previous CotEditor handled all line ending codes as LF internally, \n could be used in regular expression patterns to recognize newlines, regardless of the actual line endings in the document. From CotEditor 4.2.0 on, \n matches only the line endings of which document actually uses LF as the line ending. If you want your documents to match any line endings regardless of the line ending character, use \R instead of \n.

\R is the metacharacter defined in the CUI regular expression engine, which is used in CotEditor; and matches any of a newline character, such as U+000A (LF), U+000B, U+000C, U+000D (CR), U+0085, U+2028, U+2029, or the sequence of U+000D U+000A (CRLF).

Line ending handling in user settings

Scripts and regular expression patterns that assume only LF as line endings may not behave as intended in documents with other line endings than LF on CotEditor 4.2.0 and later. Those user settings require change by the user.

The following user settings require attention to the line ending handling:

Line endings in the Find & Replacement

In the normal textual search and replace, the line endings contain in the search or replace string are assumed as the same as the line ending code used in the document being searched for.

That is, for example, if you search a document in which the line endings are LF for a string containing the CR line ending as a (non-regular expression) text search, all line endings in the search string will be assumed as LF. If you want to handle line endings strictly on search, use the regular expression instead.

On the other hand, regarding the text replacing with, all line endings even ones defined as a metacharacter like \r are assumed as the document line ending. Currently, there is no way to replace with line endings other than the document line ending and this is the same behavior as the previous CotEditor.