Loading ...
Sorry, an error occurred while loading the content.

Re: help with vim script: set fileformat based on filename

Expand Messages
  • Tony Mechelynck
    ... The file in question being current, use setlocal fileformat=unix To do it when opening any .* and *.rb files, if has( autocmd ) autocommand
    Message 1 of 2 , Nov 27, 2008
    • 0 Attachment
      On 27/11/08 03:37, Gabe Moothart wrote:
      > 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

      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"

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.