Questions tagged [eol]

EOL is short for "end of line". In text files each line is terminated with characters such as linefeed or carriage return or a combination thereof.

EOL stands for "end of line" and refers to the various character or combination of characters that signify the end of each line of a text-based file.

For historical reasons there are various common EOLs:

  • linefeed or newline, ASCII 0x0A: common on systems with Unix heritage including Mac OS X
  • carriage return + linefeed, ASCII 0x0D 0x0A: common on systems with Microsoft DOS and Windows heritage and in text-based internet protocols
  • carriage return, ASCII 0x0D: used on Apple Macintosh up to System 7

These differences can present problems when using files and source code on multiple operating systems. Issues may be encountered with text editors, compilers, and revision controls systems.

See also

380 questions
588
votes
10 answers

How do I get a platform-independent new line character?

How do I get a platform-independent newline in Java? I can’t use "\n" everywhere.
Spoike
  • 119,724
  • 44
  • 140
  • 158
521
votes
38 answers

Convert ^M (Windows) line breaks to normal line breaks

Vim shows ^M on every line ending. How do I replace this with a normal line break in a file opened in Vim?
ByteNirvana
  • 5,640
  • 4
  • 21
  • 20
424
votes
20 answers

When do I use the PHP constant "PHP_EOL"?

When is it a good idea to use PHP_EOL? I sometimes see this in code samples of PHP. Does this handle DOS/Mac/Unix endline issues?
Christian Oudard
  • 48,140
  • 25
  • 66
  • 69
240
votes
4 answers

Force LF eol in git repo and working copy

I have a git repository hosted on github. Many of the files were initially developed on Windows, and I wasn't too careful about line endings. When I performed the initial commit, I also didn't have any git configuration in place to enforce correct…
Chowlett
  • 45,935
  • 20
  • 116
  • 150
199
votes
4 answers

Choose newline character in Notepad++

I notice that when I load a text file, Notepad++ will recognize and use whatever the newline character in that file is, \n or \r\n. Is there some option where I can select which to use by default for new documents? (I've looked in help and googled,…
Luigi Plinge
  • 50,650
  • 20
  • 113
  • 180
176
votes
10 answers

Is it possible for git-merge to ignore line-ending differences?

Is it possible for git merge to ignore line-ending differences? Maybe I'm asking the wrong question ... but: I tried uisng config.crlf input but things got a bit messy and out of control, specially when I applied it after the fact. For one thing,…
hasen
  • 161,647
  • 65
  • 194
  • 231
140
votes
4 answers

EOL conversion in notepad ++

For some reason, when I open files from a unix server on my windows machine, they occasionally have Macintosh EOL conversion, and when I edit/save them again they don't work properly on the unix server. I only use notepad ++ to edit files from this…
Jeff
  • 2,040
  • 3
  • 18
  • 19
109
votes
8 answers

Change EOL on multiple files in one go

Is there any way in Notepad++ (or even with another tool) to change the line ending automatically on multiple files in one go? i.e. convert a mix of windows EOL (CRLF) and UNIX EOL (LF) files to be all Windows EOL (CRLF)
fduff
  • 3,671
  • 2
  • 30
  • 39
96
votes
9 answers

git commit get fatal error "fatal: CRLF would be replaced by LF in"

I'm using Ubuntu 13.10 x64, and I am working on a project that some developers are using Windows , I recently changed the git config core.eol to "lf" and core.autocrlf to "input" and core.safecrlf to "true". Since then, when I try to commit file…
aserww106
  • 1,311
  • 3
  • 12
  • 14
86
votes
19 answers

Windows command to convert Unix line endings?

Is there a Windows command to convert line endings of a file? We have a test.bat which we need to run to start our server. We use Perforce and we need to have unix line endings in our workspace. For some reason, we are not allowed to change line…
Deepti Jain
  • 1,901
  • 4
  • 21
  • 29
78
votes
4 answers

How to change the EOL for all files from CRLF to LF

In Visual Studio Code, I have changed the default EOL (end-of-line token) from CRLF to LF, but this only applies to new files. I would like to know how to change the EOL for all files at once as I have more than a hundred files and it will be hard…
Thong Yi Xuen
  • 1,001
  • 1
  • 9
  • 10
63
votes
2 answers

Regular Expression to match cross platform newline characters

My program can accept data that has newline characters of \n, \r\n or \r (eg Unix, PC or Mac styles) What is the best way to construct a regular expression that will match whatever the encoding is? Alternatively, I could use universal_newline…
Alan
  • 2,140
  • 1
  • 24
  • 30
60
votes
12 answers

Hiding ^M in Emacs

Sometimes I need to read log files that have ^M (control-M) in the line endings. I can do a global replace to get rid of them, but then something more is logged to the log file and, of course, they all come back. Setting Unix-style or dos-style…
Russell
58
votes
5 answers

In Sublime Text 2 How to view carriage return and line feed?

In notepad++ there is a toolbar button to switch on/off display of EOL characters, i.e. carriage return and line feed. Can Sublime Text 2 do the similar thing?
chance
  • 6,307
  • 13
  • 46
  • 70
55
votes
6 answers

Carriage Return\Line feed in Java

I have created a text file in Unix environment using Java code. For writing the text file I am using java.io.FileWriter and BufferedWriter. And for newline after each row I am using bw.newLine() method (where bw is object of BufferedWriter). And I'm…
Manu
  • 3,179
  • 23
  • 57
  • 69
1
2 3
25 26