I am using vim to view XML files created by a Windows app. It is probably a malformed XML file because vim thinks it's opening a Unix file format. So I end up seeing ^M at the end of almost every line.

I don't want to mess with the file, as vim is the only viewer. It is going to be used by other apps, and in fact, may even be in the middle of being written to. I just want vim to interpret <CR><LF> as a Unix carriage return. In case it matters, I typically open files with either

 :e path/to/file
 :split path/to/file
 :vsplit path/to/file

or I might use the netrw plugin. I am using vim 7.4, patches 1-729, built for Cygwin. It is not easy to upgrade in my environment.

P.S. Sorry if the tag is not quite. The posting web page suggested original-vim, but that tag doesn't seem to exist. No other tags in the suggestion list seemed any more appropriate. I am open to suggestions as to a better tag.

  • Do you want to automatically do set ff=dos for these files? If so, please add how these files can be identified (location, extension or some other detail)
    – muru
    Commented Jan 21, 2017 at 8:08
  • 3
    One solution is to execute :set ffs=dos before opening the file.
    – garyjohn
    Commented Jan 21, 2017 at 18:19
  • 3
    :e ++ff=dos yourfile Commented Jan 21, 2017 at 21:06
  • @muru: Yes, I want to set ff=dos, but not after opening the file for edit, otherwise it effectively modifies the file.
    – user36800
    Commented Jan 23, 2017 at 16:22
  • @garyjohn: That's a possibility. It means opening the new window (for those cases where I open a new window) then setting ffs, then editing the file.
    – user36800
    Commented Jan 23, 2017 at 16:23

1 Answer 1


Thanks to Christan Brabandt for the solution:

:e ++ff=dos filename

If the file is already opened in unix file format:

:e ++ff=dos %

Or just:

:e ++ff=dos

If I change the file format option, the buffer/file is marked as modified. This makes sense since the changes include things like using different characters in the electronic file to represent a newline.

  • What does it do? Is it only a view change or does it change the content? Can you update your answer with an explanation (without "Edit:", "Update:", or similar)? Commented Aug 29, 2020 at 13:02
  • I just re-read your comment, and augmented the answer. Thanks.
    – user36800
    Commented Dec 2, 2020 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.