Search code examples
vimfile-format

Vim: Change the file format for a particular directory


I'm using Vim to work on a project with others developers using Windows.

The problem: I get "^M" characters instead of line-breaks. This can be solved with this simple command

:set fileformats=dos

But when I restart Vim, the file is opened again with the unix format. Another problem is that I have to execute the command for each file in the directory.

Is it possible to set this parameter for a whole directory?


Solution

  • The fileformats option is global. The fileformat option however is local to each buffer.

    With the following command you can check how those are set:

    :verbose set ff? ffs?
    

    In my .vimrc I have set the following:

    set fileformats=unix,dos,mac
    

    And it Just Works.