How to make text file created in Ubuntu compatible with Windows Notepad?
Unlike Unix where a new line is represented by a LF character we need a combination CR/LF for files in DOS/Windows:
Gedit
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.
Nano
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
Vim can convert files from Unix to DOS format with the following control sequences 2 :
:update
:e ++ff=dos
:w
Emacs
To set the buffer coding to DOS style issue Meta + x :
set-buffer-file-coding-system utf-8-dos
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.