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
395
votes
17 answers

'\r': command not found - .bashrc / .bash_profile

I have windows, using Cygwin, trying to set JAVA_HOME permanently through my .bashrc file. .bashrc: export PATH="$JAVA_HOME/bin:$PATH" export JAVA_HOME=$JAVA_HOME:"/cygdrive/c/Program Files (x86)/Java/jdk1.7.0_05" .bash_profile: if [ -f…
Jasmine
  • 4,364
  • 3
  • 16
  • 16
388
votes
7 answers

Render a string in HTML and preserve spaces and linebreaks

I have an MVC3 app that has a details page. As part of that I have a description (retrieved from a db) that has spaces and new lines. When it is rendered the new lines and spaces are ignored by the html. I would like to encode those spaces and new…
Dan dot net
  • 6,119
  • 5
  • 28
  • 25
352
votes
6 answers

CSV in Python adding an extra carriage return, on Windows

import csv with open('test.csv', 'w') as outfile: writer = csv.writer(outfile, delimiter=',', quoting=csv.QUOTE_MINIMAL) writer.writerow(['hi', 'dude']) writer.writerow(['hi2', 'dude2']) The above code generates a file, test.csv, with…
apalopohapa
  • 4,983
  • 5
  • 27
  • 29
345
votes
15 answers

Removing trailing newline character from fgets() input

I am trying to get some data from the user and send it to another function in gcc. The code is something like this. printf("Enter your Name: "); if (!(fgets(Name, sizeof Name, stdin) != NULL)) { fprintf(stderr, "Error reading Name.\n"); …
sfactor
  • 12,592
  • 32
  • 102
  • 152
340
votes
14 answers

How to stop vim from adding a newline at end of file?

So I work in a PHP shop, and we all use different editors, and we all have to work on Windows. I use vim, and everyone in the shop keeps complaining that whenever I edit a file there is a newline at the bottom. I've searched around and found that…
Boushley
  • 6,816
  • 4
  • 27
  • 29
318
votes
9 answers

Bash: Strip trailing linebreak from output

When I execute commands in Bash (or to be specific, wc -l < log.txt), the output contains a linebreak after it. How do I get rid of it?
hexacyanide
  • 88,222
  • 31
  • 159
  • 162
304
votes
17 answers

How to remove line breaks from a file in Java?

How can I replace all line breaks from a string in Java in such a way that will work on Windows and Linux (ie no OS specific problems of carriage return/line feed/new line etc.)? I've tried (note readFileAsString is a function that reads a text file…
tree-hacker
  • 5,351
  • 9
  • 38
  • 39
293
votes
4 answers

What is the difference between a "line feed" and a "carriage return"?

If there are two keywords then they must have their own meanings. So I want to know what makes them different and what their code is.
pheromix
  • 18,213
  • 29
  • 88
  • 158
290
votes
21 answers

How to add line break for UILabel?

Let see that I have a string look like this: NSString *longStr = @"AAAAA\nBBBBB\nCCCCC"; How do I make it so that the UILabel display the message like this AAAAA BBBBB CCCCC I don't think \n is recognized by UILabel, so is there…
Thang Pham
  • 38,125
  • 75
  • 201
  • 285
286
votes
20 answers

Windows batch: echo without new line

What is the Windows batch equivalent of the Linux shell command echo -n which suppresses the newline at the end of the output? The idea is to write on the same line inside a loop.
gregseth
  • 12,952
  • 15
  • 63
  • 96
286
votes
8 answers

How line ending conversions work with git core.autocrlf between different operating systems

I've read a lot of different questions and answers on Stack Overflow as well as git documentation on how the core.autocrlf setting works. This is my understanding from what I've read: Unix and Mac OSX (pre-OSX uses CR) clients use LF line…
Michael Maddox
  • 12,331
  • 5
  • 38
  • 40
286
votes
9 answers

Trying to fix line-endings with git filter-branch, but having no luck

I have been bitten by the Windows/Linux line-ending issue with git. It seems, via GitHub, MSysGit, and other sources, that the best solution is to have your local repos set to use linux-style line endings, but set core.autocrlf to true. …
Brian Donahue
  • 3,052
  • 3
  • 17
  • 11
282
votes
6 answers

Visual Studio Code — Insert Newline at the End of Files

When saving a file using Visual Studio Code, a newline is not automatically added to the end of the file, causing all sorts of potential issues. How can I append a newline automatically in Visual Studio Code?
LJH
  • 7,444
  • 3
  • 10
  • 19
272
votes
32 answers

How do I add a newline to a TextView in Android?

When I define a TextView in xml, how do I add a new line to it? \n seems not to work.
Pentium10
  • 204,586
  • 122
  • 423
  • 502
239
votes
8 answers

How can I use newline '\n' in an f-string to format output?

I tried this code: names = ['Adam', 'Bob', 'Cyril'] text = f"Winners are:\n{'\n'.join(names)}" print(text) However, '\' cannot be used inside the {...} expression portions of an f-string. How can I make it work? The result should be: Winners…
malmed
  • 2,698
  • 2
  • 13
  • 11