Change Line Endings (Encoding Windows/Mac/Unix CR/LF/CRLF) Sublime Text


In the context of text files, line endings or encoding refer to the characters that are used to indicate the end of a line of text.

There are three main types of line endings used in modern operating systems.

  1. Carriage return (CR) - used by older Macintosh Operating Systems
  2. Line feed (LF) - used by Unix/Linux Operating Systems
  3. Carriage return + line feed (CRLF) - used by Windows Operating Systems

To change the line endings (encoding) in Sublime Text, you can use the "Line Endings" option in the "View" menu. Here are the steps:

How to Select Line Endings in Sublime Text
  1. Open the text file in Sublime Text App.
  2. Go to the Menu: View.
  3. Move your cursor to "Line Endings" and you will see the available options: Windows, Unix, and Mac OS 9.
  4. Select the desired line ending format.

Once you select a line ending format, Sublime Text will automatically convert the line endings in the text file to the selected format.


Set Default Line Ending for all files

You can also configure Sublime Text to use a specific default line-ending format for all new files you create. To do this, go to the "Preferences" menu and select "Settings" (Sublime Text -> Settings -> Settings on macOS). In the right-hand pane, add the following line to the user preferences file.

Example:
"default_line_ending": "unix"
Preferences.sublime-settings for line ending
-




Have Questions? Post them here!