Notepad++ EOL Conversion – Change line termination character

The EOL conversion in Notepad++ allows you to change the line termination character in a text file. Unix uses line feed (LF), Windows use both carriage return (CR) and line feed (LF), and Macintosh uses (CR) as line termination characters.

Let me show you how this character looks in a normal text file.

Open the file in Notepad++. Click on View -> Show Symbol -> Show All Characters or click this “¶” menu on the toolbar to displays all the characters including CR and LF.

What’s the problem?

The normal text file should not have any issue as there is no difference as such. But when you are creating a file in Window and using it in Unix, it may not give a desirable result. A shell script with Windows EOL will not execute in Unix.

The script execution fails with Command not found and Program exited with status 127 error. The happens because of an additional CR character at the end of the line which becomes CTRL M in Unix. There are ways to find this CTRL M character and remove it.

One way is using Notepad++. You can use Notepad++ to change the line termination character. That is what I am going to show you.

EOL Conversion in Notepad++

Ler’ see how to change the line termination character using Notepad++. Consider the below file which is created in Windows/DOS format.

CR LF is line termination character in Windows/DOS

Now, Go to Edit-> EOL Conversion – > Unix(LF) to change the line termination character to Unix format. Notepad++ quickly removes CRLF and just put LF.

LF is line termination character in Unix

Now, Go to Edit-> EOL Conversion – > Macintosh(CR) to change the line termination character to Unix format. Notepad++ quickly removes LF and just puts CR.

CR line termination character in Macintosh

This is one useful feature that allows you to convert files to a different formats.

Bonus Tip

You can set up Notepad++ to create specific format files by default. There is a setup available.

Go to Settings- -> Preferences–> New Document.

New Document Setup

Go to the Format(Line ending) section. You have Windows(CR LF), UNIX(LF), and Macintosh(CR) options available.

Choose format as per your requirement and click the Close button.

Summary

Notepad++ makes it really easy to convert the file from Windows <–> UNIX <–> Mac format.

I think we have covered this EOL topic very well and you learn a good tip. Please do share and subscribe.

 

Share This: