Skip to main content
edited title
Link
john c. j.
  • 329
  • 3
  • 21

'BufNewFile,BufFilePre,BufRead' or justsimply 'BufFilePre,BufRead' when detecting a filetype?

Source Link
john c. j.
  • 329
  • 3
  • 21

'BufNewFile,BufFilePre,BufRead' or just 'BufFilePre,BufRead'?

The following snippet is from the vim-pandoc-syntax plugin README:

If you want to use vim-pandoc-syntax without vim-pandoc, you'll need to tell Vim to load it for certain files. Just add something like this to your vimrc:

augroup pandoc_syntax
    au! BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
augroup END

What might be the reason to use BufNewFile here? Isn't it that BufFilePre and BufRead are sufficient?

When we create a new empty buffer, its filetype value is blank in either case.