Nvim :help
pages, generated
from source
using the tree-sitter-vimdoc parser.
file-type
:filetype
:filet
To enable file type detection, use this command in your vimrc::filetype onEach time a new or existing file is edited, Vim will try to recognize the type of the file and set the 'filetype' option. This will trigger the FileType event, which can be used to set the syntax highlighting, set options, etc.
:help ft-vim-indent :help ft-vim-syntax :help ft-man-pluginIf the file type is not detected automatically, or it finds the wrong type, you can either set the 'filetype' option manually, or add a modeline to your file. Example, for an IDL file use the command:
:set filetype=idlor add this modeline to the file:
/* vim: set filetype=idl : */
:filetype-plugin-on
You can enable loading the plugin files for specific file types with::filetype plugin onIf filetype detection was not switched on yet, it will be as well. This actually loads the file "ftplugin.vim" in 'runtimepath'. The result is that when a file is edited its plugin file is loaded (if there is one for the detected filetype). filetype-plugin
:filetype-plugin-off
You can disable it again with::filetype plugin offThe filetype detection is not switched off then. But if you do switch off filetype detection, the plugins will not be loaded either. This actually loads the file "ftplugof.vim" in 'runtimepath'.
:filetype-indent-on
You can enable loading the indent file for specific file types with::filetype indent onIf filetype detection was not switched on yet, it will be as well. This actually loads the file "indent.vim" in 'runtimepath'. The result is that 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 offThe 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 offThis 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".
:filetype-overview
:filetypeThe output looks something like this:
filetype detection:ON plugin:ON indent:OFFThe 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".
filetype-detect
To detect the file type again::filetype detectUse 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:*.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
*.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
*.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
*.w
g:filetype_w ft-cweb-syntax*.r
g:filetype_r ft-rexx-syntaxfiletype-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: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
au BufRead,BufNewFile *.mine set filetype=mine
:w ~/.config/nvim/ftdetect/mine.vim
au BufRead,BufNewFile *.txt setfiletype text
au BufRead,BufNewFile * if &ft == 'pascal' | set ft=mypascal | endifC. 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
" 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
:w ~/.config/nvim/filetype.vim
new-filetype-scripts
D. If your filetype can only be detected by inspecting the contents of the
file.:!mkdir -p ~/.config/nvim
if did_filetype() " filetype already set.. finish " ..don't do these checks endif if getline(1) =~ '^#!.*\<mine\>' setfiletype mine elseif getline(1) =~? '\<drawing\>' setfiletype drawing endif
:w ~/.config/nvim/scripts.vim
remove-filetype
If a file type is detected that is wrong for you, you can set 'filetype' to
a non-existing name such as ignored
to avoid that it will be set later anyway.g:did_load_filetypes
The builtin filetype detection provided by Nvim can be disabled by setting
the did_load_filetypes
global variable. If this variable exists, the default
$VIMRUNTIME/filetype.lua
will not run.plugin-details
The "plugin" directory can be in any of the directories in the 'runtimepath'
option. All of these directories will be searched for plugins and they are
all loaded. For example, if this command:set runtimepathproduces this output:
vim -V2You will see a lot of messages, in between them is a remark about loading the plugins. It starts with:
:let maplocalleader = ","
:map ,p <Plug>MailQuote
no_mail_maps
g:no_mail_maps
3. Disable defining mappings for a specific filetype by setting a variable,
which contains the name of the filetype. For the "mail" filetype this
would be::let no_mail_maps = 1
no_plugin_maps
g:no_plugin_maps
4. Disable defining mappings for all filetypes by setting a variable::let no_plugin_maps = 1
ftplugin-overrule
If a global filetype plugin does not do exactly what you want, there are three
ways to change this:vim ~/.config/nvim/ftplugin/fortran.vim
cp $VIMRUNTIME/ftplugin/fortran.vim ~/.config/nvim/ftplugin/fortran.vim
vim ~/.config/nvim/after/ftplugin/fortran.vim
plugin_exec
g:plugin_exec
Enable executing of external commands. This was done historically for e.g.
the perl filetype plugin (and a few others) to set the search path.
Disabled by default for security reasons::let g:plugin_exec = 1It is also possible to enable this only for certain filetypes:
:let g:<filetype>_exec = 1So to enable this only for ruby, set the following variable:
:let g:ruby_exec = 1If both, the global
plugin_exec
and the <filetype>_exec
specific variable
are set, the filetype specific variable should have precedent.:let g:awk_is_gawk = 1
<Leader>
o Starts a new Changelog entry in an equally intelligent
fashion (see below).runtime ftplugin/changelog.vim
<Leader>
o Switches to the ChangeLog buffer opened for the
current directory, or opens it in a new buffer if it
exists in the current directory. Then it does the
same as the local <Leader>
o described above.whoami
and hostname
to build an
email address. The final form isFull Name <user@host>
|2003-01-14 Full Name <user@host> | | * prefix|
| * prefix|
|2003-01-14 Full Name <user@host>
b:changelog_name
Name of the ChangeLog file to look for.
The default is 'ChangeLog'.let g:freebasic_lang = "fblite"
<C-]>
to jump from a function
entry in the gprof flat profile or from a function entry in the call graph
to the details of that function in the call graph.let g:no_gprof_maps = 1
<LocalLeader>
q or \\MailQuote
Quotes the text selected in Visual mode, or from the cursor position
to the end of the file in Normal mode. This means "> " is inserted in
each line.{name}
Display the manpage for {name}
.
Man {sect}
{name}
Display the manpage for {name}
and section {sect}
.
Man {name}
({sect}
) Same as above.
Man {sect}
{name}
({sect}
) Used during completion to show the real section of
when the provided section is a prefix, e.g. 1m vs 1.
Man {path}
Open the manpage at {path}
. Prepend "./" if {path}
is relative to the current directory.
Man Open the manpage for the <cWORD>
(man buffers)
or <cword>
(non-man buffers) under the cursor.
Man! Display the current buffer contents as a manpage.:vertical Man printfLocal mappings: K or
CTRL-]
Jump to the manpage for the <cWORD>
under the
cursor. Takes a count for the section.
CTRL-T Jump back to the location that the manpage was
opened from.
gO Show the manpage outline. gO
q :quit if invoked as $MANPAGER, otherwise :close.g:no_man_maps
Do not create mappings in manpage buffers.
g:ft_man_folding_enable
Fold manpages with foldmethod=indent foldnestmax=1.
b:man_default_sects
Comma-separated, ordered list of preferred sections.
For example in C one usually wants section 3 or 2::let b:man_default_sections = '3,2'
g:man_hardwrap
Hard-wrap to $MANWIDTH or window width if $MANWIDTH is
empty. Enabled by default. Set FALSE to enable soft
wrapping.export MANPAGER='nvim +Man!'Note that when running
man
from the shell and with that MANPAGER
in your
environment, man
will pre-format the manpage using groff
. Thus, Nvim
will inevitably display the manual page as it was passed to it from stdin. One
of the caveats of this is that the width will _always_ be hard-wrapped and not
soft wrapped as with g:man_hardwrap=0
. You can set in your environment:export MANWIDTH=999So
groff
's pre-formatting output will be the same as with g:man_hardwrap=0
i.e soft-wrapped.:highlight link manBold Normal
let g:markdown_folding = 1'expandtab' will be set by default. If you do not want that use this:
let g:markdown_recommended_style = 0
<C-]>
and <C-T>
, are provided to simulate a tag stack for navigating
the PDF. The following are treated as tags::let g:no_pdf_maps = 1
setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8To disable this behavior, set the following variable in your vimrc:
let g:python_recommended_style = 0
BufEnter
and
BufWrite
. To change the events that trigger linting, usevim.g.query_lint_on = { 'InsertLeave', 'TextChanged' }
vim.g.query_lint_on = {}
:let g:qf_disable_statusline = 1R MARKDOWN
ft-rmd-plugin
let rmd_include_html = 1The 'formatexpr' option is set dynamically with different values for R code and for Markdown code. If you prefer that 'formatexpr' is not set, add to your vimrc:
let rmd_dynamic_comments = 0R RESTRUCTURED TEXT
ft-rrst-plugin
let rrst_dynamic_comments = 0
setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8To enable this behavior, set the following variable in your vimrc:
let g:rst_style = 1
Type with timestamp YYYY-mm-ddTHH:MM:SS: % Key__ Description___ Value + fooba foo bar baz fo {msgpack-value} + abcde abc def ghi jk {msgpack-value} Other type with timestamp YYYY-mm-ddTHH:MM:SS: @ Description__ Value - foo bar baz t {msgpack-value} # Expected more elements in list Some other type with timestamp YYYY-mm-ddTHH:MM:SS: # Unexpected type: type instead of map = {msgpack-value}Filetype plugin defines all Cmd-events. Defined SourceCmd event makes "source file.shada" be equivalent to "|:rshada| file.shada". BufWriteCmd, FileWriteCmd and FileAppendCmd events are affected by the following settings:
g:shada#keep_old_header
Boolean, if set to false all header entries
are ignored when writing. Defaults to 1.
g:shada#add_own_header
Boolean, if set to true first written entry
will always be header entry with two values in
a map with attached data: v:version attached
to "version" key and "shada.vim" attached to
"generator" key. Defaults to 1.#
starts a comment. Lines starting with space characters and then #
are ignored. Plugin may only add comment lines to indicate some errors in
ShaDa format. Lines containing no non-whitespace characters are also
ignored.
2. Each entry starts with line that has format "{type} with timestamp
{timestamp}
:". {timestamp}
is strftime()-formatted string representing
actual Unix timestamp value. First strftime() argument is equal to
%Y-%m-%dT%H:%M:%S
. When writing this timestamp is parsed using
msgpack#strptime(), with caching (it remembers which timestamp produced
particular strftime() output and uses this value if you did not change
timestamp). {type}
is one of
1 - Header
2 - Search pattern
3 - Replacement string
4 - History entry
5 - Register
6 - Variable
7 - Global mark
8 - Jump
9 - Buffer list
10 - Local mark
11 - Change
* - Unknown (0x{type-hex})Buffer list with timestamp 1970-01-01T00:00:00: % Key Description Value + f file name "/foo" + l line number 1 + c column 10
Buffer list with timestamp 1970-01-01T00:00:00: = [{="f": "/foo", ="c": 10}]
Buffer list with timestamp 1970-01-01T00:00:00: % Key Description Value + f file name "/foo" % Key Description Value + f file name "/bar"
Buffer list with timestamp 1970-01-01T00:00:00: = [{="f": "/foo"}, {="f": "/bar"}]
Register with timestamp 1970-01-01T00:00:00: % Key Description Value + rc contents @ | - "line1" | - "line2"
Register with timestamp 1970-01-01T00:00:00: % Key Description Value + rc contents ["line1", "line2"]
History entry with timestamp 1970-01-01T00:00:00: @ Description_ Value - history type SEARCH - contents "foo" - separator '/'
History entry with timestamp 1970-01-01T00:00:00: = [SEARCH, "foo", '/']
{msgpack-value}
": raw values. {msgpack-value} in this case may
have absolutely any type. Special array syntax for register entries is
not recognized here as well.*.tex
file has the form%&<format>then this determined the file type: plaintex (for plain TeX), context (for ConTeXt), or tex (for LaTeX). Otherwise, the file is searched for keywords to choose context or tex. If no keywords are found, it defaults to plaintex. You can change the default by defining the variable g:tex_flavor to the format (not the file type) you use most. Use one of these:
let g:tex_flavor = "plain" let g:tex_flavor = "context" let g:tex_flavor = "latex"Currently no other formats are recognized.
let g:no_vim_maps = 1
let g:no_zimbu_maps = 1