Ah, thanks Gary, now it makes sense!

I didn't realise the autocmd pattern could match different things.

The examples in the docs use BufRead, hence always matching file names.

Thanks for taking the time to explain it to me.

Rob.

On Wed, 27 Mar 2019 at 01:50, Gary Johnson <garyj...@spocom.com> wrote:

> On 2019-03-27, Robert Webb wrote:
> > Wow, that did the trick somehow.
> >
> > Using "h,c,cpp" as the file pattern works, but not "*.h,*.c,*.cpp" as
> per the
> > examples in the docs, and as I've been using for years up till now.
> >
> > Why?  Is this only required for FileType and not BufRead?
> >
> > And won't "h,c,cpp" match ANY file containing a "c" or an "h"?
> >
> > Surely there's something wrong here.
>
> The example Christian used was
>
>     autocmd FileType c,cpp setl fo=2crq
>
> The autocommand event in that example is FileType, so the
> autocommand pattern is matched against the filetype of the file
> being opened.  Filetypes include "c" for C language files and "cpp"
> for C++ language files.  These are filetypes, not filename
> extensions or suffixes.  "h" is not a filetype used by Vim, so it
> will never match the filetype of a FileType autocommand and has no
> effect in your list.
>
> The pattern of a BufRead autocommand is matched against the name of
> the file being opened.  For a BufRead autocommand, you would use
> a pattern that matches the file name of interest, e.g., "*.c,*.h" to
> match files ending with the suffix ".c" or ".h".
>
> See $VIMRUNTIME/filetype.vim to see how Vim uses BufRead and
> BufNewFile autocommand events along with filename patterns to set
> filetypes.  Setting the filetype triggers a FileType autocommand
> event which causes all the registered FileType autocommands to have
> their patterns compared against the filetype that was set.  Those
> FileType autocommands whose patterns match the filetype have their
> commands executed.
>
> The examples in the docs are correct,  Note the differences between
> the patterns used with FileType autocommand events and those used
> with BufRead autocommand events.
>
> Regards,
> Gary
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui