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
3405
votes
22 answers

Echo newline in Bash prints literal \n

How do I print a newline? This merely prints \n: $ echo -e "Hello,\nWorld!" Hello,\nWorld!
Sergey
  • 47,222
  • 25
  • 87
  • 129
2553
votes
9 answers

How do I break a string in YAML over multiple lines?

I have a very long string: Key: 'this is my very very very very very very long string' I would like to express it over multiple shorter lines, e.g., Key: 'this is my very very very ' + 'long string' I would like to use quotes as above, so…
jjkparker
  • 27,597
  • 6
  • 28
  • 29
2370
votes
12 answers

How to replace a character by a newline in Vim

I'm trying to replace each , in the current file by a new line: :%s/,/\n/g But it inserts what looks like a ^@ instead of an actual newline. The file is not in DOS mode or anything. What should I do? If you are curious, like me, check the question…
Vinko Vrsalovic
  • 330,807
  • 53
  • 334
  • 373
2012
votes
27 answers

How can I remove a trailing newline?

How can I remove the last character of a string if it is a newline? "abc\n" --> "abc"
RidingThisToTheTop
1989
votes
19 answers

Why should text files end with a newline?

I assume everyone here is familiar with the adage that all text files should end with a newline. I've known of this "rule" for years but I've always wondered — why?
Will Robertson
  • 62,540
  • 32
  • 99
  • 117
1799
votes
2 answers

LF will be replaced by CRLF in git - What is that and is it important?

git init git add . Gives the following warnings for many files: The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in . What's the difference between LF and CRLF? What should I…
LearningRoR
  • 26,582
  • 22
  • 85
  • 150
1211
votes
25 answers

Git replacing LF with CRLF

On a Windows machine, I added some files using git add. I got warnings saying: LF will be replaced by CRLF What are the ramifications of this conversion?
mrblah
  • 99,669
  • 140
  • 310
  • 420
1111
votes
10 answers

Difference between CR LF, LF and CR line break types

I'd like to know the difference (with examples if possible) between CR LF (Windows), LF (Unix) and CR (Macintosh) line break types.
eozzy
  • 66,048
  • 104
  • 272
  • 428
954
votes
26 answers

Writing a list to a file with Python, with newlines

How do I write a list to a file? writelines() doesn't insert newline characters, so I need to do: f.writelines([f"{line}\n" for line in lines])
Josh Arenberg
  • 10,078
  • 5
  • 21
  • 17
818
votes
29 answers

Convert DOS/Windows line endings to Linux line endings in Vim

If I open files I created in Windows, the lines all end with ^M. How do I delete these characters all at once?
Bert Hekman
  • 8,987
  • 3
  • 21
  • 14
796
votes
12 answers

Difference between \n and \r?

What’s the difference between \n (newline) and \r (carriage return)? In particular, are there any practical differences between \n and \r? Are there places where one should be used instead of the other?
eozzy
  • 66,048
  • 104
  • 272
  • 428
771
votes
26 answers

How can I echo a newline in a batch file?

How can you you insert a newline from your batch file output? I want to do something like: echo hello\nworld Which would output: hello world
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
745
votes
11 answers

Bash script – "/bin/bash^M: bad interpreter: No such file or directory"

I'm using this tutorial to learn bash scripts to automate a few tasks for me. I'm connecting to a server using putty. The script, located in .../Documents/LOG, is: #!/bin/bash # My first script echo "Hello World!" And I executed the following for…
cartonn
  • 7,654
  • 3
  • 19
  • 19
680
votes
9 answers

What's the strategy for handling CRLF (carriage return, line feed) with Git?

I tried committing files with CRLF-ending lines, but it failed. I spent a whole work day on my Windows computer trying different strategies and was almost drawn to stop trying to use Git and instead try Mercurial. How to properly handle CRLF line…
Daniel Jomphe
  • 16,991
  • 5
  • 29
  • 30
678
votes
40 answers

Why do I keep getting "[eslint] Delete `CR` [prettier/prettier]"?

I am using VS Code with Prettier 1.7.2 and ESLint 1.7.0. After every newline I get: [eslint] Delete `CR` [prettier/prettier] This is the .eslintrc.json: { "extends": ["airbnb", "plugin:prettier/recommended"], "env": { "jest": true, …
bier hier
  • 20,970
  • 42
  • 97
  • 166
1
2 3
99 100