line-endings

PhpStorm saving with Linux line ending on Windows

岁酱吖の 提交于 2019-11-27 03:04:04
问题 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)? 回答1: 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

Why does Windows use CR LF?

十年热恋 提交于 2019-11-27 01:17:14
问题 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. 回答1: 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

Python get proper line ending

ぃ、小莉子 提交于 2019-11-26 22:44:56
问题 Is there an easy way to get the type of line ending that the current operating system uses? 回答1: 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, '

Convert line-endings for whole directory tree (Git)

允我心安 提交于 2019-11-26 22:29:29
问题 Following situation: I'm working on a Mac running OS X and recently joined a project whose members so far all use Windows. One of my first tasks was to set up the codebase in a Git repository, so I pulled the directory tree from FTP and tried to check it into the Git repo I had prepared locally. When trying to do this, all I got was this fatal: CRLF would be replaced by LF in blog/license.txt. Since this affects all files below the "blog" folder, I'm looking for a way to conveniently convert

What's a quick one-liner to remove empty lines from a python string?

梦想的初衷 提交于 2019-11-26 19:40:25
问题 I have some code in a python string that contains extraneous empty lines. I would like to remove all empty lines from the string. What's the most pythonic way to do this? Note: I'm not looking for a general code re-formatter, just a quick one or two-liner. Thanks! 回答1: How about: text = os.linesep.join([s for s in text.splitlines() if s]) where text is the string with the possible extraneous lines? 回答2: "\n".join([s for s in code.split("\n") if s]) Edit2: text = "".join([s for s in code

Fixing Sublime Text 2 line endings?

折月煮酒 提交于 2019-11-26 19:27:59
Here is my Settings - User config: { "auto_indent": true, "color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme", "default_line_ending": "LF", "detect_indentation": true, "font_size": 10.0, "ignored_packages": [ "Vintage" ], "indent_to_bracket": false, "smart_indent": true, "tab_size": 4, "translate_tabs_to_spaces": true, "trim_automatic_white_space": true, "use_tab_stops": true } Comment to default_line_ending option says: When I create a new file, I check line ending here: As you can see it's still Windows... Any ideas? The comment states // Determines what character(s) are used

Python 2 CSV writer produces wrong line terminator on Windows

别说谁变了你拦得住时间么 提交于 2019-11-26 17:41:29
According to the its documentation csv.writer should use '\r\n' as lineterminator by default. import csv with open("test.csv", "w") as f: writer = csv.writer(f) rows = [(0,1,2,3,4), (-0,-1,-2,-3,-4), ("a","b","c","d","e"), ("A","B","C","D","E")] print writer.dialect.lineterminator.replace("\r", "\\r").replace("\n", "\\n") writer.writerows(rows) print writer.dialect.lineterminator.replace("\r", "\\r").replace("\n", "\\n") This prints \r\n \r\n as expected. But, the created csv-file uses the lineterminator '\r\r\n' 0,1,2,3,4 0,-1,-2,-3,-4 a,b,c,d,e A,B,C,D,E Is this a bug or is there something

'^M' character at end of lines

会有一股神秘感。 提交于 2019-11-26 17:21:19
When I run a particular SQL script in Unix environments, I'm am seeing 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 was originally created. What is causing this and how do I fix it? It's caused by the DOS/Windows line-ending characters. Like Andy Whitfield said, the Unix command dos2unix will help fix the problem. If you want more information, you can read the man pages for that command. Tim Abell Fix line endings in vi by running the following: :set fileformat=unix :w ColinYounger The cause is the

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

时光总嘲笑我的痴心妄想 提交于 2019-11-26 15:42:43
问题 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

How to normalize working tree line endings in Git?

感情迁移 提交于 2019-11-26 12:51:33
问题 I have cloned a repository that had inconsistend line endings. I have added a .gitattributes that sets the text attribute for the files I want to normalize. Now when I commit changes I get the message: warning: CRLF will be replaced by LF in FILE. The file will have its original line endings in your working directory. How can I make git normalize my working copy of the file for me? Preferably I would like git to normalize the entire working tree. 回答1: With Git client 2.16 and higher there is