Find or replace a line ending in CotEditor on Mac

Input a line ending

Typing Option-Return in a input field in the Find window breaks a line.

Find line endings

Textual search

On the normal textual search, the line endings contained in the search string are assumed to be the line ending code used in the document being searched for. That is, it doesn’t match the line endings that differ from the document line ending type.

Regular expression search

As with the textual search, the line endings contained in the search string are assumed to be the line ending code used in the document being searched for. On the other hand, the line endings specified as a metacharacter or a Unicode code point in the regular expression pattern are treated as-is regardless of the line endings type of the target document.

Metacharacters indicating a line ending in the regular expression
PatternDescription
\nU+000A, the line ending character for LF
\rU+000D, the line ending character for CR
\r\nThe sequence of U+000D and U+000A, the line ending character for CRLF
\RAny kind of line endings from 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).

Replace with line endings

As for the text replacing with, all line endings, even ones defined as a metacharacter like\n or captured, are assumed to be the document line ending.

For example, when replacing the find string “dog\Rcow” with the replacement string “$0\r” using the regular expression in a document whose line ending type is LF (\n), the substring “dogcow” in the document matches as well, and theoretically, the regular expression should replace it with “dogcow”; however CotEditor actually replaces it with “dogcow”.

There is currently no way to replace them with line endings other than the document line ending.

See also