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

Sometime I have to use the text files created in Ubuntu, using editors, in Windows editors. So basically when ever I create a text file in Ubuntu I append the extension .txt, and it does make the file open in Windows very easily.

But the actual problem is the text files created in Ubuntu are so difficult to understand (read) when opened in Windows' Notepad. No matter how many lines have been used, all the lines appear in the same one line.

Is there a easy way to save the text files in Ubuntu's basic editors so that it can be seen exactly the same in Windows' notepad?

share|improve this question
If you're open to alternatives, I'd recommend Notepad++, a free source code editor with syntax highlighting and more. It handles standard Unix file endings perfectly and offers a conversion function. –  minerz029 Nov 16 '13 at 7:33

2 Answers 2

up vote 14 down vote accepted

Unlike Unix where a new line is represented by a LF character we need a combination CR/LF for files in DOS/Windows:


We can let Gedit save text documents with Windows-style line endings in the File -> Save as dialog.

  • Adjust the settings for Line Endings in the drop down menu to Windows.

    enter image description here


To make nano write text files in DOS format we have to run it with the following command line option 1:

nano --dos <filename>


Vim can convert files from Unix to DOS format with the following control sequences 2 :

:e ++ff=dos


To set the buffer coding to DOS style issue Meta + x :

set-buffer-file-coding-system utf-8-dos
share|improve this answer
Thanks Takkat for your answer. I'm in Office and currently using Windows(no Ubuntu installed). I'll let you know as soon as I reach my home. :) –  Saurav Kumar Nov 13 '13 at 10:56
It would be this much simple I didn't expect. Yes it worked for gedit. Do you know how to achieve it for other editors like nano, vi and Emacs. I'm accepting this answer in a hope you'll find a way and make this question complete and perfect. Thanks.. :) –  Saurav Kumar Nov 13 '13 at 14:55
That's brilliant. Thanks for asking the question and thanks @Takkat for your answer. I will use this a lot! –  doug.numbers Dec 11 '13 at 19:13

Converting Unix-style line termination to Windows-style and back

I'm not sure if it's installed by default. Try this to be sure

sudo apt-get install dos2unix

You can convert the files with this to Windows-style

unix2dos myFileFromUbuntu.txt

And with this back to Unix-style

dos2unix myFileFromWindows.txt

Changing them back is often unnecessary. You will find, that the standard text editors handle Windows-style line termination just fine.

share|improve this answer
Good!! +1 for alternate way.. :) –  Saurav Kumar Nov 13 '13 at 17:05
A bit overkill I would say... –  Dualinity May 8 '14 at 14:13
"Write programs that do one thing and do it well." - Doug McIllroy about the Unix philosophy –  MadMike May 9 '14 at 14:33
@Dualinity Not an overkill if you have many files to convert –  warvariuc Sep 6 '14 at 15:51
+1 for thinking of dos2unix! –  CollDue96 Aug 18 at 5:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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