Questions tagged [newline]

Newline refers to a character sequence representing a line break in text (also known as End of Line, EOL, or Line Break). Different operating systems have different sequences for newlines.

Newline refers to a character sequence representing a line break in text (also known as End of Line, EOL, or Line Break). Different operating systems have different sequences for newlines.

5080 questions
678
votes
13 answers

Make 'git diff' ignore ^M

In a project where some of the files contain ^M as newline separators, diffing these files is apparently impossible, since git diff sees the entire file as just a single line. How does one git diff when comparing the current and previous versions of…
neoneye
  • 50,398
  • 25
  • 166
  • 151
646
votes
13 answers

What are carriage return, linefeed, and form feed?

What is the meaning of the following control characters: Carriage return Line feed Form feed
ashna
  • 7,159
  • 4
  • 20
  • 9
638
votes
15 answers

What does the ^M character mean in Vim?

I keep getting the ^M character in my .vimrc and it breaks my configuration.
Max
  • 6,383
  • 3
  • 15
  • 6
623
votes
39 answers

How can I insert a line break into a component in React Native?

I want to insert a new line (like \r\n,
) in a Text component in React Native. If I have:
Hi~
this is a test message.
Then React Native renders Hi~ this is a test message. Is it possible render text to add a…
Curtis
  • 6,242
  • 2
  • 10
  • 8
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
587
votes
6 answers

How do I force Git to use LF instead of CR+LF under Windows?

I want to force Git to check out files under Windows using just LF not CR+LF. I checked the two configuration options, but was not able to find the right combination of settings. I want to convert all files to have LF line breaks and keep the LF in…
sorin
  • 161,544
  • 178
  • 535
  • 806
502
votes
15 answers

What is the JavaScript string newline character?

Is \n the universal newline character sequence in JavaScript for all platforms? If not, how do I determine the character for the current environment? I'm not asking about the HTML newline element (
). I'm asking about the newline character…
Landon Kuhn
  • 76,451
  • 45
  • 104
  • 130
500
votes
14 answers

Replace a newline in TSQL

I would like to replace (or remove) a newline character in a TSQL-string. Any Ideas? The obvious REPLACE(@string, CHAR(13), '') just won't do it...
Peter
  • 47,963
  • 46
  • 132
  • 181
459
votes
21 answers

Split Java String by New Line

I'm trying to split text in a JTextArea using a regex to split the String by \n However, this does not work and I also tried by \r\n|\r|n and many other combination of regexes. Code: public void insertUpdate(DocumentEvent e) { String split[],…
dr.manhattan
  • 4,842
  • 3
  • 19
  • 10
453
votes
12 answers

How to find out line-endings in a text file?

I'm trying to use something in bash to show me the line endings in a file printed rather than interpreted. The file is a dump from SSIS/SQL Server being read in by a Linux machine for processing. Are there any switches within vi, less, more,…
Marco Ceppi
  • 7,163
  • 5
  • 31
  • 43
452
votes
15 answers

./configure : /bin/sh^M : bad interpreter

I've been trying to install lpng142 on my fed 12 system. Seems like a problem to me. I get this error [root@localhost lpng142]# ./configure bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory [root@localhost lpng142]# How do I…
Vineeth Pradhan
  • 8,201
  • 7
  • 33
  • 34
439
votes
23 answers

How to convert DOS/Windows newline (CRLF) to Unix newline (LF)

How can I programmatically (not using vi) convert DOS/Windows newlines to Unix newlines? The dos2unix and unix2dos commands are not available on certain systems. How can I emulate them with commands such as sed, awk, and tr?
Koran Molovik
  • 4,415
  • 3
  • 16
  • 3
417
votes
10 answers

How do I handle newlines in JSON?

I've generated some JSON and I'm trying to pull it into an object in JavaScript. I keep getting errors. Here's what I have: var data = '{"count" : 1, "stack" : "sometext\n\n"}'; var dataObj = eval('('+data+')'); This gives me an error:…
polarbear
  • 12,425
  • 6
  • 29
  • 22
410
votes
20 answers

Writing string to a file on a new line every time

I want to append a newline to my string every time I call file.write(). What's the easiest way to do this in Python?
kaushik
  • 5,609
  • 4
  • 23
  • 17
401
votes
14 answers

Pass a PHP variable to a JavaScript variable

What is the easiest way to encode a PHP string for output to a JavaScript variable? I have a PHP string which includes quotes and newlines. I need the contents of this string to be put into a JavaScript variable. Normally, I would just construct my…
David Laing
  • 7,605
  • 10
  • 33
  • 44