On 2006-06-13, Max Dyckhoff <[EMAIL PROTECTED]> wrote:
> I am having some issues with filetype detection stuff. Here is what I am
> doing, so far as I can see I am doing exactly what it says in the help.
> 
> 1. I am on Windows, my runtimepath is 
> 
> ~/vimfiles,C:\Program Files\Vim/vimfiles,c:\Progam Files\Vim\vim70,
> C:\Program Files\Vim/vimfiles/after,~/vimfiles/after
> 
> The folder ~/vimfiles does not exist.
> 
> 
> 2. I have ":filetype plugin indent on" set in my vimrc file.
> 
> 
> 3. I place a file called wibble.vim in c:\Program
> Files\Vim/vimfiles/ftdetect which contains the following:
> 
> if exists("did_load_filetypes")
>   finish
> endif
> augroup filetypedetect
>   au! BufRead,BufNewFile *.wibble     setfiletype wibblewobble
> augroup END
> 
> 
> 4. I open a file called foo.wibble and do :set filetype, it returns
> "filetype=". If I comment out the first three lines of wibble.vim
> (namely the check on did_load_filetypes) then it works fine.
> 
> 
> So, am I right in not including the did_load_filetypes check (which
> :help ftdetect says you should have), or am I doing something wrong
> elsewhere?

There are a number of different methods of doing filetype detection;  
you have confused two of them.

I don't understand exactly how the ftdetect directory works, but 
":help ftdetect" says that if you are going to add filetype 
detection for a new file type by putting a file in the ftdetect 
directory, that file should contain _only_ the autocommand, e.g.,

    au BufRead,BufNewFile *.wibble      set filetype wibblewobble

Note that there is no '!' after the 'au' and the command is "set 
filetype", not "setfiletype".  Note also that the help entry does 
say, 

    Note that there is no "augroup" command, this has already been 
    done when sourcing your file.

If, on the other hand, you add filetype detection by creating your 
own ~/.vim/filetype.vim file, _then_ you would put in that file the 
commands you used above, i.e.,

    if exists("did_load_filetypes")
      finish
    endif
    augroup filetypedetect
      au! BufRead,BufNewFile *.wibble   setfiletype wibblewobble
    augroup END

HTH,
Gary

-- 
Gary Johnson                 | Agilent Technologies
[EMAIL PROTECTED]     | Wireless Division
                             | Spokane, Washington, USA

Reply via email to