# Handle various types of line endings in CotEditor on Mac

CotEditor can handle various types of line endings. In general, CotEditor uses a single type of line ending set for the document consistently.

## Line ending characters in CotEditor

CotEditor treats the following characters as line ending delimiters.

Line ending types
Label | Unicode name | Code point | Metacharacter | Description
--- | --- | --- | --- | ---
LF | Line Feed | `U+000A` | \n | The standard line endings in UNIX and modern macOS.
CR | Carriage Return | `U+000D` | \r | The line ending used in classic Mac OS.
CRLF | – | `U+000D` `U+000A` | \r\n | The combination of CR and LF line endings. Used mainly in Windows.
NEL | Next Line | `U+0085` |  | A legacy line ending character used mainly in EBCDIC, a kind of character encoding by IBM. Hidden by default.
LS | Line Separator | `U+2028` |  | A control character indicating the separator of lines in Unicode. Hidden by default.
PS | Paragraph Separator | `U+2029` |  | A control character indicating the separator of paragraphs in Unicode. Hidden by default.

The latter three types, NEL, LS, and PS, are hardly used in the real world as line ending delimiters for document files. Therefore, CotEditor hides them by default in the line ending choices.

In contrast, although VT (`U+000B`) and FF (`U+000C`) also visually break lines in CotEditor, they are not regarded as line endings characters.

## Set default line endings

You can set the default line ending type for new documents in the Format settings. This setting is used also when the existing document doesn’t have any line endings.

## Line endings in an existing document

CotEditor detects the line ending used in a document automatically and sets it as the line ending for further input to the document.

If a document has inconsistent line endings, CotEditor automatically alerts and highlights them. For details, see Find inconsistent line endings.

## Inspect the document line ending

You can inspect the type of line endings used in the document either in the following area:

- The label of the Line Endings pop-up menu on the right side of the status bar
- The Document Inspector by choosing View > Inspectors > Document
- The selection of the Line Endings submenu in the Format menu

## Change the document line ending

You can change all the line endings in the document to another either in the following area:

- The Line Endings pop-up menu on the right side of the status bar
- The Line Endings submenu in the Format menu

To convert the document line endings to a hidden one, such as NEL, LS, or PS, open the Line Endings menu by pressing the `Option` key.

## Insert line endings different from document line ending

In general, CotEditor uses only the document line ending when breaking lines so that you don’t need to care about the difference in the line endings types. Even if you insert text with different line endings in some way, such as by CotEditor script or text replacement using the regular expression, CotEditor implicitly converts all line endings in the text to insert to the line ending in the document.

Currently, CotEditor provides only two ways to insert line endings different from the document’s line ending:

- Manually input a line ending character by Unicode code point.
- Paste text containing some different line endings with the Paste Exactly command.

## See also

- Find or replace a line ending
- Find inconsistent line endings
- Input a character using Unicode code point
- Paste text
- Change Format settings