function! s:set_fileformat()
if &fileformat != "unix" && input("setlocal fileformat=unix?[y/n]") == "y"
try
setlocal fileformat=unix
catch
endtry
endif
endfunction
autocmd BufWritePre * :call <SID>set_fileformat()
改行コードが unix 以外になっていると,:w の際に setlocal fileformat=unix?[y/n] と聞かれて y を入力すると unix に変えてくれます.
unix 以外だと毎回聞かれるので,「こんな改行コードが混在してるかもしれない部屋に居られるか!俺は自分の LF に戻る!」って人だけお使い下さい.
ref.
Vim の改行コードを unix に変更してみた - C++でゲームプログラミング
http://ideone.com/I8joy
https://twitter.com/manga_osyo/status/180258672520331266
Special Thanks @manga_osyo