Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Firefox 3.0 and earlier used CVS as its version control system, and if you were still using cygwin tools then you could choose which line endings you wanted to use, so for instance you could use the MS-DOS editor. However by then most people were by then using MSYS (conveniently distributed in a mozillabuild package that contained other components necessary to build) which only supported Unix line endings. This was not a problem since it was supplied with Vim (5.8.9 I think) which was configured to default to Unix line endings but would also open files with DOS line endings although it would warn you that you were using the "wrong" line endings. Of course if like me you're also used to using Vim on Unix then MSYS Vim looks much the same.

Now that Firefox has switched to Mercurial, all the source files always have Unix line endings even when checked out using a Windows version of Mercurial.

Now the latest mozillabuild package does not ship with the MSYS version of Vim, instead it ships with Vim for Windows (7.2) which doesn't really integrate well with a Unix toolchain. I know I can set fileformat=unix to make Vim default to creating files with Unix line endings (this also affects Firefox developers; from time to time I see new files checked in with DOS line endings because that's how Vim for Windows creates them by default), but is it possible to make it warn me when I open a file with DOS line endings? Currently it warns me whenever I open a file with Unix line endings, which is all the time. Example: "~\.vimrc" [unix] 9L, 155C

share|improve this question

2 Answers 2

up vote 4 down vote accepted

You can make Vim default to Unix line endings while still supporting DOS line endings by setting the 'fileformats' option:

:set fileformats=unix,dos
:set fileformat=unix

The second line may not be necessary, but I include it in my _vimrc just to be on the safe side. (Edit: It is necessary under Windows.)

As for your question about the "warning," I don't think you can change this behavior. ":help file-formats" contains this paragraph:

If the 'fileformat' option is set to "dos" on non-MS-DOS systems the message
"[dos format]" is shown to remind you that something unusual is happening.  On
MS-DOS systems you get the message "[unix format]" if 'fileformat' is set to
"unix".  On all systems but the Macintosh you get the message "[mac format]"
if 'fileformat' is set to "mac".
share|improve this answer
    
Yeah, I use those lines in my .vimrc already, but I didn't notice that there was extra help under file-format; thanks for pointing that out. –  Neil May 8 '11 at 21:37
    
I ended up separately downloading the MSYS version of Vim and installing that into mozillabuild. –  Neil May 10 '11 at 23:02
    
On my Windows system, the second line (fileformat) was indeed necessary. –  Binary Phile Feb 21 '13 at 15:22

You can use the following in your ~/.vimrc :

:set shm=x

This will change [dos format] into [dos], and [unix format] into [unix]

It will at least take less space in your status bar.

share|improve this answer
    
That's the default setting on all the versions of vim that I use anyway... –  Neil May 8 '11 at 21:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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