`*[mM]makefile,*.mk,*.mak,[mM]akefile*`
g:make_flavor |ft-make-syntax|
`*.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md`
g:filetype_md |ft-pandoc-syntax|
`*.mod` g:filetype_mod
`*.p` g:filetype_p |ft-pascal-syntax|
`*.pl` g:filetype_pl
`*.pp` g:filetype_pp |ft-pascal-syntax|
`*.prg` g:filetype_prg
`*.r` g:filetype_r
`*.sig` g:filetype_sig
`*.sql` g:filetype_sql |ft-sql-syntax|
`*.src` g:filetype_src
`*.sys` g:filetype_sys
`*.sh` g:bash_is_sh |ft-sh-syntax|
`*.tex` g:tex_flavor |ft-tex-plugin|
`*.typ` g:filetype_typ
`*.v` g:filetype_v
`*.w` g:filetype_w |ft-cweb-syntax|
For a few filetypes the global variable is used only when the filetype could
not be detected:
`*.r` g:filetype_r |ft-rexx-syntax|
*filetype-ignore*
To avoid that certain files are being inspected, the g:ft_ignore_pat variable
is used. The default value is set like this: >
:let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$'
This means that the contents of compressed files are not inspected.
*new-filetype*
If a file type that you want to use is not detected yet, there are a few ways
to add it. The recommended way is to use |vim.filetype.add()| to add it to
Nvim's builtin filetype detection mechanism. If you want to handle the
detection manually, proceed as follows:
A. If you want to overrule all default file type checks.
This works by writing one file for each filetype. The disadvantage is that
there can be many files. The advantage is that you can simply drop this
file in the right directory to make it work.
*ftdetect*
1. Create your user runtime directory. You would normally use the first
item of the 'runtimepath' option. Then create the directory "ftdetect"
inside it. Example for Unix: >
:!mkdir -p ~/.config/nvim/ftdetect
<
2. Create a file that contains an autocommand to detect the file type.
Example: >
au BufRead,BufNewFile *.mine set filetype=mine
< Note that there is no "augroup" command, this has already been done
when sourcing your file. You could also use the pattern "*" and then
check the contents of the file to recognize it.
Write this file as "mine.vim" in the "ftdetect" directory in your user
runtime directory. For example, for Unix: >
:w ~/.config/nvim/ftdetect/mine.vim
< 3. To use the new filetype detection you must restart Vim.
The files in the "ftdetect" directory are used after all the default
checks, thus they can overrule a previously detected file type. But you
can also use |:setfiletype| to keep a previously detected filetype.
B. If you want to detect your file after the default file type checks.
This works like A above, but instead of setting 'filetype' unconditionally
use ":setfiletype". This will only set 'filetype' if no file type was
detected yet. Example: >
au BufRead,BufNewFile *.txt setfiletype text
<
You can also use the already detected file type in your command. For
example, to use the file type "mypascal" when "pascal" has been detected: >
au BufRead,BufNewFile * if &ft == 'pascal' | set ft=mypascal
| endif
C. If your file type can be detected by the file name or extension.
1. Create your user runtime directory. You would normally use the first
item of the 'runtimepath' option. Example for Unix: >
:!mkdir -p ~/.config/nvim
<
2. Create a file that contains autocommands to detect the file type.
Example: >
" my filetype file
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile *.mine setfiletype mine
au! BufRead,BufNewFile *.xyz setfiletype drawing
augroup END
<
Write this file as "filetype.vim" in your user runtime directory. For
example, for Unix: >
:w ~/.config/nvim/filetype.vim
< 3. To use the new filetype detection you must restart Vim.
Your filetype.vim will be sourced before the default FileType autocommands
have been installed. Your