help with vim script: set fileformat based on filename

9 views
Skip to first unread message

Gabe Moothart

unread,
Nov 26, 2008, 9:37:13 PM11/26/08
to vim...@googlegroups.com
Hi,
I'm new to vim, so I don't really know what I'm doing :-). I'm running on multiple platforms, and I've run into some line-ending problems. When in windows, I'd like to tell vim to use unix line-endings on some files (i.e, those that begin with '.', those that end with '.rb', etc) - i.e., :set fileformat=unix. How can I accomplish this with vimscript?


TIA,
Gabe

Tony Mechelynck

unread,
Nov 27, 2008, 3:57:43 AM11/27/08
to vim...@googlegroups.com

The file in question being current, use

setlocal fileformat=unix

To do it when opening any .* and *.rb files,

if has('autocmd')
autocommand BufRead,BufNewFile .*,*.rb setlocal ff=unix
endif

The "if" wrapper is there because you of course cannot use autocommands
if the autocommand feature hasn't been compiled-in.


Best regards,
Tony.
--
Coward, n.:
One who in a perilous emergency thinks with his legs.
-- Ambrose Bierce, "The Devil's Dictionary"

Reply all
Reply to author
Forward
0 new messages