Home Explore Blog CI



neovim

2nd chunk of `runtime/doc/filetype.txt`
c2d9624fa526e8ddf6b81dd96628a1ecc5a26cd72adbc2c00000000100000fa8
 when a file is edited its indent file is loaded (if there
is one for the detected filetype). |indent-expression|

						*:filetype-indent-off*
You can disable it again with: >
	:filetype indent off
The filetype detection is not switched off then.  But if you do switch off
filetype detection, the indent files will not be loaded either.
This actually loads the file "indoff.vim" in 'runtimepath'.
This disables auto-indenting for files you will open.  It will keep working in
already opened files.  Reset 'autoindent', 'cindent', 'smartindent' and/or
'indentexpr' to disable indenting in an opened file.

						*:filetype-off*
To disable file type detection, use this command: >
	:filetype off
This will keep the flags for "plugin" and "indent", but since no file types
are being detected, they won't work until the next ":filetype on".


Overview:					*:filetype-overview*

command				detection	plugin		indent ~
:filetype on			on		unchanged	unchanged
:filetype off			off		unchanged	unchanged
:filetype plugin on		on		on		unchanged
:filetype plugin off		unchanged	off		unchanged
:filetype indent on		on		unchanged	on
:filetype indent off		unchanged	unchanged	off
:filetype plugin indent on	on		on		on
:filetype plugin indent off	unchanged	off		off

To see the current status, type: >
	:filetype
The output looks something like this: >
	filetype detection:ON  plugin:ON  indent:OFF

The file types are also used for syntax highlighting.  If the ":syntax on"
command is used, the file type detection is installed too.  There is no need
to do ":filetype on" after ":syntax on".

To disable one of the file types, add a line in your filetype file, see
|remove-filetype|.

							*filetype-detect*
To detect the file type again: >
	:filetype detect
Use this if you started with an empty file and typed text that makes it
possible to detect the file type.  For example, when you entered this in a
shell script: "#!/bin/csh".
   When filetype detection was off, it will be enabled first, like the "on"
argument was used.

							*filetype-overrule*
When the same extension is used for multiple filetypes, Vim tries to guess
what kind of file it is.  This doesn't always work.  A number of global
variables can be used to overrule the filetype used for certain extensions:

	file name	variable ~
	`*.asa`		g:filetype_asa		|ft-aspperl-syntax|
						|ft-aspvbs-syntax|
	`*.asm`		g:asmsyntax		|ft-asm-syntax|
	`*.asp`		g:filetype_asp		|ft-aspperl-syntax|
						|ft-aspvbs-syntax|
	`*.bas`		g:filetype_bas		|ft-basic-syntax|
	`*.cfg`		g:filetype_cfg
	`*.cls`		g:filetype_cls
	`*.csh`		g:filetype_csh		|ft-csh-syntax|
	`*.dat`		g:filetype_dat
	`*.def`		g:filetype_def
	`*.dsp`		g:filetype_dsp
	`*.f`		g:filetype_f		|ft-forth-syntax|
	`*.frm`		g:filetype_frm		|ft-form-syntax|
	`*.fs`		g:filetype_fs		|ft-forth-syntax|
	`*.h`		g:c_syntax_for_h	|ft-c-syntax|
	`*.i`		g:filetype_i		|ft-progress-syntax|
	`*.inc`		g:filetype_inc
	`*.lsl`		g:filetype_lsl
	`*.m`		g:filetype_m		|ft-mathematica-syntax|
	`*[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.

Title: Managing Filetype Detection, Plugins, and Indentation in Vim
Summary
This section explains how to disable filetype indentation, filetype detection, and provides an overview of filetype-related commands. The ":filetype" command shows the current status. Syntax highlighting is linked to file types. To force filetype detection, use ":filetype detect". Global variables can overrule filetypes based on extension, and g:ft_ignore_pat avoids inspecting certain files.