Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In VIM I can show all the hidden characters in a file via the command ":set invlist". However, end of line sequences are always displayed as $ whether it is a carriage return/line feed or just a line feed. How do I distinguish between the two types of line endings?

share|improve this question
up vote 4 down vote accepted

refer to VIM change end-of-line format.

If you set the file to unix mode then the carriage return shows up as ^M and the linefeed displays as the end-of-line character.

share|improve this answer
I always fix to the unixmode and usually run dos2unix on text files from Windows. – nik Aug 7 '09 at 16:45
I did this, and it converts the file format in silently. However, I can test the line ending of the file effectively but awkwardly by setting one format and quitting then setting to the other format and quitting. Whichever sequence leads to a "you have unsaved changes" message is the format the line endings are not in. – Justin Dearing Aug 7 '09 at 19:19
Best answer at the moment, but I'll change the accepted answer if anyone comes up with a better one. – Justin Dearing Aug 11 '09 at 19:56

I know this is an older question, but I needed a similar answer and was able to find something a little better.

:set ff?

This will tell you what type of file vim thought it was when it loaded. Of course you have to have vim configured to recognize the line endings of the particular file. More details about VIM file formats here... VIM File Formats Blog Post

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .