Questions tagged [carriage-return]
Carriage return is one of the control characters in ASCII code, Unicode, EBCDIC, and many other codes. It commands a printer, or other output systems such as the display of a system console, to move the cursor's position to the first position on the same line.
894
questions
1247
votes
26
answers
1.0m
views
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?
1163
votes
10
answers
1.7m
views
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.
831
votes
29
answers
698k
views
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?
822
votes
12
answers
707k
views
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 ...
788
votes
11
answers
1.2m
views
Bash script – "/bin/bash^M: bad interpreter: No such file or directory" [duplicate]
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 &...
738
votes
44
answers
679k
views
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", &...
706
votes
13
answers
510k
views
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 ...
689
votes
9
answers
259k
views
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 ...
669
votes
13
answers
694k
views
What are carriage return, linefeed, and form feed?
What is the meaning of the following control characters:
Carriage return
Line feed
Form feed
662
votes
15
answers
446k
views
What does the ^M character mean in Vim?
I keep getting the ^M character in my .vimrc and it breaks my
configuration.
618
votes
7
answers
434k
views
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 ...
522
votes
38
answers
429k
views
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?
452
votes
15
answers
610k
views
./configure : /bin/sh^M : bad interpreter [duplicate]
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 ...
449
votes
23
answers
627k
views
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 ...
298
votes
4
answers
381k
views
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.
267
votes
21
answers
495k
views
Remove carriage return in Unix
What is the simplest way to remove all the carriage returns \r from a file in Unix?
248
votes
9
answers
425k
views
See line breaks and carriage returns in editor
Is there a text editor on Linux that allows me to see line breaks and carriage returns? Does Vim support this feature?
239
votes
3
answers
370k
views
How to prevent that CR and LF are changed when writing bytes to file?
I have a function that returns a string. The string contains carriage returns and newlines (0x0D, 0x0A). However when I write to a file it contains only the new line feeds. Is there a way to get the ...
225
votes
6
answers
185k
views
Find and replace - Add carriage return OR Newline
In the case of following string to be parsed.
ford mustang,10,blue~~?bugatti veyron,13,black
I want to replace the ~~? with a carriage return
Replacing with \n just adds the string "\n"
How can ...
202
votes
15
answers
141k
views
What are these ^M's that keep showing up in my files in emacs?
I think it may have to do with TextMate, but we work in a small team and are having some issues with full-file conflicts of nearly identical files in git – in one branch the files have a ^M appended ...
150
votes
11
answers
102k
views
^M at the end of every line in Vim
When I am editing source files using Vim and other editors, sometimes I get these ^M characters at the end of each line.
I think that it has something to do with editing a file on Windows and then on ...
142
votes
17
answers
222k
views
Text Editor which shows \r\n? [closed]
I'm looking for a text editor that can show me the actual carriage returns and newlines.
E.g. if I save this string: "This\rIs\r\nA\nString"
Instead of showing
This
Is
A
String
I'm looking for ...
139
votes
13
answers
243k
views
Removing carriage return and linefeed from the end of a string in C#
How do I remove the carriage return character (\r) and
the Unix newline character(\n) from the end of a string?
119
votes
1
answer
110k
views
Insert the carriage return character in Vim
I'm editing a network protocol frame stored in a file in Unix (\n newlines). I need to insert the carriage return character (U+000D also known as \r or ^M).
When I try to paste it from the clipboard (&...
109
votes
16
answers
68k
views
Are shell scripts sensitive to encoding and line endings?
I am making an NW.js app on macOS, and want to run the app in dev mode
by double-clicking on an icon.
In the first step, I'm trying to make my shell script work.
Using VS Code on Windows (I wanted to ...
108
votes
5
answers
54k
views
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 ...
104
votes
17
answers
123k
views
'^M' character at end of lines
When I run a particular SQL script in Unix environments, I see a '^M' character at the end of each line of the SQL script as it is echoed to the command line.
I don't know on which OS the SQL script ...
102
votes
15
answers
314k
views
How can I insert new line/carriage returns into an element.textContent?
Let's say I want to dynamically create a new DOM element and fill up its textContent/innerText
with a JS string literal.
The string is so long I would like to split it into three chunks:
var h1 = ...
94
votes
8
answers
292k
views
What are the differences between char literals '\n' and '\r' in Java?
In Java, the newline and carriage return characters are both seem to be showing same effect.
What are the actual differences between char literals \n and \r in Java?
Note that the above asks about ...
91
votes
8
answers
254k
views
What's the Use of '\r' escape sequence?
I have C code like this:
#include<stdio.h>
int main()
{
printf("Hey this is my first hello world \r");
return 0;
}
I have used the \r escape sequence as an experiment. When I run the ...
83
votes
6
answers
106k
views
Does Windows carriage return \r\n consist of two characters or one character?
Windows carriage return is \r\n while it is \n in Unix, is \r\n treated as two characters?
82
votes
10
answers
68k
views
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 ...
70
votes
9
answers
251k
views
How can I remove "\r\n" from a string in C#? Can I use a regular expression?
I am trying to persist string from an ASP.NET textarea. I need to strip out the carriage return line feeds and then break up whatever is left into a string array of 50 character pieces.
I have this ...
70
votes
10
answers
306k
views
SQL query for a carriage return in a string and ultimately removing carriage return
SQL query for a carriage return in a string and ultimately removing carriage return
I have some data in a table and there are some carriage returns in places where I don't want them. I am trying to ...
66
votes
10
answers
124k
views
"/usr/bin/python^M: bad interpreter" [duplicate]
Cannot figure out, where to change EOF in PyCharm.
My scripts start with :
#!/usr/bin/python
# -*- coding: utf-8 -*-
It outputs something like this when I try to run it like an executable (chmode +x) ...
66
votes
9
answers
208k
views
In C#, what's the difference between \n and \r\n?
In C#, what's the difference between \n and \r\n?
61
votes
3
answers
123k
views
How to match whitespace, carriage return and line feed using regular expression in PHP?
I am working with a regular expression in PHP. I have the following string:
<img
src="/files/admin/hotel_website.gif" alt="Go To The Hotel's Web
Site" align="absmiddle" border="0" class="...
60
votes
12
answers
32k
views
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 ...
55
votes
6
answers
242k
views
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() ...
49
votes
1
answer
193k
views
How to add a newline (line break) in an XML file?
I have an XML file and I would like to make a new line in the text
"Sample Text 123" like this
Sample
Text 123
I've tried already everything I mean 
 
 \n but nothing works:
...
43
votes
3
answers
46k
views
Start a new line in wpf textbox
I created a small GUI with WPF, containing a Textbox.
I want the user to have the ability to start a new line .
How do I let the user start a new line in the WPF textbox (with \n or \r)?
I want the ...
43
votes
11
answers
97k
views
Anything like dos2unix for Windows?
I have some shell scripts created on Windows.
I want to run dos2unix on them.
I have read that dos2unix works on Linux.
Is there a way that I can convert my files to having Unix newlines while working ...
42
votes
10
answers
31k
views
How to strip CR (^M) and leave LF (^J) characters?
I am trying to use Hexl mode to manually remove some special characters from a text file and don't see how to delete anything in Hexl mode.
What I really want is to remove carriage return and keep ...
42
votes
14
answers
196k
views
Inserting line breaks into PDF
I'm generating some PDF file on the fly using PHP. My problem is I need to insert line breaks in some part of the text that will be inserted in the PDF file. Something like:
$pdf->InsertText('Line ...
40
votes
5
answers
164k
views
How can I create a carriage return in my C# string
I have C# code that creates HTML. One particular piece of code creates a long string which is no problem for the browser. However when I look at the code with view > source it's difficult to see ...
40
votes
1
answer
65k
views
Finding line break and carriage return (\r\n) in MySQL
I can't seem to find any info about this on the internet (or I'm just not looking in the right direction).
I have a few fields in my MySQL database containing a carriage return and line break \r\n .
...
40
votes
2
answers
26k
views
How to disable ^M line endings in VS Code?
VS Code has decided to start adding ^M characters to the end of any
line I edit.
They're not visible in the editor but git diff picks them up.
It wasn't doing this before, so I'm guessing I ...
39
votes
11
answers
118k
views
In Perl, how to remove ^M from a file?
I have a script that is appending new fields to an existing CSV, however ^M characters are appearing at the end of the old lines so the new fields end up on a new row instead of the same one. How do I ...
38
votes
4
answers
72k
views
Remove carriage return and space from a string
I want to remove carriage return and space from a string
for exemple:
var t =" \n \n aaa \n bbb \n ccc \n";
I want to have as result:
t = "aaa bbb ccc"
I use this one, it removes carriage ...
34
votes
5
answers
146k
views
Carriage return and Line feed... Are both required in C#?
When inserting a new line character into a string I have usually done this:
str = "First line\nSecond line";
In C#, is this the standard practice? Should I also include the 'carriage return' ...