Movatterモバイル変換


[0]ホーム

URL:


Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq
Go to keyword (shortcut:k)
Site search (shortcut:s)
filetype.txt  ForVim version 9.2.  Last change: 2026 Feb 14VIM REFERENCE MANUAL  by Bram MoolenaarFiletypesfiletypefile-type1. Filetypesfiletypes2. Filetypepluginfiletype-plugins3. Docs for the defaultfiletype plugins.ftplugin-docsAlso seeautocmd.txt.==============================================================================1. Filetypesfiletypesfile-typesVim can detect the type of file thatis edited.  Thisis done by checking thefile name and sometimes by inspecting the contents of the file for specifictext.:filetype:filetTo enable file type detection, use this command in your vimrc::filetype onEach timea new or existing fileis edited, Vim will try to recognize the typeof the file and set the'filetype' option.  This will trigger theFileTypeevent, which can be used to set thesyntax highlighting, set options, etc.NOTE: Filetypes and'compatible' don't work together well, since beingVicompatible meansoptions are global.  Resetting'compatible'is recommended,if you didn'tdo that already.Detail: The ":filetype on" command will load one of these files:Amiga    $VIMRUNTIME/filetype.vimMac    $VIMRUNTIME:filetype.vimMS-Windows  $VIMRUNTIME\filetype.vimUnix    $VIMRUNTIME/filetype.vimVMS    $VIMRUNTIME/filetype.vimThis fileisa Vimscript that definesautocommands for theBufNewFile andBufRead events.  If the file typeis not found by thename, the file $VIMRUNTIME/scripts.vimis used to detectit from thecontents of the file.When theGUIis running or will start soon, themenu.vimscriptisalso sourced.  See'go-M' about avoiding that.To add your own file types, seenew-filetype below.  To search forhelp onafiletype prepend "ft-" and optionally append "-syntax", "-indent" or"-plugin".  For example::help ft-vim-indent:help ft-vim-syntax:help ft-man-pluginIf the file typeis not detected automatically, orit finds the wrong type,you can either set the'filetype' option manually, or addamodeline to yourfile.  Example, for an IDL file use the command::set filetype=idlor add thismodeline to the file:/* vim: set filetype=idl : */:filetype-plugin-onYou can enable loading theplugin files for specific file types with::filetype plugin onIffiletype detection was not switched on yet,it will beas well.This actually loads the file "ftplugin.vim" in'runtimepath'.The resultis that whena fileis edited itsplugin fileis loaded (if thereis one for the detected filetype).filetype-plugin:filetype-plugin-offYou can disableit again with::filetype plugin offThefiletype detectionis not switched off then.  But if youdo switch offfiletype detection, the plugins will not be loaded either.This actually loads the file "ftplugof.vim" in'runtimepath'.:filetype-indent-onYou can enable loading the indent file for specific file types with::filetype indent onIffiletype detection was not switched on yet,it will beas well.This actually loads the file "indent.vim" in'runtimepath'.The resultis that whena fileis edited its indent fileis loaded (if thereis one for the detected filetype).indent-expression:filetype-indent-offYou can disableit again with::filetype indent offThefiletype detectionis not switched off then.  But if youdo switch offfiletype 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 inalready opened files.  Reset'autoindent','cindent','smartindent' and/or'indentexpr' to disable indenting in an opened file.:filetype-offTo disable file type detection, use this command::filetype offThis will keep the flags for "plugin" and "indent", but since no file typesare being detected, they won't work until the next ":filetype on".Overview::filetype-overviewcommanddetectionpluginindent:filetype ononunchangedunchanged:filetype offoffunchangedunchanged:filetypeplugin onononunchanged:filetypeplugin offunchangedoffunchanged:filetype indent ononunchangedon:filetype indent offunchangedunchangedoff:filetypeplugin indent onononon:filetypeplugin indent offunchangedoffoffTo see the current status, type::filetypeThe output looks something like this:filetype detection:ON  plugin:ON  indent:OFFThe file types are also used forsyntax highlighting.  If the ":syntax on"commandis used, the file type detectionis installed too.  Thereis no needtodo ":filetype on" after ":syntax on".To disable one of the file types, adda line in yourfiletype file, seeremove-filetype.filetype-detectTo detect the file type again::filetype detectUse this if you started with an empty file and typed text that makesitpossible to detect the file type.  For example, when you entered this inashell script: "#!/bin/csh".   Whenfiletype detection was off,it will be enabled first, like the "on"argument was used.filetype-overruleWhen the same extensionis used for multiple filetypes, Vim tries to guesswhat kind of fileit is.  This doesn't always work.A number of globalvariables can be used to overrule thefiletype used for certain extensions:file namevariable*.appg:filetype_app*.asag:filetype_asaft-aspperl-syntaxft-aspvbs-syntax*.asmg:asmsyntaxft-asm-syntax*.aspg:filetype_aspft-aspperl-syntaxft-aspvbs-syntax*.basg:filetype_basft-basic-syntax*.cfgg:filetype_cfg*.clsg:filetype_cls*.cshg:filetype_cshft-csh-syntax*.datg:filetype_dat*.defg:filetype_def*.dspg:filetype_dsp*.fg:filetype_fft-forth-syntax*.frmg:filetype_frmft-form-syntax*.fsg:filetype_fsft-forth-syntax*.hg:c_syntax_for_hft-c-syntax  (deprecated)*.hg:ch_syntax_for_hft-ch-syntax  (deprecated)*.hg:filetype_hft-c-syntaxft-ch-syntaxft-cpp-syntax*.ig:filetype_ift-progress-syntax*.incg:filetype_inc*.lslg:filetype_lsl*.mg:filetype_mft-mathematica-syntax*[mM]makefile,*.mk,.mak,[mM]akefileg:make_flavorft-make-syntax*.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.mdg:filetype_mdft-pandoc-syntax*.modg:filetype_mod*.pg:filetype_pft-pascal-syntax*.plg:filetype_pl*.ppg:filetype_ppft-pascal-syntax*.prgg:filetype_prg*.rg:filetype_r*.sigg:filetype_sig*.sqlg:filetype_sqlft-sql-syntax*.srcg:filetype_src*.sysg:filetype_sys*.shg:bash_is_shft-sh-syntax*.texg:tex_flavorft-tex-plugin*.typg:filetype_typ*.vg:filetype_v*.wg:filetype_wft-cweb-syntaxFora fewfiletypes the global variableis used only when thefiletype couldnot be detected:*.rg:filetype_rft-rexx-syntaxfiletype-ignoreTo avoid that certain files are being inspected, the g:ft_ignore_pat variableis used.  The default valueis 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-filetypeIfa file type that you want to useis not detected yet, there are four waysto add it.  In any way, it's better not to modify the $VIMRUNTIME/filetype.vimfile.  It will be overwritten when installinga new version of Vim.A. If you want to overrule all default file type checks.   This works bywriting one file for each filetype.  The disadvantageis that   there can be many files.  The advantageis that you can simply drop this   file in the right directory to makeit 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 ~/.vim:!mkdir ~/.vim/ftdetect   2. Createa file that contains anautocommand to detect the file type.      Example:au BufRead,BufNewFile *.mineset filetype=mineNote that thereis no "augroup" command, this has already been done      when sourcing your file.  You could also use thepattern "*" and then      check the contents of the file to recognize it.      Write this fileas "mine.vim" in the "ftdetect" directory in your user      runtime directory.  For example, for Unix::w ~/.vim/ftdetect/mine.vim  3. To use the newfiletype detection youmust restart Vim.   The files in the "ftdetect" directory are used after all the default   checks, thus they can overrulea previously detected file type.  But you   can also use:setfiletype to keepa previously detected filetype.B. If you want to detect your file after the default file type checks.   This works likeA 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 *.txtsetfiletype 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       | endifC. If your file type can be detected by the file name.   1. Create your user runtime directory.  You would normally use the first      item of the'runtimepath' option.  Example for Unix::!mkdir ~/.vim   2. Createa file that containsautocommands to detect the file type.      Example:" my filetype fileif exists("did_load_filetypes")  finishendifaugroup filetypedetect  au! BufRead,BufNewFile *.minesetfiletype mine  au! BufRead,BufNewFile *.xyzsetfiletype drawingaugroup END     Write this fileas "filetype.vim" in your user runtime directory.  For      example, for Unix::w ~/.vim/filetype.vim  3. To use the newfiletype detection youmust restart Vim.   Your filetype.vim will be sourced before the defaultFileTypeautocommands   have been installed.  Yourautocommands will match first, and the   ":setfiletype" command will make sure that no otherautocommands will set'filetype' after this.new-filetype-scriptsD. If yourfiletype can only be detected by inspecting the contents of the   file.   1. Create your user runtime directory.  You would normally use the first      item of the'runtimepath' option.  Example for Unix::!mkdir ~/.vim   2. Createa Vimscript file for doing this.  Example:if did_filetype()" filetype already set..  finish" ..don't do these checksendifif getline(1) =~ '^#!.*\<mine\>'  setfiletype mineelseif getline(1) =~? '\<drawing\>'  setfiletype drawingendif     See $VIMRUNTIME/scripts.vim for more examples.      Write this fileas "scripts.vim" in your user runtime directory.  For      example, for Unix::w ~/.vim/scripts.vim   3. The detection will work right away, no need to restart Vim.   Your scripts.vimis loaded before the default checks for file types, which   means that your rules override the default rules in   $VIMRUNTIME/scripts.vim.remove-filetypeIfa file typeis detected thatis wrong for you,installa filetype.vim orscripts.vim to catchit (see above).  You can set'filetype' toa non-existingname to avoid thatit will be set later anyway::set filetype=ignoredIf you are setting upa system with many users, and you don't want each userto add/remove the same filetypes, considerwriting the filetype.vim andscripts.vim files ina runtime directory thatis used for everybody.  Checkthe'runtimepath' fora directory to use.  If there isn't one, set'runtimepath' in thesystem-vimrc.  Be careful to keep the defaultdirectories!autocmd-osfiletypesNOTE: this codeis currently disabled,as the RISC OS implementation wasremoved.  In the future this will use the'filetype' option.On operating systems which support storinga file type with the file, you canspecify that anautocommand should only be executed if the fileis ofacertain type.The actual type checking depends on which platform you are running Vimon; see your system's documentation for details.To use osfiletype checking in anautocommand you shouldputalist of types tomatch in angle brackets in place ofa pattern, like this::au BufRead *.html,<&faf;HTML>  runtime! syntax/html.vimThis will match:- Any file whose name ends in ".html"- Any file whose typeis "&faf" or "HTML", where the meaning of these types  depends on which version of Vim you are using.  Unknown types are considered NOT to match.You can also specifya type andapatternat the same time (in whichcase theymust both match)::au BufRead <&fff>diff*This will match files of type "&fff" whose names start with "diff".plugin-detailsThe "plugin" directory can be in any of the directories in the'runtimepath'option.  All of these directories will be searched for plugins and they areall loaded.  For example, if this command:set runtimepathproduces this output:runtimepath=/etc/vim,~/.vim,/usr/local/share/vim/vim82then Vim will load all plugins in these directories and below:/etc/vim/plugin/~/.vim/plugin//usr/local/share/vim/vim82/plugin/Note that the last oneis the value of$VIMRUNTIME which has been expanded.Note that when usingaplugin manager orpackages many directories will beadded to'runtimepath'.  These plugins each require their own directory, don'tput them directly in ~/.vim/plugin.What ifit looks like yourpluginis not being loaded?  You can find out whathappens when Vim starts up by using the-V argument:vim -V2You will seea lot of messages, in between themisa remark about loading theplugins.  It starts with:Searching for "plugin/**/*.vim" inThere you can see where Vim looks for yourplugin scripts.==============================================================================2. Filetypepluginfiletype-pluginsWhen loadingfiletype plugins has been enabled:filetype-plugin-on,optionswill be set and mappings defined.  These are all local to the buffer, theywill not be used for other files.Defining mappings forafiletype may get in the way of the mappings youdefine yourself.  There area few ways to avoid this:1. Set the "maplocalleader" variable to the key sequence you want the mappings   to start with.  Example::let maplocalleader = ","  All mappings will then start witha comma instead of the default, whichisa backslash.  Also see<LocalLeader>.2. Define your own mapping.  Example::map ,p <Plug>MailQuote  You need to check the description of theplugin file below for the   functionalityit offers and thestring to map to.   You need to define your ownmapping before thepluginis loaded (before   editinga file of that type).  Theplugin will then skip installing the   default mapping.no_mail_mapsg:no_mail_maps3. Disable defining mappings fora specificfiletype by settinga variable,   which contains the name of the filetype.  For the "mail"filetype this   would be::let no_mail_maps = 1no_plugin_mapsg:no_plugin_maps4. Disable defining mappings for allfiletypes by settinga variable::let no_plugin_maps = 1ftplugin-overruleIfa globalfiletypeplugin does notdo exactly what you want, there are threeways to change this:1. Adda few settings.   Youmust createa newfiletypeplugin ina directory early in'runtimepath'.  For Unix, for example you could use this file:vim ~/.vim/ftplugin/fortran.vim   You can set those settings and mappings that you would like to add.Note   that the globalplugin will be loaded after this,it may overrule the   settings that youdo here.  If thisis the case, you need to use one of the   following two methods.2. Makea copy of theplugin and change it.   Youmustput the copy ina directory early in'runtimepath'.  For Unix, for   example, you coulddo this:cp $VIMRUNTIME/ftplugin/fortran.vim ~/.vim/ftplugin/fortran.vim   Then you can edit the copied file to your liking.  Since the b:did_ftplugin   variable will be set, the globalplugin will not be loaded.A disadvantage of thismethodis that when the distributedplugin gets   improved, you will have to copy and modifyit again.3. Overrule the settings after loading the global plugin.   Youmust createa newfiletypeplugin ina directory from theend of'runtimepath'.  For Unix, for example, you could use this file:vim ~/.vim/after/ftplugin/fortran.vim   In this file you can change just those settings that you want to change.==============================================================================3.  Docs for the defaultfiletype plugins.ftplugin-docsplugin_execg:plugin_execEnable executing of external commands.  This was done historically for e.g.theperlfiletypeplugin (anda few others) to set the search path.Disabled by default for security reasons::let g:plugin_exec = 1Itis 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 globalplugin_exec and the<filetype>_exec specific variableare set, thefiletype specific variable should have precedent.ASCIIDOCft-asciidoc-pluginTo enablefolding use this:let g:asciidoc_folding = 1To disable nesting of folded headers use this:let g:asciidoc_foldnested = 0To disablefolding everything under the title use this:let asciidoc_fold_under_title = 0ARDUINOft-arduino-pluginBy default the followingoptions are set, in accordance with the defaultsettings of Arduino IDE:setlocal expandtab tabstop=2 softtabstop=2 shiftwidth=2To disable this behavior, set the following variable in your vimrc:let g:arduino_recommended_style = 0AWKft-awk-pluginSupport for features specific to GNU Awk, like @include, can be enabled bysetting::let g:awk_is_gawk = 1CHANGELOGft-changelog-pluginAllows foreasy entrance of Changelog entries in Changelog files.  There aresome commands, mappings, andvariables worth exploring:Options:'comments'is made empty to not mess up formatting.'textwidth'is set to 78, whichis standard.'formatoptions'the 't' flagis added to wrap wheninserting text.Commands:NewChangelogEntryAddsa new Changelog entry in an intelligent fashion(see below).Local mappings:<Leader>oStartsa new Changelog entry in an equally intelligentfashion (see below).Global mappings:NOTE: The global mappings are accessed by sourcing theftplugin/changelog.vim file first, e.g. withruntime ftplugin/changelog.vimin your.vimrc.<Leader>oSwitches to the ChangeLog buffer opened for thecurrent directory, or opensit ina new buffer ifitexists in the current directory.  Thenit does thesameas the local<Leader>o described above.Variables:g:changelog_timeformat  Deprecated; use g:changelog_dateformat instead.g:changelog_dateformatThe date (and time) format used in ChangeLog entries.The format acceptedis the sameas for thestrftime() function.The defaultis "%Y-%m-%d" whichis the standard formatfor many ChangeLog layouts.g:changelog_usernameThe name and email address of the user.The defaultis deduced from environmentvariables andsystem files.  It searches /etc/passwd for the commentpart of the current user, which informally containsthe real name of the user up to the first separatingcomma.  thenit checks the $NAME environment variableand finally runswhoami andhostname to build anemail address.  The final formisFull Name  <user@host>g:changelog_new_date_formatThe format to use when creatinga new date-entry.The following table describes special tokens in thestring:%%inserta single '%' character%dinsert the date from above%uinsert the user from above%pinsert result ofb:changelog_entry_prefix%cwhere to position cursor when doneThe defaultis "%d  %u\n\n\t* %p%c\n\n", whichproduces something like(|is where cursor will be,unlessat the start of the line whereit denotes thebeginning of the line)|2003-01-14  Full Name  <user@host>||        * prefix|g:changelog_new_entry_formatThe format used when creatinga new entry.The following table describes special tokens in thestring:%pinsert result ofb:changelog_entry_prefix%cwhere to position cursor when doneThe defaultis "\t*%c", which produces somethingsimilar to|        * prefix|g:changelog_date_entry_searchThe searchpattern to use when searching foradate-entry.The same tokens that can be used forg:changelog_new_date_format can be used hereas well.The defaultis '^\s*%d\_s*%u' which finds linesmatching the form|2003-01-14  Full Name  <user@host>and some similar formats.g:changelog_date_end_entry_searchThe searchpattern to use when searching for theendofa date-entry.The same tokens that can be used forg:changelog_new_date_format can be used hereas well.The defaultis '^\s*$' which finds lines that containonlywhitespace or are completely empty.b:changelog_nameb:changelog_nameName of the ChangeLog file to look for.The defaultis 'ChangeLog'.b:changelog_pathPath of the ChangeLog to use for the current buffer.The defaultis empty, thus looking fora file namedb:changelog_name in the same directoryas thecurrent buffer.  If not found, the parent directory ofthe current bufferis searched.  This continuesrecursively untila fileis found or there are no moreparent directories to search.b:changelog_entry_prefixName ofa function to call to generatea prefix toanew entry.  This function takes no arguments andshould returnastring containing the prefix.Returning an empty prefixis fine.The default generates the shortest path between theChangeLog's pathname and the currentbuffers pathname.In the future,it will also be possible to use othervariable contexts for this variable, for example, g:.The Changelog entries are inserted where they add the least amount of text.After figuring out the current date and user, the fileis searched for anentry beginning with the current date and user and if found adds another itemunder it.  If not found,a new entry and itemis prepended to the beginning ofthe Changelog.FORTRANft-fortran-pluginOptions:'expandtab'is switched on to avoid tabsas required by the Fortranstandards unless the user has set fortran_have_tabs in .vimrc.'textwidth'is set to 80 for fixed source format whereasitis set to 132for free source format.  Setting thefortran_extended_line_length variable increases the width to132 for fixed source format.'formatoptions'is set to break code and comment lines and to preserve longlines.  You can format comments withgq.For further discussion of fortran_have_tabs and themethod used for thedetection of source format seeft-fortran-syntax.FREEBASICft-freebasic-pluginThisplugin aims to treat the four FreeBASIC dialects, "fb", "qb", "fblite"and "deprecated",as distinct languages.The dialect will be set to the first name found in g:freebasic_forcelang, any#lang directive or $lang metacommand in the file being edited, or finallyg:freebasic_lang.  These globalvariables conceptually map to the fbcoptions-forcelang and -lang.  If no dialectis explicitly specified "fb" will beused.For example, to set the dialect toa default of "fblite" but still allow forany #lang directive overrides, use the following command:let g:freebasic_lang = "fblite"GDSCRIPTft-gdscript-pluginBy default the followingoptions are set, based on Godot official docs:setlocal noexpandtab softtabstop=0 shiftwidth=0To disable this behavior, set the following variable in your vimrc:let g:gdscript_recommended_style = 0GIT COMMITft-gitcommit-pluginOne command, :DiffGitCached,is provided to showadiff of the current commitin the preview window.  Itis equivalent to calling "gitdiff --cached" plusany arguments given to the command.GIT REBASEft-gitrebase-pluginThe gitrebasefiletype defines the following buffer-local commands, tohelpwith interactive `git rebase`::Drop   " to discard this commit:Edit   " to stop for editing this commit:Fixup  " to squash (but discard the message) into the previous one:Pick   " to pick this commit (the cursor is on):Reword " to pick this commit, but change the commit message:Squash " to squash this commit into the previous oneIn addition, the following command can be used to cycle between the differentpossibilities::Cycle  " to cycle between the previous commandsThe:Cycle commandis also mapped to theCTRL-A andCTRL-X keys.For details, see `git-rebase --help`.GLEAMft-gleam-pluginBy default the followingoptions are set for the recommended gleam style:setlocal expandtab shiftwidth=2 softtabstop=2To disable this behavior, set the following variable in your vimrc:let g:gleam_recommended_style = 0GOft-go-pluginBy default the followingoptions are set, based on Golang official docs:setlocal noexpandtab softtabstop=0 shiftwidth=0To disable this behavior, set the following variable in your vimrc:let g:go_recommended_style = 0GPROFft-gprof-pluginThe gproffiletypeplugin definesamapping<C-]> to jump froma functionentry in the gprof flatprofile or froma function entry in the call graphto the details of that function in the call graph.Themapping can be disabled with:let g:no_gprof_maps = 1HAREft-hareSince the text for thispluginis rather longit has beenput ina separatefile:ft_hare.txt.HTMLft-html-pluginTagfolding posesa few difficulties.  Many elements, e.g.blockquote, arealways delimited by start andend tags;endtags for some elements, e.g.p,can be omitted in certain contexts; void elements, e.g.hr, have noend tag.Although the rules for supporting omissibleendtags are ad-hoc and involved[0], they apply to elements in scope.  Assuming syntactical wellformedness, anendtag can be associated with its nearest matching starttag discoverable inscope [1] and towards the beginning ofa file, whereas all unbalancedtags andinlinedtags can be disregarded.  Havingsyntax highlighting in effect,tagfolding using thefold-exprmethod can be enabled with:let g:html_expr_folding = 1By default,tagfolding will be redone from scratch after each occurrence ofaTextChanged or anInsertLeave event.  Such frequency may not be desired,especially for large files, and this recomputation can be disabled with:let g:html_expr_folding_without_recomputation = 1        doautocmd FileTypeTo force another recomputation, do:unlet! b:foldsmapnormal zx[0]https://html.spec.whatwg.org/multipage/syntax.html#optional-tags[1]https://en.wikipedia.org/wiki/Dangling_elseIDRIS2ft-idris2-pluginBy default the followingoptions are set:setlocal shiftwidth=2 tabstop=2 expandtabsetlocal comments=s1:{-,mb:-,ex:-},:\|\|\|,:--setlocal commentstring=--\ %ssetlocal wildignore+=*.ibcTo use tabs instead of spaces for indentation, set the following variablein your vimrc:let g:idris2#allow_tabchar = 1JAVAft-java-pluginWhenever the variable "g:ftplugin_java_source_path"is defined and its valueisa filename whose extensionis either ".jar" or ".zip", e.g.:let g:ftplugin_java_source_path = '/path/to/src.jar'let g:ftplugin_java_source_path = '/path/to/src.zip'and thezipplugin has already been sourced, thegf command can be used toopen the archive and then command can be used to look for the selected typeand the<Return> key can be used to loada listed file.Note that the effect of using the "gf" command WITHINa buffer loaded with theZipplugin depends on the version of the Zip plugin.  For the Zippluginversions thatdo not support Jar type archives, consider creating symboliclinks with the ".zip" extension for each Jar archive of interest and assigningany such file to the variable from now on.Otherwise, for the defined variable "g:ftplugin_java_source_path", the localvalue of the'path' option will be further modified by prefixing the value ofthe variable, e.g.:let g:ftplugin_java_source_path = $JDK_SRC_PATHlet &l:path = g:ftplugin_java_source_path .. ',' .. &l:pathand the "gf" command can be used ona fully-qualified type to look fora filein the "path" and to try to load it.Remember to manually trigger theFileType event froma buffer witha Javafile loaded init each time after assigninga new value to the variable:doautocmd FileTypeMarkdown documentation comments may contain common runs of vertical leadingwhitespace following the comment marks (`///`) for aesthetic reasons; however,some horizontal runs of leadingwhitespace are significant in Markdown becausethey denote code blocks etc.  For convenience,a'formatexpr' functionisprovided for thegq operator.  As longas neither "g:java_ignore_javadoc"nor "g:java_ignore_markdown"is defined, the reformatting of Markdown commentscan be enabled on demand with:setlocal formatexpr=g:javaformat#RemoveCommonMarkdownWhitespace()Or for Vim versionsless than7.4.265, with:setlocal formatexpr=javaformat#RemoveCommonMarkdownWhitespace()This function acceptsa range of lines, removesa common run of verticalleading whitespace, and rewrites the lines of the range.  Depending on theauthor's layout style and the comment contents, which lines to select forreformatting can vary from the whole comment to only some portion of it.To enable the recognition of Markdown comments each time after removing"g:java_ignore_markdown" or "g:java_ignore_javadoc", remember to manuallyre-source "javaformat.vim" for Vim versions greater than8.2.1397:runtime autoload/javaformat.vimJSON-FORMATft-json-pluginJSONfiletype can be extended to use'formatexpr' and "json.FormatExpr()"function for jsonformatting (usinggq).Add following lines to $HOME/.vim/ftplugin/json.vim:vim9scriptimport autoload 'dist/json.vim'setl formatexpr=json.FormatExpr()LUAft-lua-pluging:lua_foldingYou can enablefolding ofLuafunctions usingfold-expr by:let g:lua_folding = 1g:lua_versiong:lua_subversionLua filetype's'includeexpr' andft-lua-syntax highlighting use the globalvariables "g:lua_version" and "g:lua_subversion" to determine the version ofLua to use (5.3is the default)For example, to useLua 5.1, set thevariables like this:let g:lua_version = 5let g:lua_subversion = 1MAILft-mail-pluginOptions:'modeline'is switched off to avoid the danger of trojan horses, and toavoid thata Subject line with "Vim:" init will cause anerror message.'textwidth'is set to 72.  Thisis often recommended for e-mail.'formatoptions'is set to break text lines and to repeat the comment leaderin new lines, so thata leading ">" forquotesis repeated.You can also format quoted text withgq.Local mappings:<LocalLeader>q   or   \MailQuoteQuotes the text selected inVisual mode, or from the cursor positionto theend of the file inNormal mode.  This means "> "is inserted ineach line.MANft-man-plugin:Man:ManReloadman.vimThisplugin displaysa manual page ina nice way.  Seefind-manpage in theuser manual for more information.To start using the:Man command before any manual page has been loaded,source thisscript from yourstartupvimrc file:runtime ftplugin/man.vimOptions:'iskeyword'The '.' characteris added to support the use ofCTRL-] on themanual page name.Commands:Man{name}Display the manual page for{name} ina window.Man{number}{name}Display the manual page for{name} inasection{number}.ManReloadReload the cache of available man pages used for:Man argumentcompletion.Global mapping:<Leader>KDisplays the manual page for theword under the cursor.<Plug>ManPreGetPageidem, allows for usinga mapping:nmap <F1> <Plug>ManPreGetPageLocal mappings:<Plug>ManBS<LocalLeader>hClearbackspace<BS> characters from the buffer.CTRL-]Jump to the manual page for theword under the cursor.CTRL-TJump back to the previous manual page.The mappings can be disabled with:let g:no_man_maps = 1To usea vertical split instead of horizontal:let g:ft_man_open_mode = 'vert'To usea new tab:let g:ft_man_open_mode = 'tab'To enablefolding, use this:let g:ft_man_folding_enable = 1If youdo not like the default folding, use anautocommand to add yourdesiredfolding style instead.  For example:autocmd FileType man setlocal foldmethod=indent foldenableIf you would like:Man{number}{name} to behave like man{number}{name} bynot running man{name} if no pageis found, then use this:let g:ft_man_no_sect_fallback = 1g:ft_man_implementationThe completion for the:Man command tries to guess which implementation of manthe system has.  Ifit guesses wrong, you can setg:ft_man_implementation toone of these values:'man-db'https://man-db.nongnu.org/''Unknown, fall back to completing shell commandsinstead of man pages.You may also want to set'keywordprg' to make theK command opena manualpage ina Vim window:set keywordprg=:ManMANPAGERmanpager.vimThe:Man command allows you to turn Vim intoa manpager (thatsyntaxhighlights manpages and follows linked manpages on hittingCTRL-]).For bash,zsh,ksh or dash, add to the config file (.bashrc,.zshrc, ...)export MANPAGER="vim +MANPAGER--not-a-term-"For (t)csh, add to the config filesetenv MANPAGER "vim +MANPAGER--not-a-term-"For fish, add to the config fileset-x MANPAGER "vim +MANPAGER--not-a-term-"MARKDOWNft-markdown-pluginTo enablefolding use this:let g:markdown_folding = 1'expandtab' will be set by default.  If youdo not want that use this:let g:markdown_recommended_style = 0ORGft-org-pluginTo enablefolding use this:let g:org_folding = 1PDFft-pdf-pluginTwo maps,<C-]> and<C-T>, are provided to simulateatag stack for navigatingthe PDF.  The following are treatedas tags:- The byte offset after "startxref" to the xref table- The byte offset after the /Prev key in the trailer to an earlier xref table-A line of the form "0123456789 00000n" in the xref table- Anobjectreference like "10R" anywhere in the PDFThese maps can be disabled with:let g:no_pdf_maps = 1PLSQLft-plsql-pluginTo enablesyntaxfolding in PL/SQL filetypes, set the following variable::let g:plsql_fold = 1PYTHONft-python-pluginPEP8By default the followingoptions are set, in accordance with PEP8:setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8To disable this behavior, set the following variable in your vimrc:let g:python_recommended_style = 0QF QUICKFIXqf.vimft-qf-pluginThe "qf"filetypeis used for thequickfix window, seequickfix-window.Thequickfixfiletypeplugin includes configuration for displaying the commandthat produced thequickfixlist in thestatus-line.  To disable this setting,configureas follows::let g:qf_disable_statusline = 1R MARKDOWNft-rmd-pluginBy default ftplugin/html.vimis not sourced.  If you wantit sourced, add toyourvimrc:let rmd_include_html = 1The'formatexpr' optionis set dynamically with different values forR codeand for Markdown code.  If you prefer that'formatexpr'is not set, add toyourvimrc:let rmd_dynamic_comments = 0R RESTRUCTURED TEXTft-rrst-pluginThe'formatexpr' optionis set dynamically with different values forR codeand for ReStructured text.  If you prefer that'formatexpr'is not set, add toyourvimrc:let rrst_dynamic_comments = 0RESTRUCTUREDTEXTft-rst-pluginThe followingformatting setting are optionally available:setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8To enable this behavior, set the following variable in your vimrc:let g:rst_style = 1RNOWEBft-rnoweb-pluginThe'formatexpr' optionis set dynamically with different values forR codeand for LaTeX code.  If you prefer that'formatexpr'is not set, add to yourvimrc:let rnw_dynamic_comments = 0RPM SPECft-spec-pluginSince the text for thispluginis rather longit has beenput ina separatefile:pi_spec.txt.RUSTft-rustSince the text for thispluginis rather longit has beenput ina separatefile:ft_rust.txt.SQLft-sqlSince the text for thispluginis rather longit has beenput ina separatefile:ft_sql.txt.TEXft-tex-pluging:tex_flavorIf the first line ofa *.tex file has the form%&<format>then this determined the file type:  plaintex (for plain TeX), context (forConTeXt), or tex (for LaTeX).  Otherwise, the fileis searched for keywords tochoose context or tex.  If no keywords are found,it defaults to plaintex.You can change the default by defining the variableg: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.TYPSTft-typst-pluging:typst_concealWhenTRUE the Typstfiletypeplugin will set the'conceallevel' option to 2.g:typst_foldingWhenTRUE the Typstfiletypeplugin will fold headings. (default:FALSE)To enable:let g:typst_folding = 1g:typst_foldnestedWhenTRUE the Typstfiletypeplugin will fold nested heading under theirparents. (default:TRUE)To disable:let g:typst_foldnested = 0VIMft-vim-pluginThe Vimfiletypeplugin defines the following mappings:[[move to the start of the previous function]]move to the start of the next function][move to theend of the previous function[]move to theend of the next function]"move to the next (legacy) comment["move to the previous (legacy) commentgfedit the file under the cursorCTRL-Wgfedit the file under the cursor ina newtab pageCTRL-Wfedit the file under the cursor ina newwindowThe mappings can be disabled with:let g:no_vim_maps = 1YAMLft-yaml-pluginBy default, the YAMLfiletypeplugin enables the following options:setlocal shiftwidth=2 softtabstop=2To disable this, set the following variable:let g:yaml_recommended_style = 0ZIGft-zig-pluging:zig_recommended_styleBy default the following indentationoptions are set, in accordance with Zig'srecommended style (https://ziglang.org/documentation/master/):setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8To disable this behavior, setg:zig_recommended_style to 0:let g:zig_recommended_style = 0g:zig_std_dirThe path to the Zig standard library.  The Zigftplugin readsg:zig_std_dirand appendsit to the'path' for Zig files.  Where the Zig standard libraryis locatedis system and installationmethod dependent.One can automatically setg:zig_std_dir using `zig env`:let g:zig_std_dir = json_decode(system('zig env'))['std_dir']This can, for example, beput inaFileType:autocmd or userftplugin toonly load whena Zig fileis opened.ZIMBUft-zimbu-pluginThe Zimbufiletypeplugin defines mappings to move to the start andend offunctions with[[ and ]].The mappings can be disabled with:let g:no_zimbu_maps = 1 vim:tw=78:ts=8:noet:ft=help:norl:

Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq


[8]ページ先頭

©2009-2026 Movatter.jp