Remove Line Breaks in Sublime Text

Learn how to remove line breaks in Sublime Text with Find and Replace, regular expressions, and multi-cursor editing. Includes steps to check the result and fix common issues.

Before you start

Sublime Text removes line breaks locally on your computer. You do not need an online service or an account. Open the file in Sublime Text and make sure that line endings are visible enough for you to confirm the change. If the text uses Windows or old Mac line endings, you can still remove them; you only need to choose the correct pattern in the Find and Replace tool.

Step-by-step instructions

The fastest method uses Find and Replace. It works for one part of a file or for the whole document.

1) Open the file in Sublime Text.

2) Open Find and Replace. On Windows or Linux, press Ctrl+H. On macOS, press Cmd+Option+F.

3) Turn on regular expressions. In the Find and Replace panel, click the button labeled with a dot and asterisk, or press Alt+R on Windows and Linux. On macOS, use Cmd+Option+R.

4) In the Find field, enter a newline pattern. For a single newline, type \n. For a Windows CRLF line break, use \r\n. If the file may contain a mixture, search for \r?\n.

5) Leave the Replace field empty to remove the line breaks, or type a space if you need to keep words separated.

6) Select the text you want to change, or clear the selection to affect the entire file.

7) Click Replace All. Sublime Text joins the selected lines into one continuous run of text.

If you only need to join a few lines, select them and press Ctrl+J on Windows or Linux, or Cmd+J on macOS. This command joins the selected lines. It is useful for short edits, but the regular-expression method gives you more control over spacing and line-ending types.

Check the output

After using Replace All, scroll through the changed area and check that the text is still readable. If you used an empty replacement, words at the end of one line and the start of the next may appear stuck together, such as "cameramicrophone" instead of "camera microphone". To avoid this, repeat the replacement using a space in the Replace field, but only after reviewing the result. You can also check the status bar or use the undo command to compare the file before and after the change. Press Ctrl+Z on Windows or Linux, or Cmd+Z on macOS, to undo the replacement if the formatting is wrong.

Common problems and next steps

If Replace All does not find the line breaks, confirm that regular-expression mode is active. Without it, Sublime Text searches for the literal characters backslash and n instead of a newline. A file with CRLF line endings may also require \r\n rather than \n, so try the combined pattern \r?\n if the result is inconsistent.

When the joined text is one long line, you can restore the line breaks with the same panel. Open Find and Replace, enter a space or punctuation mark in the Find field, and place the matching text plus \n in the Replace field. This approach is reversible only if you know the original spacing or have not saved the file yet.

For large plain-text transcripts, removing every line break creates a wall of text. If you later need the file for subtitles, a podcast note, or a video description, keep a copy of the original before applying Replace All. Sublime Text operates on the open file, so saving after an unwanted global change can make the original layout harder to recover.