gexcen
gexcen

Reputation: 31

How to start a new line with Emacs

I have created a file using emacs but when I open the file all the text comes in one line. What do I enter in emacs so that when I open the file there will be more than one line?

Upvotes: 0

Views: 250

Answers (2)

Adrian Pronk
Adrian Pronk

Reputation: 13906

If Notepad shows the data in one line then that probably means that emacs is not using CRLF as the line terminator.

You can tell emacs to set the line-terminator to CRLF by entering the command Control-XEnterF then when prompted for a coding system, type dos and press Enter.

This should be the default if you're using NT-emacs (the windows version of Emacs).

Upvotes: 1

Chris
Chris

Reputation: 136880

Notepad is a very limited text editor that doesn't support, among other things, Unix-style line endings (<LF>). To save a file in Emacs that will open up properly in Notepad, you need to save it with Windows-style line endings (<CR><LF>).

Likely the easiest solution is to run set-buffer-file-coding-system (bound to C-x RET f by default) and choose undecided-dos, then save the buffer.

Note that this is a limitation of Notepad; files created with Unix-style line endings under Emacs can generally be opened without issue on any number of other text editors, including Vim, Sublime Text, Notepad++, and most IDEs. Simply installing a decent text editor on your Windows machine may be a good alternative to saving with Windows line endings.

Upvotes: 1

Related Questions