vimrc: convert to UNIX line endings automatically.

This commit is contained in:
Mikaela Suomalainen 2014-06-08 11:56:38 +03:00
parent 0c9b8117ef
commit 3362a57f92

18
vimrc
View File

@ -102,3 +102,21 @@ autocmd BufReadPost *
if has("autocmd")
au BufReadPost * if &modifiable | retab | endif
endif
" dos2unix ^M copied from http://stackoverflow.com/a/5361702/1675649
fun! Dos2unixFunction()
let _s=@/
let l = line(".")
let c = col(".")
try
set ff=unix
w!
"%s/\%x0d$//e
catch /E32:/
echo "Sorry, the file is not saved."
endtry
let @/=_s
call cursor(l, c)
endfun
com! Dos2Unix keepjumps call Dos2unixFunction()
au BufReadPost * keepjumps call Dos2unixFunction()