line-endings

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

半腔热情 提交于 2019-11-28 13:21:03
问题 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 unix (also shows ^M characters) and back to dos. Has anyone else seen this? 回答1: This happens when you have a mixture of Windows line endings and Unix ones. If you have 100 lines, 99 are \r\n and one is \n, you'll see 99 ^M characters. The fix is to

how C output LF to stdout without being changed to CR LF?

折月煮酒 提交于 2019-11-28 12:23:56
On Windows this #include <stdio.h> int main() { putc('A',stdout); putc('\r',stdout); putc('\n',stdout); } outputs A<CR><CR><LF> How to write just LF char to stdout without automatic conversion to CR LF? I need it to make simple socket stream reader to stdout. I've tried bcc32 from CodeGear, mingw, tinycc all yield same result, changing putc to putchar, fputc, fwrite doesn't help either. The MSVC solution is: #include <io.h> #include <fcntl.h> ... _setmode(1,_O_BINARY) Other runtimes may provide the C99 solution or an alternate way. EDIT: I believe setmode([file number],O_BINARY) originated on

How to WriteAllLines in C# without CRLF

半腔热情 提交于 2019-11-28 10:59:26
I'm using C# and am trying to output a few lines to an ASCII file. The issue I'm having is that my Linux host is seeing these files as: ASCII text, with CRLF line terminators I need this file to be just: ASCII text The CRLF is causing some issues and I was hoping there was a way in C# to just create the file formatted in the way I want. I'm basically using this code: string[] lines = { "Line1", "Line2" }; File.WriteAllLines(myOutputFile, lines, System.Text.Encoding.UTF8); Is there an easy way to create the file without the CRLF line terminators? I can probably take care of it on the Linux side

PhpStorm saving with Linux line ending on Windows

别说谁变了你拦得住时间么 提交于 2019-11-28 10:42:27
Environment: Windows + PhpStorm Issue : PhpStorm saves file with Windows line endings - and for shell script it's issue so there is need to always convert after copying to server. Question : Is possible to configure PhpStorm to save file with Linux line endings - \n and not \n\r (new line + carriage return)? You can safely use \n line ending for .php and most of other files as well -- PHP on Windows will read such files just fine. To set default line ending for all new files: go to Settings/Preferences | Editor | Code Style and change Line separator (for new files) option to the desired style

How to find/fix files with MIXED line endings (0x0d 0x0d 0x0a)

有些话、适合烂在心里 提交于 2019-11-28 07:49:54
问题 I know I can "probably" fix them by using "flip -u" (cygwin flip) which basically removes one of the 0xd's leaving the file with DOS style line endings (0x0d 0x0a) (of course, technically speaking this might be considered a bug!). But the other side of it is that i'd like to do this selectively, ensuring that what I'm fixing really is a "non-binary" file and EXPLICITLY replacing the 0x0d 0x0d 0x0a sequence with 0x0d 0x0a... not running a buggy program that appears to do what I want (and

Why does Windows use CR LF?

萝らか妹 提交于 2019-11-28 06:07:48
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 more sense, saves space, and is easier to parse. Historically when using dot-matrix printers teletypes CR would return the carriage to the first position of the line while LF would feed to the next line. Using CR+LF in the file themselves made it possible to send a file directly to the printer, without any kind of printer driver. Thanks @zaph

Dealing with files that Git refuses to reset?

北城以北 提交于 2019-11-28 01:16:49
问题 I and my collegues are having terrible trouble getting git to behave properly with certain files on our Windows repostiory clones. The clones have been made by cloning a repository which originates on an OSX machine. We have set autocrlf to true, but the problem is that we reguarly find files that git thinks are changed even though we never touch them (we don't even open them in an editor. The following output illustrates the issue: any ideas where I am going wrong? $ git status # On branch

git config core.autocrlf is true, but I'm still getting a warning?

余生长醉 提交于 2019-11-27 23:09:46
问题 I understand that Windows uses CRLF and that it's good practice to let Git change line endings to LF before committing and back to CRLF when checking out. For that reason, I have core.autocrlf set to true. However, contrary to what other threads say (e.g., this), I am still getting this warning: warning: LF will be replaced by CRLF in [FILE_NAME]. The file will have its original line endings in your working directory. Firstly, I thought setting core.autocrlf to true was supposed to stop these

Python get proper line ending

丶灬走出姿态 提交于 2019-11-27 18:55:29
Is there an easy way to get the type of line ending that the current operating system uses? If you are operating on a file that you opened in text mode, then you are correct that line breaks all show up as ' \n '. Otherwise, you are looking for os.linesep . From http://docs.python.org/library/os.html : os. linesep The string used to separate (or, rather, terminate) lines on the current platform. This may be a single character, such as '\n' for POSIX, or multiple characters, for example, '\r\n' for Windows. Do not use os.linesep as a line terminator when writing files opened in text mode (the

Git status ignore line endings / identical files / windows & linux environment / dropbox / mled

两盒软妹~` 提交于 2019-11-27 18:27:10
How do I make git status ignore line ending differences? Background info: I use randomly Windows and Linux to work on the project. The project is in Dropbox. I found a lot about how do make git diff ignore line endings. Since i use meld git diff opens meld for each file. And meld says "identical file". So how do I avoid this. Git should only open meld for changed files. And git status should not report files as changed if only the file ending is different. EDIT: Cause: This happened because of this setting on Windows core.autocrlf true So I checked out the working copy on Linux and set core