2

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 Jan 21 '17 at 8:08
  • 3
    One solution is to execute :set ffs=dos before opening the file. – garyjohn Jan 21 '17 at 18:19
  • 2
    :e ++ff=dos yourfile – Christian Brabandt Jan 21 '17 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 Jan 23 '17 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 Jan 23 '17 at 16:23
3

Thanks to Christan Brabandt for the solution:

:e ++ff=dos filename

If the file is already opened in unix file format:

:e ++ff=dos %

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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