filetype.txt (44837B)
1 *filetype.txt* Nvim 2 3 4 VIM REFERENCE MANUAL by Bram Moolenaar 5 6 7 Filetypes *filetype* *file-type* 8 9 Also see |autocmd.txt|. 10 11 Type |gO| to see the table of contents. 12 13 ============================================================================== 14 1. Filetypes *filetypes* *file-types* 15 16 Vim can detect the type of file that is edited. This is done by checking the 17 file name and sometimes by inspecting the contents of the file for specific 18 text. 19 20 *:filetype* *:filet* 21 To enable file type detection, use this command in your vimrc: > 22 :filetype on 23 Each time a new or existing file is edited, Vim will try to recognize the type 24 of the file and set the 'filetype' option. This will trigger the FileType 25 event, which can be used to set the syntax highlighting, set options, etc. 26 27 Detail: The ":filetype on" command will load these files: 28 $VIMRUNTIME/filetype.lua 29 $VIMRUNTIME/filetype.vim 30 filetype.lua creates an autocommand that fires for all BufNewFile and 31 BufRead events. It tries to detect the filetype based off of the 32 file's extension or name. 33 34 filetype.vim is a Vim script that defines autocommands for the 35 BufNewFile and BufRead events. In contrast to filetype.lua, this 36 file creates separate BufNewFile and BufRead events for each filetype 37 pattern. 38 39 If the file type is not found by the name, the file 40 $VIMRUNTIME/scripts.vim is used to detect it from the contents of the 41 file. 42 When the GUI is running or will start soon, the |menu.vim| script is 43 also sourced. 44 45 To add your own file types, see |new-filetype| below. To search for help on a 46 filetype prepend "ft-" and optionally append "-syntax", "-indent" or 47 "-plugin". For example: > 48 :help ft-vim-indent 49 :help ft-vim-syntax 50 :help ft-man-plugin 51 52 If the file type is not detected automatically, or it finds the wrong type, 53 you can either set the 'filetype' option manually, or add a modeline to your 54 file. Example, for an IDL file use the command: > 55 :set filetype=idl 56 57 or add this |modeline| to the file: > 58 /* vim: set filetype=idl : */ 59 < 60 *:filetype-plugin-on* 61 You can enable loading the plugin files for specific file types with: > 62 :filetype plugin on 63 If filetype detection was not switched on yet, it will be as well. 64 This actually loads the file "ftplugin.vim" in 'runtimepath'. 65 The result is that when a file is edited its plugin file is loaded (if there 66 is one for the detected filetype). |filetype-plugin| 67 68 *:filetype-plugin-off* 69 You can disable it again with: > 70 :filetype plugin off 71 The filetype detection is not switched off then. But if you do switch off 72 filetype detection, the plugins will not be loaded either. 73 This actually loads the file "ftplugof.vim" in 'runtimepath'. 74 75 *:filetype-indent-on* 76 You can enable loading the indent file for specific file types with: > 77 :filetype indent on 78 If filetype detection was not switched on yet, it will be as well. 79 This actually loads the file "indent.vim" in 'runtimepath'. 80 The result is that when a file is edited its indent file is loaded (if there 81 is one for the detected filetype). |indent-expression| 82 83 *:filetype-indent-off* 84 You can disable it again with: > 85 :filetype indent off 86 The filetype detection is not switched off then. But if you do switch off 87 filetype detection, the indent files will not be loaded either. 88 This actually loads the file "indoff.vim" in 'runtimepath'. 89 This disables auto-indenting for files you will open. It will keep working in 90 already opened files. Reset 'autoindent', 'cindent', 'smartindent' and/or 91 'indentexpr' to disable indenting in an opened file. 92 93 *:filetype-off* 94 To disable file type detection, use this command: > 95 :filetype off 96 This will keep the flags for "plugin" and "indent", but since no file types 97 are being detected, they won't work until the next ":filetype on". 98 99 100 Overview: *:filetype-overview* 101 102 command detection plugin indent ~ 103 :filetype on on unchanged unchanged 104 :filetype off off unchanged unchanged 105 :filetype plugin on on on unchanged 106 :filetype plugin off unchanged off unchanged 107 :filetype indent on on unchanged on 108 :filetype indent off unchanged unchanged off 109 :filetype plugin indent on on on on 110 :filetype plugin indent off unchanged off off 111 112 To see the current status, type: > 113 :filetype 114 The output looks something like this: > 115 filetype detection:ON plugin:ON indent:OFF 116 117 The file types are also used for syntax highlighting. If the ":syntax on" 118 command is used, the file type detection is installed too. There is no need 119 to do ":filetype on" after ":syntax on". 120 121 To disable one of the file types, add a line in your filetype file, see 122 |remove-filetype|. 123 124 *filetype-detect* 125 To detect the file type again: > 126 :filetype detect 127 Use this if you started with an empty file and typed text that makes it 128 possible to detect the file type. For example, when you entered this in a 129 shell script: "#!/bin/csh". 130 When filetype detection was off, it will be enabled first, like the "on" 131 argument was used. 132 133 *filetype-overrule* 134 When the same extension is used for multiple filetypes, Vim tries to guess 135 what kind of file it is. This doesn't always work. A number of global 136 variables can be used to overrule the filetype used for certain extensions: 137 138 file name variable ~ 139 `*.app` g:filetype_app 140 `*.asa` g:filetype_asa |ft-aspperl-syntax| 141 |ft-aspvbs-syntax| 142 `*.asm` g:asmsyntax |ft-asm-syntax| 143 `*.asp` g:filetype_asp |ft-aspperl-syntax| 144 |ft-aspvbs-syntax| 145 `*.bas` g:filetype_bas |ft-basic-syntax| 146 `*.cfg` g:filetype_cfg 147 `*.cls` g:filetype_cls 148 `*.csh` g:filetype_csh |ft-csh-syntax| 149 `*.dat` g:filetype_dat 150 `*.def` g:filetype_def 151 `*.dsp` g:filetype_dsp 152 `*.f` g:filetype_f |ft-forth-syntax| 153 `*.frm` g:filetype_frm |ft-form-syntax| 154 `*.fs` g:filetype_fs |ft-forth-syntax| 155 `*.h` g:c_syntax_for_h |ft-c-syntax| 156 `*.i` g:filetype_i |ft-progress-syntax| 157 `*.inc` g:filetype_inc 158 `*.lsl` g:filetype_lsl 159 `*.m` g:filetype_m |ft-mathematica-syntax| 160 `*[mM]makefile,*.mk,*.mak,[mM]akefile*` 161 g:make_flavor |ft-make-syntax| 162 `*.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md` 163 g:filetype_md |ft-pandoc-syntax| 164 `*.mod` g:filetype_mod 165 `*.p` g:filetype_p |ft-pascal-syntax| 166 `*.pl` g:filetype_pl 167 `*.pp` g:filetype_pp |ft-pascal-syntax| 168 `*.prg` g:filetype_prg 169 `*.r` g:filetype_r 170 `*.sig` g:filetype_sig 171 `*.sql` g:filetype_sql |ft-sql-syntax| 172 `*.src` g:filetype_src 173 `*.sys` g:filetype_sys 174 `*.sh` g:bash_is_sh |ft-sh-syntax| 175 `*.tex` g:tex_flavor |ft-tex-plugin| 176 `*.typ` g:filetype_typ 177 `*.v` g:filetype_v 178 `*.w` g:filetype_w |ft-cweb-syntax| 179 180 For a few filetypes the global variable is used only when the filetype could 181 not be detected: 182 `*.r` g:filetype_r |ft-rexx-syntax| 183 184 *filetype-ignore* 185 To avoid that certain files are being inspected, the g:ft_ignore_pat variable 186 is used. The default value is set like this: > 187 :let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$' 188 This means that the contents of compressed files are not inspected. 189 190 *new-filetype* 191 If a file type that you want to use is not detected yet, there are a few ways 192 to add it. The recommended way is to use |vim.filetype.add()| to add it to 193 Nvim's builtin filetype detection mechanism. If you want to handle the 194 detection manually, proceed as follows: 195 196 A. If you want to overrule all default file type checks. 197 This works by writing one file for each filetype. The disadvantage is that 198 there can be many files. The advantage is that you can simply drop this 199 file in the right directory to make it work. 200 *ftdetect* 201 1. Create your user runtime directory. You would normally use the first 202 item of the 'runtimepath' option. Then create the directory "ftdetect" 203 inside it. Example for Unix: > 204 :!mkdir -p ~/.config/nvim/ftdetect 205 < 206 2. Create a file that contains an autocommand to detect the file type. 207 Example: > 208 au BufRead,BufNewFile *.mine set filetype=mine 209 < Note that there is no "augroup" command, this has already been done 210 when sourcing your file. You could also use the pattern "*" and then 211 check the contents of the file to recognize it. 212 Write this file as "mine.vim" in the "ftdetect" directory in your user 213 runtime directory. For example, for Unix: > 214 :w ~/.config/nvim/ftdetect/mine.vim 215 216 < 3. To use the new filetype detection you must restart Vim. 217 218 The files in the "ftdetect" directory are used after all the default 219 checks, thus they can overrule a previously detected file type. But you 220 can also use |:setfiletype| to keep a previously detected filetype. 221 222 B. If you want to detect your file after the default file type checks. 223 224 This works like A above, but instead of setting 'filetype' unconditionally 225 use ":setfiletype". This will only set 'filetype' if no file type was 226 detected yet. Example: > 227 au BufRead,BufNewFile *.txt setfiletype text 228 < 229 You can also use the already detected file type in your command. For 230 example, to use the file type "mypascal" when "pascal" has been detected: > 231 au BufRead,BufNewFile * if &ft == 'pascal' | set ft=mypascal 232 | endif 233 234 C. If your file type can be detected by the file name or extension. 235 1. Create your user runtime directory. You would normally use the first 236 item of the 'runtimepath' option. Example for Unix: > 237 :!mkdir -p ~/.config/nvim 238 < 239 2. Create a file that contains autocommands to detect the file type. 240 Example: > 241 " my filetype file 242 if exists("did_load_filetypes") 243 finish 244 endif 245 augroup filetypedetect 246 au! BufRead,BufNewFile *.mine setfiletype mine 247 au! BufRead,BufNewFile *.xyz setfiletype drawing 248 augroup END 249 < 250 Write this file as "filetype.vim" in your user runtime directory. For 251 example, for Unix: > 252 :w ~/.config/nvim/filetype.vim 253 254 < 3. To use the new filetype detection you must restart Vim. 255 256 Your filetype.vim will be sourced before the default FileType autocommands 257 have been installed. Your autocommands will match first, and the 258 ":setfiletype" command will make sure that no other autocommands will set 259 'filetype' after this. 260 *new-filetype-scripts* 261 D. If your filetype can only be detected by inspecting the contents of the 262 file. 263 264 1. Create your user runtime directory. You would normally use the first 265 item of the 'runtimepath' option. Example for Unix: > 266 :!mkdir -p ~/.config/nvim 267 < 268 2. Create a Vim script file for doing this. Example: > 269 if did_filetype() " filetype already set.. 270 finish " ..don't do these checks 271 endif 272 if getline(1) =~ '^#!.*\<mine\>' 273 setfiletype mine 274 elseif getline(1) =~? '\<drawing\>' 275 setfiletype drawing 276 endif 277 < See $VIMRUNTIME/scripts.vim for more examples. 278 Write this file as "scripts.vim" in your user runtime directory. For 279 example, for Unix: > 280 :w ~/.config/nvim/scripts.vim 281 < 282 3. The detection will work right away, no need to restart Vim. 283 284 Your scripts.vim is loaded before the default checks for file types, which 285 means that your rules override the default rules in 286 $VIMRUNTIME/scripts.vim. 287 288 *remove-filetype* 289 If a file type is detected that is wrong for you, you can set 'filetype' to 290 a non-existing name such as `ignored` to avoid that it will be set later anyway. 291 292 *g:did_load_filetypes* 293 The builtin filetype detection provided by Nvim can be disabled by setting 294 the `did_load_filetypes` global variable. If this variable exists, the default 295 `$VIMRUNTIME/filetype.lua` will not run. 296 297 *plugin-details* 298 The "plugin" directory can be in any of the directories in the 'runtimepath' 299 option. All of these directories will be searched for plugins and they are 300 all loaded. For example, if this command: > 301 302 set runtimepath 303 304 produces this output: 305 306 runtimepath=/etc/vim,~/.config/nvim,/usr/local/share/vim/vim82 ~ 307 308 then Vim will load all plugins in these directories and below: 309 310 /etc/vim/plugin/ ~ 311 ~/.config/nvim/plugin/ ~ 312 /usr/local/share/vim/vim82/plugin/ ~ 313 314 Note that the last one is the value of $VIMRUNTIME which has been expanded. 315 316 Note that when using a plugin manager or |packages| many directories will be 317 added to 'runtimepath'. These plugins each require their own directory, don't 318 put them directly in ~/.config/nvim/plugin. 319 320 What if it looks like your plugin is not being loaded? You can find out what 321 happens when Vim starts up by using the |-V| argument: > 322 323 vim -V2 324 325 You will see a lot of messages, in between them is a remark about loading the 326 plugins. It starts with: 327 328 Searching for "plugin/**/*.vim" in ~ 329 330 There you can see where Vim looks for your plugin scripts. 331 332 ============================================================================== 333 2. Filetype plugin *filetype-plugins* 334 335 When loading filetype plugins has been enabled |:filetype-plugin-on|, options 336 will be set and mappings defined. These are all local to the buffer, they 337 will not be used for other files. 338 339 Defining mappings for a filetype may get in the way of the mappings you 340 define yourself. There are a few ways to avoid this: 341 1. Set the "maplocalleader" variable to the key sequence you want the mappings 342 to start with. Example: > 343 :let maplocalleader = "," 344 < All mappings will then start with a comma instead of the default, which 345 is a backslash. Also see |<LocalLeader>|. 346 347 2. Define your own mapping. Example: > 348 :map ,p <Plug>MailQuote 349 < You need to check the description of the plugin file below for the 350 functionality it offers and the string to map to. 351 You need to define your own mapping before the plugin is loaded (before 352 editing a file of that type). The plugin will then skip installing the 353 default mapping. 354 *no_mail_maps* *g:no_mail_maps* 355 3. Disable defining mappings for a specific filetype by setting a variable, 356 which contains the name of the filetype. For the "mail" filetype this 357 would be: > 358 :let no_mail_maps = 1 359 < *no_plugin_maps* *g:no_plugin_maps* 360 4. Disable defining mappings for all filetypes by setting a variable: > 361 :let no_plugin_maps = 1 362 < 363 364 *ftplugin-overrule* 365 If a global filetype plugin does not do exactly what you want, there are three 366 ways to change this: 367 368 1. Add a few settings. 369 You must create a new filetype plugin in a directory early in 370 'runtimepath'. For Unix, for example you could use this file: > 371 vim ~/.config/nvim/ftplugin/fortran.vim 372 < You can set those settings and mappings that you would like to add. Note 373 that the global plugin will be loaded after this, it may overrule the 374 settings that you do here. If this is the case, you need to use one of the 375 following two methods. 376 377 2. Make a copy of the plugin and change it. 378 You must put the copy in a directory early in 'runtimepath'. For Unix, for 379 example, you could do this: > 380 cp $VIMRUNTIME/ftplugin/fortran.vim ~/.config/nvim/ftplugin/fortran.vim 381 < Then you can edit the copied file to your liking. Since the b:did_ftplugin 382 variable will be set, the global plugin will not be loaded. 383 A disadvantage of this method is that when the distributed plugin gets 384 improved, you will have to copy and modify it again. 385 386 3. Overrule the settings after loading the global plugin. 387 You must create a new filetype plugin in a directory from the end of 388 'runtimepath'. For Unix, for example, you could use this file: > 389 vim ~/.config/nvim/after/ftplugin/fortran.vim 390 < In this file you can change just those settings that you want to change. 391 392 ============================================================================== 393 3. Docs for the default filetype plugins. *ftplugin-docs* 394 395 396 *plugin_exec* *g:plugin_exec* 397 Enable executing of external commands. This was done historically for e.g. 398 the perl filetype plugin (and a few others) to set the search path. 399 Disabled by default for security reasons: > 400 :let g:plugin_exec = 1 401 It is also possible to enable this only for certain filetypes: > 402 :let g:<filetype>_exec = 1 403 So to enable this only for ruby, set the following variable: > 404 :let g:ruby_exec = 1 405 406 If both, the global `plugin_exec` and the `<filetype>_exec` specific variable 407 are set, the filetype specific variable should have precedent. 408 409 410 ASCIIDOC *ft-asciidoc-plugin* 411 412 To enable |folding| use this: > 413 let g:asciidoc_folding = 1 414 415 To disable nesting of folded headers use this: > 416 let g:asciidoc_foldnested = 0 417 418 To disable folding everything under the title use this: > 419 let asciidoc_fold_under_title = 0 420 421 422 ARDUINO *ft-arduino-plugin* 423 424 By default the following options are set, in accordance with the default 425 settings of Arduino IDE: > 426 427 setlocal expandtab tabstop=2 softtabstop=2 shiftwidth=2 428 429 To disable this behavior, set the following variable in your vimrc: > 430 431 let g:arduino_recommended_style = 0 432 433 434 AWK *ft-awk-plugin* 435 436 Support for features specific to GNU Awk, like @include, can be enabled by 437 setting: > 438 :let g:awk_is_gawk = 1 439 440 441 CHANGELOG *ft-changelog-plugin* 442 443 Allows for easy entrance of Changelog entries in Changelog files. There are 444 some commands, mappings, and variables worth exploring: 445 446 Options: 447 'comments' is made empty to not mess up formatting. 448 'textwidth' is set to 78, which is standard. 449 'formatoptions' the 't' flag is added to wrap when inserting text. 450 451 Commands: 452 NewChangelogEntry Adds a new Changelog entry in an intelligent fashion 453 (see below). 454 455 Local mappings: 456 <Leader>o Starts a new Changelog entry in an equally intelligent 457 fashion (see below). 458 459 Global mappings: 460 NOTE: The global mappings are accessed by sourcing the 461 ftplugin/changelog.vim file first, e.g. with > 462 runtime ftplugin/changelog.vim 463 < in your |init.vim|. 464 <Leader>o Switches to the ChangeLog buffer opened for the 465 current directory, or opens it in a new buffer if it 466 exists in the current directory. Then it does the 467 same as the local <Leader>o described above. 468 469 Variables: 470 g:changelog_timeformat Deprecated; use g:changelog_dateformat instead. 471 g:changelog_dateformat The date (and time) format used in ChangeLog entries. 472 The format accepted is the same as for the 473 |strftime()| function. 474 The default is "%Y-%m-%d" which is the standard format 475 for many ChangeLog layouts. 476 g:changelog_username The name and email address of the user. 477 The default is deduced from environment variables and 478 system files. It searches /etc/passwd for the comment 479 part of the current user, which informally contains 480 the real name of the user up to the first separating 481 comma. then it checks the $NAME environment variable 482 and finally runs `whoami` and `hostname` to build an 483 email address. The final form is > 484 Full Name <user@host> 485 < 486 g:changelog_new_date_format 487 The format to use when creating a new date-entry. 488 The following table describes special tokens in the 489 string: 490 %% insert a single '%' character 491 %d insert the date from above 492 %u insert the user from above 493 %p insert result of 494 b:changelog_entry_prefix 495 %c where to position cursor when done 496 The default is "%d %u\n\n\t* %p%c\n\n", which 497 produces something like (| is where cursor will be, 498 unless at the start of the line where it denotes the 499 beginning of the line) > 500 |2003-01-14 Full Name <user@host> 501 | 502 | * prefix| 503 < 504 g:changelog_new_entry_format 505 The format used when creating a new entry. 506 The following table describes special tokens in the 507 string: 508 %p insert result of 509 b:changelog_entry_prefix 510 %c where to position cursor when done 511 The default is "\t*%c", which produces something 512 similar to > 513 | * prefix| 514 < 515 g:changelog_date_entry_search 516 The search pattern to use when searching for a 517 date-entry. 518 The same tokens that can be used for 519 g:changelog_new_date_format can be used here as well. 520 The default is '^\s*%d\_s*%u' which finds lines 521 matching the form > 522 |2003-01-14 Full Name <user@host> 523 < and some similar formats. 524 525 g:changelog_date_end_entry_search 526 The search pattern to use when searching for the end 527 of a date-entry. 528 The same tokens that can be used for 529 g:changelog_new_date_format can be used here as well. 530 The default is '^\s*$' which finds lines that contain 531 only whitespace or are completely empty. 532 533 b:changelog_name *b:changelog_name* 534 Name of the ChangeLog file to look for. 535 The default is 'ChangeLog'. 536 537 b:changelog_path 538 Path of the ChangeLog to use for the current buffer. 539 The default is empty, thus looking for a file named 540 |b:changelog_name| in the same directory as the 541 current buffer. If not found, the parent directory of 542 the current buffer is searched. This continues 543 recursively until a file is found or there are no more 544 parent directories to search. 545 546 b:changelog_entry_prefix 547 Name of a function to call to generate a prefix to a 548 new entry. This function takes no arguments and 549 should return a string containing the prefix. 550 Returning an empty prefix is fine. 551 The default generates the shortest path between the 552 ChangeLog's pathname and the current buffers pathname. 553 In the future, it will also be possible to use other 554 variable contexts for this variable, for example, g:. 555 556 The Changelog entries are inserted where they add the least amount of text. 557 After figuring out the current date and user, the file is searched for an 558 entry beginning with the current date and user and if found adds another item 559 under it. If not found, a new entry and item is prepended to the beginning of 560 the Changelog. 561 562 563 FORTRAN *ft-fortran-plugin* 564 565 Options: 566 'expandtab' is switched on to avoid tabs as required by the Fortran 567 standards unless the user has set fortran_have_tabs in vimrc. 568 'textwidth' is set to 80 for fixed source format whereas it is set to 132 569 for free source format. Setting the 570 fortran_extended_line_length variable increases the width to 571 132 for fixed source format. 572 'formatoptions' is set to break code and comment lines and to preserve long 573 lines. You can format comments with |gq|. 574 For further discussion of fortran_have_tabs and the method used for the 575 detection of source format see |ft-fortran-syntax|. 576 577 578 FREEBASIC *ft-freebasic-plugin* 579 580 This plugin aims to treat the four FreeBASIC dialects, "fb", "qb", "fblite" 581 and "deprecated", as distinct languages. 582 583 The dialect will be set to the first name found in g:freebasic_forcelang, any 584 #lang directive or $lang metacommand in the file being edited, or finally 585 g:freebasic_lang. These global variables conceptually map to the fbc options 586 -forcelang and -lang. If no dialect is explicitly specified "fb" will be 587 used. 588 589 For example, to set the dialect to a default of "fblite" but still allow for 590 any #lang directive overrides, use the following command: > 591 592 let g:freebasic_lang = "fblite" 593 594 595 GDSCRIPT *ft-gdscript-plugin* 596 597 By default the following options are set, based on Godot official docs: > 598 599 setlocal noexpandtab softtabstop=0 shiftwidth=0 600 601 To disable this behavior, set the following variable in your vimrc: > 602 603 let g:gdscript_recommended_style = 0 604 605 606 GIT COMMIT *ft-gitcommit-plugin* 607 608 One command, :DiffGitCached, is provided to show a diff of the current commit 609 in the preview window. It is equivalent to calling "git diff --cached" plus 610 any arguments given to the command. 611 612 GIT REBASE *ft-gitrebase-plugin* 613 614 The gitrebase filetype defines the following buffer-local commands, to help 615 with interactive `git rebase`: > 616 617 :Drop " to discard this commit 618 :Edit " to stop for editing this commit 619 :Fixup " to squash (but discard the message) into the previous one 620 :Pick " to pick this commit (the cursor is on) 621 :Reword " to pick this commit, but change the commit message 622 :Squash " to squash this commit into the previous one 623 624 In addition, the following command can be used to cycle between the different 625 possibilities: > 626 627 :Cycle " to cycle between the previous commands 628 < 629 The `:Cycle` command is also mapped to the CTRL-A and CTRL-X keys. 630 For details, see `git-rebase --help`. 631 632 GLEAM *ft-gleam-plugin* 633 634 By default the following options are set for the recommended gleam style: > 635 636 setlocal expandtab shiftwidth=2 softtabstop=2 637 638 To disable this behavior, set the following variable in your vimrc: > 639 640 let g:gleam_recommended_style = 0 641 642 GO *ft-go-plugin* 643 644 By default the following options are set, based on Golang official docs: > 645 646 setlocal noexpandtab softtabstop=0 shiftwidth=0 647 648 To disable this behavior, set the following variable in your vimrc: > 649 650 let g:go_recommended_style = 0 651 652 653 GPROF *ft-gprof-plugin* 654 655 The gprof filetype plugin defines a mapping <C-]> to jump from a function 656 entry in the gprof flat profile or from a function entry in the call graph 657 to the details of that function in the call graph. 658 659 The mapping can be disabled with: > 660 let g:no_gprof_maps = 1 661 662 663 HARE *ft-hare* 664 665 Since the text for this plugin is rather long it has been put in a separate 666 file: |ft_hare.txt|. 667 668 HTML *ft-html-plugin* 669 670 Tag folding poses a few difficulties. Many elements, e.g. `blockquote`, are 671 always delimited by start and end tags; end tags for some elements, e.g. `p`, 672 can be omitted in certain contexts; void elements, e.g. `hr`, have no end tag. 673 Although the rules for supporting omissible end tags are ad-hoc and involved 674 [0], they apply to elements in scope. Assuming syntactical wellformedness, an 675 end tag can be associated with its nearest matching start tag discoverable in 676 scope [1] and towards the beginning of a file, whereas all unbalanced tags and 677 inlined tags can be disregarded. Having syntax highlighting in effect, tag 678 folding using the |fold-expr| method can be enabled with: > 679 let g:html_expr_folding = 1 680 < 681 By default, tag folding will be redone from scratch after each occurrence of 682 a |TextChanged| or an |InsertLeave| event. Such frequency may not be desired, 683 especially for large files, and this recomputation can be disabled with: > 684 let g:html_expr_folding_without_recomputation = 1 685 doautocmd FileType 686 < 687 To force another recomputation, do: > 688 unlet! b:foldsmap 689 normal zx 690 < 691 [0] https://html.spec.whatwg.org/multipage/syntax.html#optional-tags 692 [1] https://en.wikipedia.org/wiki/Dangling_else 693 694 IDRIS2 *ft-idris2-plugin* 695 696 By default the following options are set: > 697 698 setlocal shiftwidth=2 tabstop=2 expandtab 699 setlocal comments=s1:{-,mb:-,ex:-},:\|\|\|,:-- 700 setlocal commentstring=--\ %s 701 setlocal wildignore+=*.ibc 702 703 To use tabs instead of spaces for indentation, set the following variable 704 in your vimrc: > 705 706 let g:idris2#allow_tabchar = 1 707 708 JAVA *ft-java-plugin* 709 710 Whenever the variable "g:ftplugin_java_source_path" is defined and its value 711 is a filename whose extension is either ".jar" or ".zip", e.g.: > 712 let g:ftplugin_java_source_path = '/path/to/src.jar' 713 let g:ftplugin_java_source_path = '/path/to/src.zip' 714 < 715 and the |zip| plugin has already been sourced, the |gf| command can be used to 716 open the archive and the |n| command can be used to look for the selected type 717 and the <Return> key can be used to load a listed file. 718 719 Note that the effect of using the "gf" command WITHIN a buffer loaded with the 720 Zip plugin depends on the version of the Zip plugin. For the Zip plugin 721 versions that do not support Jar type archives, consider creating symbolic 722 links with the ".zip" extension for each Jar archive of interest and assigning 723 any such file to the variable from now on. 724 725 Otherwise, for the defined variable "g:ftplugin_java_source_path", the local 726 value of the 'path' option will be further modified by prefixing the value of 727 the variable, e.g.: > 728 let g:ftplugin_java_source_path = $JDK_SRC_PATH 729 let &l:path = g:ftplugin_java_source_path .. ',' .. &l:path 730 < 731 and the "gf" command can be used on a fully-qualified type to look for a file 732 in the "path" and to try to load it. 733 734 Remember to manually trigger the |FileType| event from a buffer with a Java 735 file loaded in it each time after assigning a new value to the variable: > 736 doautocmd FileType 737 < 738 Markdown documentation comments may contain common runs of vertical leading 739 whitespace following the comment marks (`///`) for aesthetic reasons; however, 740 some horizontal runs of leading whitespace are significant in Markdown because 741 they denote code blocks etc. For convenience, a 'formatexpr' function is 742 provided for the |gq| operator. As long as neither "g:java_ignore_javadoc" 743 nor "g:java_ignore_markdown" is defined, the reformatting of Markdown comments 744 can be enabled on demand with: > 745 setlocal formatexpr=g:javaformat#RemoveCommonMarkdownWhitespace() 746 < 747 Or for Vim versions less than `7.4.265`, with: > 748 setlocal formatexpr=javaformat#RemoveCommonMarkdownWhitespace() 749 < 750 This function accepts a range of lines, removes a common run of vertical 751 leading whitespace, and rewrites the lines of the range. Depending on the 752 author's layout style and the comment contents, which lines to select for 753 reformatting can vary from the whole comment to only some portion of it. 754 To enable the recognition of Markdown comments each time after removing 755 "g:java_ignore_markdown" or "g:java_ignore_javadoc", remember to manually 756 re-source "javaformat.vim" for Vim versions greater than `8.2.1397`: > 757 runtime autoload/javaformat.vim 758 < 759 LUA *ft-lua-plugin* 760 761 *g:lua_version* *g:lua_subversion* 762 Lua filetype's 'includeexpr' and |ft-lua-syntax| highlighting use the global 763 variables "g:lua_version" and "g:lua_subversion" to determine the version of 764 Lua to use (5.3 is the default) 765 766 For example, to use Lua 5.1, set the variables like this: > 767 768 let g:lua_version = 5 769 let g:lua_subversion = 1 770 < 771 MAIL *ft-mail-plugin* 772 773 Options: 774 'modeline' is switched off to avoid the danger of trojan horses, and to 775 avoid that a Subject line with "Vim:" in it will cause an 776 error message. 777 'textwidth' is set to 72. This is often recommended for e-mail. 778 'formatoptions' is set to break text lines and to repeat the comment leader 779 in new lines, so that a leading ">" for quotes is repeated. 780 You can also format quoted text with |gq|. 781 782 Local mappings: 783 <LocalLeader>q or \MailQuote 784 Quotes the text selected in Visual mode, or from the cursor position 785 to the end of the file in Normal mode. This means "> " is inserted in 786 each line. 787 788 MAN *ft-man-plugin* *:Man* *man.lua* 789 790 View manpages in Nvim. Supports highlighting, completion, locales, and 791 navigation. Also see |find-manpage|. 792 793 man.lua will always attempt to reuse the closest man window (above/left) but 794 otherwise create a split. 795 796 The case sensitivity of completion is controlled by 'fileignorecase'. 797 798 Commands: 799 Man {name} Display the manpage for {name}. 800 Man {sect} {name} Display the manpage for {name} and section {sect}. 801 Man {name}({sect}) Same as above. 802 Man {sect} {name}({sect}) Used during completion to show the real section of 803 when the provided section is a prefix, e.g. 1m vs 1. 804 Man {path} Open the manpage at {path}. Prepend "./" if {path} 805 is relative to the current directory. 806 Man Open the manpage for the <cWORD> (man buffers) 807 or <cword> (non-man buffers) under the cursor. 808 Man! Display the current buffer contents as a manpage. 809 810 |:Man| accepts command modifiers. For example, to use a vertical split: >vim 811 :vertical Man printf 812 To reuse the current window: >vim 813 :hide Man printf 814 815 Local mappings: 816 K or CTRL-] Jump to the manpage for the <cWORD> under the 817 cursor. Takes a count for the section. 818 CTRL-T Jump back to the location that the manpage was 819 opened from. 820 gO Show the manpage outline. |gO| 821 q :quit if invoked as $MANPAGER, otherwise :close. 822 823 Variables: 824 *g:no_man_maps* Do not create mappings in manpage buffers. 825 *g:ft_man_folding_enable* Fold manpages with foldmethod=indent foldnestmax=1. 826 *b:man_default_sects* Comma-separated, ordered list of preferred sections. 827 For example in C one usually wants section 3 or 2: > 828 :let b:man_default_sections = '3,2' 829 *g:man_hardwrap* Hard-wrap to $MANWIDTH or window width if $MANWIDTH is 830 empty or larger than the window width. Enabled by 831 default. Set |FALSE| to enable soft wrapping. 832 833 To use Nvim as a manpager: >bash 834 export MANPAGER='nvim +Man!' 835 836 Note: when running `man` from the shell with Nvim as `$MANPAGER`, `man` will 837 pre-format the manpage using `groff`, and Nvim will display the manual page as 838 it was received from stdin (it can't "undo" the hard-wrap caused by 839 man/groff). To prevent man/groff from hard-wrapping the manpage, you can set 840 `$MANWIDTH=999` in your environment. 841 842 To disable bold highlighting: >vim 843 :highlight link manBold Normal 844 845 Troubleshooting: 846 847 If you see an error like: > 848 fuse: mount failed: Permission denied 849 this may be caused by AppArmor sandboxing. To fix this, add a local override 850 in e.g. `/etc/apparmor.d/local/usr.bin.man`: >bash 851 mount fstype=fuse.nvim options=(ro, nosuid, nodev) -> /tmp/**, 852 /usr/bin/fusermount Ux, 853 See also https://github.com/neovim/neovim/issues/30268 . 854 855 MARKDOWN *ft-markdown-plugin* 856 857 To enable folding use this: > 858 let g:markdown_folding = 1 859 860 'expandtab' will be set by default. If you do not want that use this: > 861 let g:markdown_recommended_style = 0 862 863 864 ORG *ft-org-plugin* 865 866 To enable folding use this: > 867 let g:org_folding = 1 868 < 869 870 PDF *ft-pdf-plugin* 871 872 Two maps, <C-]> and <C-T>, are provided to simulate a tag stack for navigating 873 the PDF. The following are treated as tags: 874 875 - The byte offset after "startxref" to the xref table 876 - The byte offset after the /Prev key in the trailer to an earlier xref table 877 - A line of the form "0123456789 00000 n" in the xref table 878 - An object reference like "1 0 R" anywhere in the PDF 879 880 These maps can be disabled with > 881 :let g:no_pdf_maps = 1 882 883 PLSQL *ft-plsql-plugin* 884 885 To enable syntax folding in PL/SQL filetypes, set the following variable: > 886 887 :let g:plsql_fold = 1 888 < 889 890 PYTHON *ft-python-plugin* *PEP8* 891 892 By default the following options are set, in accordance with PEP8: > 893 894 setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8 895 896 To disable this behavior, set the following variable in your vimrc: > 897 898 let g:python_recommended_style = 0 899 900 QUERY *ft-query-plugin* 901 902 903 Linting of treesitter queries for installed parsers using 904 |vim.treesitter.query.lint()| is disabled by default. To enable 905 linting when opening and writing buffers, add >lua 906 907 vim.g.query_lint_on = { 'BufEnter', 'BufWrite' } 908 < 909 to your config. To update diagnostics when editing, use >lua 910 911 vim.g.query_lint_on = { 'InsertLeave', 'TextChanged' } 912 < 913 For a dedicated language server, see https://github.com/ribru17/ts_query_ls. 914 915 QF QUICKFIX *qf.vim* *ft-qf-plugin* 916 917 The "qf" filetype is used for the quickfix window, see |quickfix-window|. 918 919 The quickfix filetype plugin includes configuration for displaying the command 920 that produced the quickfix list in the |status-line|. To disable this setting, 921 configure as follows: > 922 :let g:qf_disable_statusline = 1 923 924 925 R MARKDOWN *ft-rmd-plugin* 926 927 By default ftplugin/html.vim is not sourced. If you want it sourced, add to 928 your |vimrc|: > 929 let rmd_include_html = 1 930 931 The 'formatexpr' option is set dynamically with different values for R code 932 and for Markdown code. If you prefer that 'formatexpr' is not set, add to 933 your |vimrc|: > 934 let rmd_dynamic_comments = 0 935 936 937 R RESTRUCTURED TEXT *ft-rrst-plugin* 938 939 The 'formatexpr' option is set dynamically with different values for R code 940 and for ReStructured text. If you prefer that 'formatexpr' is not set, add to 941 your |vimrc|: > 942 let rrst_dynamic_comments = 0 943 944 945 RESTRUCTUREDTEXT *ft-rst-plugin* 946 947 The following formatting setting are optionally available: > 948 setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8 949 950 To enable this behavior, set the following variable in your vimrc: > 951 let g:rst_style = 1 952 953 954 RNOWEB *ft-rnoweb-plugin* 955 956 The 'formatexpr' option is set dynamically with different values for R code 957 and for LaTeX code. If you prefer that 'formatexpr' is not set, add to your 958 |vimrc|: > 959 let rnw_dynamic_comments = 0 960 961 962 RPM SPEC *ft-spec-plugin* 963 964 Since the text for this plugin is rather long it has been put in a separate 965 file: |pi_spec.txt|. 966 967 968 SHADA *ft-shada* 969 970 Allows editing binary |shada-file|s in a nice way. Opened binary files are 971 displayed in the following format: > 972 973 Type with timestamp YYYY-mm-ddTHH:MM:SS: 974 % Key__ Description___ Value 975 + fooba foo bar baz fo {msgpack-value} 976 + abcde abc def ghi jk {msgpack-value} 977 Other type with timestamp YYYY-mm-ddTHH:MM:SS: 978 @ Description__ Value 979 - foo bar baz t {msgpack-value} 980 # Expected more elements in list 981 Some other type with timestamp YYYY-mm-ddTHH:MM:SS: 982 # Unexpected type: type instead of map 983 = {msgpack-value} 984 985 Filetype plugin defines all |Cmd-event|s. Defined |SourceCmd| event makes 986 "source file.shada" be equivalent to "|:rshada| file.shada". |BufWriteCmd|, 987 |FileWriteCmd| and |FileAppendCmd| events are affected by the following 988 settings: 989 990 *g:shada#keep_old_header* Boolean, if set to false all header entries 991 are ignored when writing. Defaults to 1. 992 *g:shada#add_own_header* Boolean, if set to true first written entry 993 will always be header entry with two values in 994 a map with attached data: |v:version| attached 995 to "version" key and "shada.vim" attached to 996 "generator" key. Defaults to 1. 997 998 Format description: 999 1000 1. `#` starts a comment. Lines starting with space characters and then `#` 1001 are ignored. Plugin may only add comment lines to indicate some errors in 1002 ShaDa format. Lines containing no non-whitespace characters are also 1003 ignored. 1004 2. Each entry starts with line that has format "{type} with timestamp 1005 {timestamp}:". {timestamp} is |strftime()|-formatted string representing 1006 actual Unix timestamp value. First strftime() argument is equal to 1007 `%Y-%m-%dT%H:%M:%S`. When writing this timestamp is parsed using 1008 |msgpack#strptime()|, with caching (it remembers which timestamp produced 1009 particular strftime() output and uses this value if you did not change 1010 timestamp). {type} is one of 1011 1 - Header 1012 2 - Search pattern 1013 3 - Replacement string 1014 4 - History entry 1015 5 - Register 1016 6 - Variable 1017 7 - Global mark 1018 8 - Jump 1019 9 - Buffer list 1020 10 - Local mark 1021 11 - Change 1022 * - Unknown (0x{type-hex}) 1023 1024 Each type may be represented using Unknown entry: "Jump with timestamp ..." 1025 is the same as "Unknown (0x8) with timestamp ....". 1026 3. After header there is one of the following lines: 1027 1. " % Key__ Description__ Value": map header. After mapping header 1028 follows a table which may contain comments and lines consisting of 1029 " +", key, description and |{msgpack-value}|. Key is separated by at 1030 least two spaces with description, description is separated by at least 1031 two spaces with the value. Each key in the map must be at most as wide 1032 as "Key__" header: "Key" allows at most 3-byte keys, "Key__" allows at 1033 most 5-byte keys. If keys actually occupy less bytes then the rest is 1034 filled with spaces. Keys cannot be empty, end with spaces, contain two 1035 consequent spaces inside of them or contain multibyte characters (use 1036 "=" format if you need this). Descriptions have the same restrictions 1037 on width and contents, except that empty descriptions are allowed. 1038 Description column may be omitted. 1039 1040 When writing description is ignored. Keys with values |msgpack#equal| 1041 to default ones are ignored. Order of keys is preserved. All keys are 1042 treated as strings (not binary strings). 1043 1044 Note: specifically for buffer list entries it is allowed to have more 1045 then one map header. Each map header starts a new map entry inside 1046 buffer list because ShaDa buffer list entry is an array of maps. I.e. > 1047 1048 Buffer list with timestamp 1970-01-01T00:00:00: 1049 % Key Description Value 1050 + f file name "/foo" 1051 + l line number 1 1052 + c column 10 1053 < 1054 is equivalent to > 1055 1056 Buffer list with timestamp 1970-01-01T00:00:00: 1057 = [{="f": "/foo", ="c": 10}] 1058 < 1059 and > 1060 1061 Buffer list with timestamp 1970-01-01T00:00:00: 1062 % Key Description Value 1063 + f file name "/foo" 1064 1065 % Key Description Value 1066 + f file name "/bar" 1067 < 1068 is equivalent to > 1069 1070 Buffer list with timestamp 1970-01-01T00:00:00: 1071 = [{="f": "/foo"}, {="f": "/bar"}] 1072 < 1073 Note 2: specifically for register entries special syntax for arrays was 1074 designed: > 1075 1076 Register with timestamp 1970-01-01T00:00:00: 1077 % Key Description Value 1078 + rc contents @ 1079 | - "line1" 1080 | - "line2" 1081 < 1082 This is equivalent to > 1083 1084 Register with timestamp 1970-01-01T00:00:00: 1085 % Key Description Value 1086 + rc contents ["line1", "line2"] 1087 < 1088 Such syntax is automatically used if array representation appears to be 1089 too lengthy. 1090 2. " @ Description__ Value": array header. Same as map, but key is 1091 omitted and description cannot be omitted. Array entries start with 1092 " -". Example: > 1093 1094 History entry with timestamp 1970-01-01T00:00:00: 1095 @ Description_ Value 1096 - history type SEARCH 1097 - contents "foo" 1098 - separator '/' 1099 < 1100 is equivalent to > 1101 1102 History entry with timestamp 1970-01-01T00:00:00: 1103 = [SEARCH, "foo", '/'] 1104 < 1105 Note: special array syntax for register entries is not recognized here. 1106 3. " = {msgpack-value}": raw values. |{msgpack-value}| in this case may 1107 have absolutely any type. Special array syntax for register entries is 1108 not recognized here as well. 1109 1110 1111 RUST *ft-rust* 1112 1113 Since the text for this plugin is rather long it has been put in a separate 1114 file: |ft_rust.txt|. 1115 1116 1117 SQL *ft-sql* 1118 1119 Since the text for this plugin is rather long it has been put in a separate 1120 file: |ft_sql.txt|. 1121 1122 1123 TEX *ft-tex-plugin* *g:tex_flavor* 1124 1125 If the first line of a `*.tex` file has the form > 1126 %&<format> 1127 then this determined the file type: plaintex (for plain TeX), context (for 1128 ConTeXt), or tex (for LaTeX). Otherwise, the file is searched for keywords to 1129 choose context or tex. If no keywords are found, it defaults to plaintex. 1130 You can change the default by defining the variable g:tex_flavor to the format 1131 (not the file type) you use most. Use one of these: > 1132 let g:tex_flavor = "plain" 1133 let g:tex_flavor = "context" 1134 let g:tex_flavor = "latex" 1135 Currently no other formats are recognized. 1136 1137 TYPST *ft-typst-plugin* 1138 1139 *g:typst_conceal* 1140 When |TRUE| the Typst filetype plugin will set the 'conceallevel' option to 2. 1141 1142 *g:typst_folding* 1143 When |TRUE| the Typst filetype plugin will fold headings. (default: |FALSE|) 1144 1145 To enable: > 1146 let g:typst_folding = 1 1147 < 1148 *g:typst_foldnested* 1149 When |TRUE| the Typst filetype plugin will fold nested heading under their 1150 parents. (default: |TRUE|) 1151 1152 To disable: > 1153 let g:typst_foldnested = 0 1154 < 1155 VIM *ft-vim-plugin* 1156 1157 The Vim filetype plugin defines mappings to move to the start and end of 1158 functions with [[ and ]]. Move around comments with ]" and [". 1159 1160 The mappings can be disabled with: > 1161 let g:no_vim_maps = 1 1162 1163 YAML *ft-yaml-plugin* 1164 By default, the YAML filetype plugin enables the following options: > 1165 setlocal shiftwidth=2 softtabstop=2 1166 1167 To disable this, set the following variable: > 1168 let g:yaml_recommended_style = 0 1169 1170 1171 ZIG *ft-zig-plugin* 1172 1173 *g:zig_recommended_style* 1174 By default the following indentation options are set, in accordance with Zig's 1175 recommended style (https://ziglang.org/documentation/master/): > 1176 1177 setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8 1178 < 1179 To disable this behavior, set |g:zig_recommended_style| to 0: > 1180 1181 let g:zig_recommended_style = 0 1182 < 1183 *g:zig_std_dir* 1184 The path to the Zig standard library. The Zig |ftplugin| reads |g:zig_std_dir| 1185 and appends it to the 'path' for Zig files. Where the Zig standard library 1186 is located is system and installation method dependent. 1187 1188 One can automatically set |g:zig_std_dir| using `zig env`: > 1189 1190 let g:zig_std_dir = json_decode(system('zig env'))['std_dir'] 1191 < 1192 This can, for example, be put in a FileType |:autocmd| or user |ftplugin| to 1193 only load when a Zig file is opened. 1194 1195 1196 ZIMBU *ft-zimbu-plugin* 1197 1198 The Zimbu filetype plugin defines mappings to move to the start and end of 1199 functions with [[ and ]]. 1200 1201 The mappings can be disabled with: > 1202 let g:no_zimbu_maps = 1 1203 < 1204 1205 1206 vim:tw=78:ts=8:noet:ft=help:norl: