1

I keep all of my files on a flash drive so that I can move them from computer to computer. When editing .txt files on my Pi, the Enter key acts perfectly normal; showing this on the screen:

This is
a Test.

When I open up the same file on my Windows 10 in Notepad, it shows this:

This isa Test.

As if Enter never registered in the file. However, when I open up the file in Notepad++, it looks like the first example.

I upgraded from a Pi 1 to a Pi 2 a few weeks ago, and I have had the same problem on both systems. I also upgraded from Windows 8 to 10 a while ago, also with no change.

Does anyone know what's going on here, or how to fix it?

2

The effect is the result of the way line endings are handled in Windows vs. Linux. Windows uses a carriage return and line feed while Linux uses a line feed only. You can read more about this here. The reason for the differing results between notepad and notepadd++ is that notepad++ is a little more sophisticated in its handling of line endings (basically it is aware of the difference and can be setup to work with both styles).

This question explains how to convert Windows line endings to Linux line endings, and this question explains the conversion from Linux to Windows line endings.

To covert line endings on your Pi install the dos2unix package, by doing the following:

sudo apt-get install dos2unix

You can read the Man page (documentation) for the unix2dos command with the following command:

man dos2unix

If you are using git, there are config settings that will control the line endings

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.