line-endings

git diff - show me line ending changes?

怎甘沉沦 提交于 2019-11-26 12:19:51
My editor is changing the line endings of my source files. When I do git diff , I see the same line twice -- once with - and once with + -- with no visible difference. How do I get git diff to show me what this change actually was? Paul Whittaker First, make sure you're using the coloured output (e.g. with git diff --color ) and that you've enabled whitespace highlighting with (e.g.) git config color.diff.whitespace "red reverse" This might not work in all cases, however, as git doesn't appear to highlight trailing whitespace for removed lines. To see whitespace that you've deleted, simply use

Definitive recommendation for git autocrlf settings

℡╲_俬逩灬. 提交于 2019-11-26 12:17:35
I use Windows, Mac OS X and linux on a daily basis. I use git in all these environments, pulling from repos that are used by folks with different choices for line endings. Are there definitive recommendation for setting core.autocrlf in my situation? VonC I would recommend, as I did in this SO question , to set it to false. If you can avoid modifying any eol (with your editor), then it would be best to push back your work with those eol unchanged (i.e. "as you found them"). One issue that is often not mentioned in these discussions: if you develop shell scripts on windows (say, in cygwin) and

env: bash\r: No such file or directory

浪尽此生 提交于 2019-11-26 12:08:36
问题 I\'m trying to install YouCompleteMe from here. When I execute: ./install.sh --clang-completer I get this error: env: bash\\r: No such file or directory I don\'t know whats wrong with environment variables. Here\'s my bash path: which bash /bin/bash Do I need to change it to /usr/bash? If yes, then how should I do that? I tried changing ~/.bashrc file, but it didn\'t work. 回答1: The error message suggests that the script you're invoking has embedded \r characters , which in turn suggests that

Historical reason behind different line ending at different platforms

喜夏-厌秋 提交于 2019-11-26 11:16:21
问题 Why did DOS/Windows and Mac decide to use \\r\\n and \\r for line ending instead of \\n? Was it just a result of trying to be \"different\" from Unix? And now that Mac OS X is Unix (-like), did Apple switch to \\n from \\r? 回答1: DOS inherited CR-LF line endings (what you're calling \r\n, just making the ascii characters explicit) from CP/M. CP/M inherited it from the various DEC operating systems which influenced CP/M designer Gary Kildall. CR-LF was used so that the teletype machines would

How to read lines of a file in Ruby

浪子不回头ぞ 提交于 2019-11-26 10:07:04
问题 I was trying to use the following code to read lines from a file. But when reading a file, the contents are all in one line: line_num=0 File.open(\'xxx.txt\').each do |line| print \"#{line_num += 1} #{line}\" end But this file prints each line separately. I have to use stdin, like ruby my_prog.rb < file.txt , where I can\'t assume what the line-ending character is that the file uses. How can I handle it? 回答1: I believe my answer covers your new concerns about handling any type of line endings

Fixing Sublime Text 2 line endings?

旧街凉风 提交于 2019-11-26 08:58:06
问题 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

How to find out line-endings in a text file?

半世苍凉 提交于 2019-11-26 07:52:02
问题 I\'m trying to use something in bash to show me the line endings in a file printed rather than interpreted. The file is a dump from SSIS/SQL Server being read in by a Linux machine for processing. Are there any switches within vi , less , more , etc? In addition to seeing the line-endings, I need to know what type of line end it is ( CRLF or LF ). How do I find that out? 回答1: You can use the file utility to give you an indication of the type of line endings. Unix: $ file testfile1.txt

Is it possible for git-merge to ignore line-ending differences?

徘徊边缘 提交于 2019-11-26 05:55:27
Is it possible for git merge to ignore line-ending differences? Maybe I'm asking the wrong question ... but: I tried uisng config.crlf input but things got a bit messy and out of control, specially when I applied it after the fact . For one thing, applying this config after the fact doesn't seem to affect files that were committed to the repository before applying this option. Another thing is that suddenly all commits now result in lots of annoying warning messages about CRLF being converted to LF. To be honest, I don't really care what line-ending is used, I personally prefer the Unix style

Python 2 CSV writer produces wrong line terminator on Windows

烂漫一生 提交于 2019-11-26 05:34:35
问题 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\

&#39;^M&#39; character at end of lines

情到浓时终转凉″ 提交于 2019-11-26 05:24:24
问题 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? 回答1: 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. 回答2: