Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I just made a .txt file with my laptop (that runs Ubuntu 14.04), and when i open it with my Computer (runs Windows 10) it shows it like I wrote everything in one line

Maybe it's a dumb question, but I'm new to Ubuntu.

for example:

Ubuntu txt file

Windows same txt file

share|improve this question

marked as duplicate by Takkat, Community Feb 24 at 16:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Notepad is crap. Practically anything else will do better. – muru Feb 24 at 13:21
@muru agreed. Try Notepad++ Far better :-) – Rinzwind Feb 24 at 13:29
On Windows, you can use Wordpad. It's built-in and supports *NIX linefeeds. (No, I didn't said it is better!) – Ismael Miguel Feb 24 at 14:21
up vote 17 down vote accepted

Text files created on Windows machines have different line endings than files created on Linux.

  • Windows uses carriage return and line feed (\r\n)
  • Linux uses just line feed (\n).

There are a couple of methods to have it work on both ends:

  • When copying text files you need to use a tool that supports converting text files (like "winscp" on Windows).
  • With Windows Notepad++ you can replace \n by \r\n. Normal Notepad will not have this feature.
  • On Ubuntu you can use unix2dos testfile1.txt and dos2unix testfile2.txt to change line endings from one to the other. Also you can use the replace \n by \r\n on most editors or editors will have an option to switch between the too (like Serg in comments mentioned "nano").
share|improve this answer
Some editors support saving in Windows format, for instance nano – Serg Feb 24 at 13:25
As well, gedit which the user is using can also save as Windows format - File > Save As..., and select the line ending style to Windows. – Thomas W. Feb 24 at 13:40
@ThomasW. i found it in gedit, thanks :) – Saviih Feb 24 at 13:47
I don't understand why Windows has to follow the archaic convention of using a carriage return when \n (newline) is the standard way of denoting one. – Bharadwaj Raju Mar 15 at 9:13

If your concern is to be able to open any arbitrary text file created on Linux in Windows, here are a couple of solutions.

First: Use Wordpad. Wordpad included in all recent versions of Windows is able to open Unix style text files. This is not always ideal, as it is not a text editor per se, but it can be a quick and easy way to open your Unix-style text files on Windows if you have not installed additional software.

Second: Install another text editor. If you control the box and use it regularly, this probably better. Most third party text editors will support both text styles. Two common, lightweight, and free options are Notepad2, which is a drop-in replacement for Notepad with a few extra features and Notepad++ which has a bit more features.

share|improve this answer

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