Questions tagged [line-endings]

Line-ending signifies end of line. Depending on operating system line-endings are different.

465 questions
90
votes
6 answers

Why does Windows use CR LF?

I understand the difference between the two so there's no need to go into that, but I'm just wondering what the reasoning is behind why Windows uses both CR and LF to indicate a line break. It seems like the Linux method (just using LF) makes a lot…
Kyle
  • 3,987
  • 9
  • 43
  • 85
90
votes
5 answers

git diff - show me line ending changes?

My editor is changing the line endings of my source files. When I do git diff, I see the same line twice -- once with - and once with + -- with no visible difference. How do I get git diff to show me what this change actually was?
Stonky
  • 983
  • 1
  • 6
  • 5
82
votes
4 answers

Python get proper line ending

Is there an easy way to get the type of line ending that the current operating system uses?
Evan Fosmark
  • 89,147
  • 33
  • 99
  • 116
80
votes
6 answers

How to normalize working tree line endings in Git?

I have cloned a repository that had inconsistend line endings. I have added a .gitattributes that sets the text attribute for the files I want to normalize. Now when I commit changes I get the message: warning: CRLF will be replaced by LF in…
user11171
  • 3,271
  • 4
  • 23
  • 32
78
votes
10 answers

gVim showing carriage return (^M) even when file mode is explicitly DOS

I'm using gVim on Windows. My code shows ^M characters at the end of lines. I used :set ff=dos to no avail. The ^M characters remain for existing lines, but don't show up for newlines I enter. I've switched modes to mac (shows ^J characters) and…
Jerph
  • 4,412
  • 3
  • 37
  • 40
78
votes
9 answers

Configure Visual Studio to use UNIX line endings

We would like to use Visual Studio 2005 to work on a local copy of an SVN repository. This local copy has been checked out by Mac OS X (and updates and commits will only be made under Mac OS X, so no problem there), and as a consequence the line…
moala
  • 4,580
  • 6
  • 41
  • 64
72
votes
12 answers

What's a quick one-liner to remove empty lines from a python string?

I have some code in a python string that contains extraneous empty lines. I would like to remove all empty lines from the string. What's the most pythonic way to do this? Note: I'm not looking for a general code re-formatter, just a quick one or…
Andrew Wagner
  • 17,943
  • 18
  • 70
  • 92
66
votes
7 answers

How do I force unix (LF) line endings in Visual Studio (Express) 2008?

Is there a way to always have LF line endings in Visual Studio? I can never seem to find it!
59
votes
8 answers

How can I make all line endings (EOLs) in all files in Visual Studio Code, Unix-like?

I use Windows 10 Home and I usually use Visual Studio Code (VS Code) to edit Linux Bash scripts as well as PHP and JavaScript. I don't develop anything dedicated for Windows and I wouldn't mind that the default EOLs for all files I edit whatsoever…
user9303970
  • 883
  • 1
  • 7
  • 15
54
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,013
  • 23
  • 54
  • 69
53
votes
8 answers

How can I write a ESLint rule for "linebreak-style", changing depending on Windows or Unix?

As we all know, the linebreaks (new line) used in Windows are usually carriage returns (CR) followed by a line feed (LF) i.e. (CRLF) whereas, Linux and Unix use a simple line feed (LF) Now, in my case, my build server uses supports Linux and Unix…
Ravindra Thorat
  • 1,120
  • 1
  • 11
  • 22
53
votes
7 answers

How to determine the line ending of a file

I have a bunch (hundreds) of files that are supposed to have Unix line endings. I strongly suspect that some of them have Windows line endings, and I want to programmatically figure out which ones do. I know I can just run flip -u or something…
nwahmaet
  • 2,626
  • 3
  • 26
  • 31
49
votes
10 answers

How can I redirect PowerShell output when run from Task Scheduler?

When running a simple PowerShell script from Task Scheduler, I would like to redirect the output to a file. There is a long thread about this very topic here, yet it's not clear if they reached the most appropriate solution in the end. I'm…
cmcginty
  • 101,562
  • 37
  • 148
  • 155
47
votes
2 answers

Does Python csv writer always use DOS end-of-line characters?

I realize that the csv library in Python always generates DOS end-of-line characters. Even if I use the 'wb' mode, even if I use Linux. import csv f = open('output.txt', 'wb'); writer = csv.writer(f) writer.writerow([2,3,4]); f.close() The above…
Vendetta
  • 13,178
  • 19
  • 71
  • 111
47
votes
4 answers

How to fix inconsistent line endings for whole VS solution?

Visual Studio will detect inconsistent line endings when opening a file and there is an option to fix it for that specific file. However, if I want to fix line endings for all files in a solution, how do I do that?
Borek Bernard
  • 43,410
  • 50
  • 148
  • 224
1
2
3
30 31