Timeline for How to find out line-endings in a text file?
Current License: CC BY-SA 3.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 22, 2020 at 9:30 | comment | added | galath |
To add from @Samuel's comment, using :set list might be sufficient to find out line endings. See :help binary , option -b only changes a few options.
|
|
Apr 20, 2018 at 22:32 | comment | added | Sundar R |
Note that the fileformat inferred by Vim (and reported by :set fileformat ) prefers towards reporting unix i.e. it reports dos only if every line in the file has CRLF as its line ending, otherwise it reports it as a unix format file. If you think the file might be one of those mixed line-ending abominations, vim can't tell you which lines have \n and which have \r\n .
|
|
S Nov 7, 2017 at 16:26 | history | edited | Engineero | CC BY-SA 3.0 |
fixed a typo in the `od` flags, added alternative
|
Nov 7, 2017 at 16:16 | comment | added | Ron Wertlen |
The utility command od should be the correct answer to this ticket.
|
|
Nov 7, 2017 at 16:15 | review | Suggested edits | |||
S Nov 7, 2017 at 16:26 | |||||
Aug 25, 2017 at 19:51 | history | edited | Ryan Berger | CC BY-SA 3.0 |
Added command-line option based on comment feedback.
|
Aug 23, 2017 at 20:41 | comment | added | Noah Sparks | @RyanBerger you should edit the answer to include "od -c". First thing I've come across that just simply showed the returns. Thank you. | |
Sep 26, 2016 at 16:25 | comment | added | Eric Fossum |
@RyanBerger - Looks like you're missing a -t. It should be od -t c file/path , but thanks for the new program. Worked great!
|
|
Mar 31, 2015 at 0:59 | comment | added | Samuel | Use the -b flag when starting vi/vim and then use :set list to see CR (^M) and LF ($) endings. | |
Jun 18, 2013 at 16:09 | comment | added | Victor Zamanian |
In vim: :set fileformat will report which of unix or dos vim thinks the file's line endings are in. You can change it by :set fileformat=unix .
|
|
Oct 28, 2012 at 22:33 | comment | added | cowboydan | In the "for what it's worth" category you can grep for Dos style CRLF by issuing grep --regex="^M" where ^M is CTRL+V CTRL+M. You can remove those by replacing those with a sed command. This does essentially the same thing as dos2unix | |
Aug 26, 2010 at 3:48 | vote | accept | Marco Ceppi | ||
Mar 11, 2013 at 15:44 | |||||
Aug 25, 2010 at 22:55 | history | edited | Ryan Berger | CC BY-SA 2.5 |
Added vi option
|
Aug 25, 2010 at 22:51 | comment | added | Ryan Berger | Unfortunately, I don't think vi can show those specific characters. You can try od -c <filename> which I believe will display \n or \r\n. | |
Aug 25, 2010 at 21:32 | comment | added | Marco Ceppi | Thank you - this has indeed worked - now I'm trying to tell if it's a \n or \r\n is there an additional switch for that in Vi? | |
Aug 25, 2010 at 20:42 | history | answered | Ryan Berger | CC BY-SA 2.5 |