vimrc help with line endings

I was reading this and thought I could put this in my vimrc and it would convert the line endings to unix. Am I doing something wrong or am I missing something?

set ff=unix

Managing/Munging Line-Endings with Vi/Vim | Jeet Sukumaran

I used this command and it confirms that my global option is set to unix. I edited the file a little bit and saved it but it didn't convert it to unix. It remained in the dos format.

:verbose set ff? ffs?
fileformat=dos
  fileformats=unix,dos                                     
        Last set from ~/.vimrc

File format - Vim Tips Wiki

Hmm, the ::verbose set ff? ffs? Shows fileformat=dos, shouldn't it show Unix since you are setting fileformat=Unix? I think the fileformat gets set on the local buffer when you open the file. So if the file is in dos, when you open the file, it sets fileformat to dos. fileformat is a local variable. Fileformats, the other, note the plural is global and settable.

VIm will not automatically convert existing files. What you set in ~/.vimrc are settings for the UI and new files, but the encodings and file formats of existing files will not be changed unless the user explicitly says so.

1 Like