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

15525Re: when is filetype set?

Expand Messages
  • Janakiraman .S
    Jan 3, 2001
    • 0 Attachment
      * Michael P. Soulier (msoulier@...) wrote thusly :

      > Hey people. I'm trying to put some logic in my .vimrc file so that
      > different options are set when the filetype or syntax is set to
      > "mail". However, filetype and syntax don't seem to be set at that
      > point, even though it appears that they should be if I read the output
      > from verbose.
      > I'd like to do something like this:
      >
      > " Turn on syntax shading, depending on a few things.
      > " I don't want it for mail, too hard to read.
      > if &filetype == "mail"
      > " Also, set it to wrap lines if we're editing mail.
      > set textwidth=78
      > " And lose the auto-indent.
      > set noautoindent
      > " Turn off syntax shading.
      > syntax off
      > " Have it on by default.
      > else
      > syntax on
      > endif
      >
      > Will this not work at all in the .vimrc file?

      I dont think so. You will need to execute this each time you load a
      buffer.

      Also syn off turns syntax highlighting off on all buffers.
      syn clear will clear it for the current buffer alone.

      I suggest using autocommands to achieve what you want.
      Something like

      " Set up your defaults for all files
      syn on
      au FileType * se cindent nu
      " Specific to files of filetype mail
      au FileType mail syn clear
      au FileType mail se tw=78 noai

      :he autocmd
      :he FileType
    • Show all 5 messages in this topic