CotEditor’s search treats line endings strictly. While it allows you to search for specific line ending types, using an incorrect specification may prevent matches with the line endings you intend to find.
Tip: Typing Option-Return in a text field in the Find window breaks a line.
On the normal textual search, the line endings contained in the search text 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.
As with the textual search, the line endings contained in the search text 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.
The following metacharacters indicate a line ending in regular expression patterns:
| Metacharacter | Description |
|---|---|
| \n |
|
| \r |
|
| \r\n | The sequence of |
| \R | Any kind of line endings from |
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 text “dog\Rcow” with the replacement text “$0\r” using regular expressions in a document whose line ending type is LF (\n), the text “dog\r\ncow” in the document also matches. Theoretically, the regular expression would replace it with “dog\r\ncow\r”. However, CotEditor actually replaces it with “dog\ncow\n”.
There is currently no way to replace them with line endings other than the document line ending.