Mercurial > vim
annotate runtime/doc/filetype.txt @ 9967:45098d7f72b6 v7.4.2257
commit https://github.com/vim/vim/commit/9f28953f0c1e3d9fffd49af76503f54eaa279acb
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 26 16:39:03 2016 +0200
patch 7.4.2257
Problem: Coverity complains about not checking for NULL.
Solution: Check for out of memory.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 26 Aug 2016 16:45:07 +0200 |
parents | 33c1b85d408c |
children | a5ef9968638c |
rev | line source |
---|---|
9344
33c1b85d408c
commit https://github.com/vim/vim/commit/802a0d902fca423acb15f835d7b09183883d79a0
Christian Brabandt <cb@256bit.org>
parents:
9116
diff
changeset
|
1 *filetype.txt* For Vim version 7.4. Last change: 2016 Jun 20 |
7 | 2 |
3 | |
4 VIM REFERENCE MANUAL by Bram Moolenaar | |
5 | |
6 | |
7 Filetypes *filetype* *file-type* | |
8 | |
9 1. Filetypes |filetypes| | |
10 2. Filetype plugin |filetype-plugins| | |
11 3. Docs for the default filetype plugins. |ftplugin-docs| | |
12 | |
13 Also see |autocmd.txt|. | |
14 | |
15 {Vi does not have any of these commands} | |
16 | |
17 ============================================================================== | |
18 1. Filetypes *filetypes* *file-types* | |
19 | |
20 Vim can detect the type of file that is edited. This is done by checking the | |
21 file name and sometimes by inspecting the contents of the file for specific | |
22 text. | |
23 | |
24 *:filetype* *:filet* | |
25 To enable file type detection, use this command in your vimrc: > | |
26 :filetype on | |
27 Each time a new or existing file is edited, Vim will try to recognize the type | |
28 of the file and set the 'filetype' option. This will trigger the FileType | |
29 event, which can be used to set the syntax highlighting, set options, etc. | |
30 | |
31 NOTE: Filetypes and 'compatible' don't work together well, since being Vi | |
32 compatible means options are global. Resetting 'compatible' is recommended, | |
33 if you didn't do that already. | |
34 | |
35 Detail: The ":filetype on" command will load one of these files: | |
36 Amiga $VIMRUNTIME/filetype.vim | |
37 Mac $VIMRUNTIME:filetype.vim | |
38 MS-DOS $VIMRUNTIME\filetype.vim | |
39 RiscOS Vim:Filetype | |
40 Unix $VIMRUNTIME/filetype.vim | |
41 VMS $VIMRUNTIME/filetype.vim | |
42 This file is a Vim script that defines autocommands for the | |
43 BufNewFile and BufRead events. If the file type is not found by the | |
44 name, the file $VIMRUNTIME/scripts.vim is used to detect it from the | |
45 contents of the file. | |
1125 | 46 When the GUI is running or will start soon, the menu.vim script is |
47 also sourced. See |'go-M'| about avoiding that. | |
7 | 48 |
501 | 49 To add your own file types, see |new-filetype| below. To search for help on a |
50 filetype prepend "ft-" and optionally append "-syntax", "-indent" or | |
51 "-plugin". For example: > | |
52 :help ft-vim-indent | |
53 :help ft-vim-syntax | |
54 :help ft-man-plugin | |
7 | 55 |
56 If the file type is not detected automatically, or it finds the wrong type, | |
57 you can either set the 'filetype' option manually, or add a modeline to your | |
1668 | 58 file. Example, for an IDL file use the command: > |
7 | 59 :set filetype=idl |
501 | 60 |
61 or add this |modeline| to the file: | |
62 /* vim: set filetype=idl : */ ~ | |
63 | |
7 | 64 *:filetype-plugin-on* |
65 You can enable loading the plugin files for specific file types with: > | |
66 :filetype plugin on | |
67 If filetype detection was not switched on yet, it will be as well. | |
68 This actually loads the file "ftplugin.vim" in 'runtimepath'. | |
69 The result is that when a file is edited its plugin file is loaded (if there | |
70 is one for the detected filetype). |filetype-plugin| | |
71 | |
72 *:filetype-plugin-off* | |
73 You can disable it again with: > | |
74 :filetype plugin off | |
75 The filetype detection is not switched off then. But if you do switch off | |
76 filetype detection, the plugins will not be loaded either. | |
77 This actually loads the file "ftplugof.vim" in 'runtimepath'. | |
78 | |
79 *:filetype-indent-on* | |
80 You can enable loading the indent file for specific file types with: > | |
81 :filetype indent on | |
82 If filetype detection was not switched on yet, it will be as well. | |
83 This actually loads the file "indent.vim" in 'runtimepath'. | |
84 The result is that when a file is edited its indent file is loaded (if there | |
85 is one for the detected filetype). |indent-expression| | |
86 | |
87 *:filetype-indent-off* | |
88 You can disable it again with: > | |
89 :filetype indent off | |
90 The filetype detection is not switched off then. But if you do switch off | |
91 filetype detection, the indent files will not be loaded either. | |
92 This actually loads the file "indoff.vim" in 'runtimepath'. | |
22 | 93 This disables auto-indenting for files you will open. It will keep working in |
94 already opened files. Reset 'autoindent', 'cindent', 'smartindent' and/or | |
95 'indentexpr' to disable indenting in an opened file. | |
7 | 96 |
97 *:filetype-off* | |
98 To disable file type detection, use this command: > | |
99 :filetype off | |
100 This will keep the flags for "plugin" and "indent", but since no file types | |
101 are being detected, they won't work until the next ":filetype on". | |
102 | |
103 | |
104 Overview: *:filetype-overview* | |
105 | |
106 command detection plugin indent ~ | |
107 :filetype on on unchanged unchanged | |
108 :filetype off off unchanged unchanged | |
109 :filetype plugin on on on unchanged | |
110 :filetype plugin off unchanged off unchanged | |
111 :filetype indent on on unchanged on | |
112 :filetype indent off unchanged unchanged off | |
113 :filetype plugin indent on on on on | |
114 :filetype plugin indent off unchanged off off | |
115 | |
116 To see the current status, type: > | |
117 :filetype | |
118 The output looks something like this: > | |
119 filetype detection:ON plugin:ON indent:OFF | |
120 | |
121 The file types are also used for syntax highlighting. If the ":syntax on" | |
122 command is used, the file type detection is installed too. There is no need | |
123 to do ":filetype on" after ":syntax on". | |
124 | |
1624 | 125 To disable one of the file types, add a line in your filetype file, see |
7 | 126 |remove-filetype|. |
127 | |
128 *filetype-detect* | |
129 To detect the file type again: > | |
130 :filetype detect | |
131 Use this if you started with an empty file and typed text that makes it | |
132 possible to detect the file type. For example, when you entered this in a | |
133 shell script: "#!/bin/csh". | |
134 When filetype detection was off, it will be enabled first, like the "on" | |
135 argument was used. | |
136 | |
137 *filetype-overrule* | |
138 When the same extension is used for two filetypes, Vim tries to guess what | |
139 kind of file it is. This doesn't always work. A number of global variables | |
140 can be used to overrule the filetype used for certain extensions: | |
141 | |
142 file name variable ~ | |
501 | 143 *.asa g:filetype_asa |ft-aspvbs-syntax| |ft-aspperl-syntax| |
144 *.asp g:filetype_asp |ft-aspvbs-syntax| |ft-aspperl-syntax| | |
145 *.asm g:asmsyntax |ft-asm-syntax| | |
7 | 146 *.prg g:filetype_prg |
147 *.pl g:filetype_pl | |
148 *.inc g:filetype_inc | |
501 | 149 *.w g:filetype_w |ft-cweb-syntax| |
150 *.i g:filetype_i |ft-progress-syntax| | |
151 *.p g:filetype_p |ft-pascal-syntax| | |
152 *.sh g:bash_is_sh |ft-sh-syntax| | |
798 | 153 *.tex g:tex_flavor |ft-tex-plugin| |
7 | 154 |
155 *filetype-ignore* | |
156 To avoid that certain files are being inspected, the g:ft_ignore_pat variable | |
157 is used. The default value is set like this: > | |
158 :let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$' | |
159 This means that the contents of compressed files are not inspected. | |
160 | |
161 *new-filetype* | |
22 | 162 If a file type that you want to use is not detected yet, there are four ways |
10 | 163 to add it. In any way, it's better not to modify the $VIMRUNTIME/filetype.vim |
7 | 164 file. It will be overwritten when installing a new version of Vim. |
165 | |
166 A. If you want to overrule all default file type checks. | |
167 This works by writing one file for each filetype. The disadvantage is that | |
168 means there can be many files. The advantage is that you can simply drop | |
169 this file in the right directory to make it work. | |
22 | 170 *ftdetect* |
7 | 171 1. Create your user runtime directory. You would normally use the first |
172 item of the 'runtimepath' option. Then create the directory "ftdetect" | |
173 inside it. Example for Unix: > | |
174 :!mkdir ~/.vim | |
175 :!mkdir ~/.vim/ftdetect | |
176 < | |
177 2. Create a file that contains an autocommand to detect the file type. | |
178 Example: > | |
179 au BufRead,BufNewFile *.mine set filetype=mine | |
180 < Note that there is no "augroup" command, this has already been done | |
181 when sourcing your file. You could also use the pattern "*" and then | |
182 check the contents of the file to recognize it. | |
183 Write this file as "mine.vim" in the "ftdetect" directory in your user | |
184 runtime directory. For example, for Unix: > | |
185 :w ~/.vim/ftdetect/mine.vim | |
186 | |
187 < 3. To use the new filetype detection you must restart Vim. | |
188 | |
189 The files in the "ftdetect" directory are used after all the default | |
530 | 190 checks, thus they can overrule a previously detected file type. But you |
191 can also use |:setfiletype| to keep a previously detected filetype. | |
7 | 192 |
193 B. If you want to detect your file after the default file type checks. | |
194 | |
195 This works like A above, but instead of setting 'filetype' unconditionally | |
196 use ":setfiletype". This will only set 'filetype' if no file type was | |
197 detected yet. Example: > | |
198 au BufRead,BufNewFile *.txt setfiletype text | |
199 < | |
200 You can also use the already detected file type in your command. For | |
201 example, to use the file type "mypascal" when "pascal" has been detected: > | |
202 au BufRead,BufNewFile * if &ft == 'pascal' | set ft=mypascal | |
203 | endif | |
204 | |
205 C. If your file type can be detected by the file name. | |
206 1. Create your user runtime directory. You would normally use the first | |
207 item of the 'runtimepath' option. Example for Unix: > | |
208 :!mkdir ~/.vim | |
209 < | |
210 2. Create a file that contains autocommands to detect the file type. | |
211 Example: > | |
212 " my filetype file | |
213 if exists("did_load_filetypes") | |
214 finish | |
215 endif | |
216 augroup filetypedetect | |
217 au! BufRead,BufNewFile *.mine setfiletype mine | |
218 au! BufRead,BufNewFile *.xyz setfiletype drawing | |
219 augroup END | |
220 < Write this file as "filetype.vim" in your user runtime directory. For | |
221 example, for Unix: > | |
222 :w ~/.vim/filetype.vim | |
223 | |
224 < 3. To use the new filetype detection you must restart Vim. | |
225 | |
226 Your filetype.vim will be sourced before the default FileType autocommands | |
227 have been installed. Your autocommands will match first, and the | |
228 ":setfiletype" command will make sure that no other autocommands will set | |
229 'filetype' after this. | |
230 *new-filetype-scripts* | |
231 D. If your filetype can only be detected by inspecting the contents of the | |
232 file. | |
233 | |
234 1. Create your user runtime directory. You would normally use the first | |
235 item of the 'runtimepath' option. Example for Unix: > | |
236 :!mkdir ~/.vim | |
237 < | |
238 2. Create a vim script file for doing this. Example: > | |
239 if did_filetype() " filetype already set.. | |
240 finish " ..don't do these checks | |
241 endif | |
242 if getline(1) =~ '^#!.*\<mine\>' | |
243 setfiletype mine | |
244 elseif getline(1) =~? '\<drawing\>' | |
245 setfiletype drawing | |
246 endif | |
247 < See $VIMRUNTIME/scripts.vim for more examples. | |
248 Write this file as "scripts.vim" in your user runtime directory. For | |
249 example, for Unix: > | |
250 :w ~/.vim/scripts.vim | |
251 < | |
252 3. The detection will work right away, no need to restart Vim. | |
253 | |
254 Your scripts.vim is loaded before the default checks for file types, which | |
255 means that your rules override the default rules in | |
256 $VIMRUNTIME/scripts.vim. | |
257 | |
258 *remove-filetype* | |
259 If a file type is detected that is wrong for you, install a filetype.vim or | |
260 scripts.vim to catch it (see above). You can set 'filetype' to a non-existing | |
261 name to avoid that it will be set later anyway: > | |
262 :set filetype=ignored | |
263 | |
264 If you are setting up a system with many users, and you don't want each user | |
265 to add/remove the same filetypes, consider writing the filetype.vim and | |
266 scripts.vim files in a runtime directory that is used for everybody. Check | |
267 the 'runtimepath' for a directory to use. If there isn't one, set | |
268 'runtimepath' in the |system-vimrc|. Be careful to keep the default | |
269 directories! | |
270 | |
271 | |
272 *autocmd-osfiletypes* | |
2908 | 273 NOTE: this code is currently disabled, as the RISC OS implementation was |
274 removed. In the future this will use the 'filetype' option. | |
275 | |
7 | 276 On operating systems which support storing a file type with the file, you can |
277 specify that an autocommand should only be executed if the file is of a | |
278 certain type. | |
279 | |
280 The actual type checking depends on which platform you are running Vim | |
281 on; see your system's documentation for details. | |
282 | |
283 To use osfiletype checking in an autocommand you should put a list of types to | |
284 match in angle brackets in place of a pattern, like this: > | |
285 | |
286 :au BufRead *.html,<&faf;HTML> runtime! syntax/html.vim | |
287 | |
288 This will match: | |
289 | |
1668 | 290 - Any file whose name ends in ".html" |
291 - Any file whose type is "&faf" or "HTML", where the meaning of these types | |
7 | 292 depends on which version of Vim you are using. |
293 Unknown types are considered NOT to match. | |
294 | |
295 You can also specify a type and a pattern at the same time (in which case they | |
296 must both match): > | |
297 | |
298 :au BufRead <&fff>diff* | |
299 | |
1668 | 300 This will match files of type "&fff" whose names start with "diff". |
7 | 301 |
302 | |
303 *plugin-details* | |
304 The "plugin" directory can be in any of the directories in the 'runtimepath' | |
305 option. All of these directories will be searched for plugins and they are | |
306 all loaded. For example, if this command: > | |
307 | |
308 set runtimepath | |
309 | |
1125 | 310 produces this output: |
7 | 311 |
1125 | 312 runtimepath=/etc/vim,~/.vim,/usr/local/share/vim/vim60 ~ |
7 | 313 |
1125 | 314 then Vim will load all plugins in these directories and below: |
7 | 315 |
1125 | 316 /etc/vim/plugin/ ~ |
317 ~/.vim/plugin/ ~ | |
318 /usr/local/share/vim/vim60/plugin/ ~ | |
7 | 319 |
320 Note that the last one is the value of $VIMRUNTIME which has been expanded. | |
321 | |
322 What if it looks like your plugin is not being loaded? You can find out what | |
323 happens when Vim starts up by using the |-V| argument: > | |
1125 | 324 |
325 vim -V2 | |
326 | |
7 | 327 You will see a lot of messages, in between them is a remark about loading the |
1125 | 328 plugins. It starts with: |
329 | |
330 Searching for "plugin/**/*.vim" in ~ | |
331 | |
7 | 332 There you can see where Vim looks for your plugin scripts. |
333 | |
334 ============================================================================== | |
335 2. Filetype plugin *filetype-plugins* | |
336 | |
337 When loading filetype plugins has been enabled |:filetype-plugin-on|, options | |
338 will be set and mappings defined. These are all local to the buffer, they | |
339 will not be used for other files. | |
340 | |
341 Defining mappings for a filetype may get in the way of the mappings you | |
342 define yourself. There are a few ways to avoid this: | |
343 1. Set the "maplocalleader" variable to the key sequence you want the mappings | |
344 to start with. Example: > | |
345 :let maplocalleader = "," | |
346 < All mappings will then start with a comma instead of the default, which | |
347 is a backslash. Also see |<LocalLeader>|. | |
348 | |
349 2. Define your own mapping. Example: > | |
350 :map ,p <Plug>MailQuote | |
351 < You need to check the description of the plugin file below for the | |
352 functionality it offers and the string to map to. | |
353 You need to define your own mapping before the plugin is loaded (before | |
354 editing a file of that type). The plugin will then skip installing the | |
355 default mapping. | |
356 | |
357 3. Disable defining mappings for a specific filetype by setting a variable, | |
358 which contains the name of the filetype. For the "mail" filetype this | |
359 would be: > | |
360 :let no_mail_maps = 1 | |
361 | |
362 4. Disable defining mappings for all filetypes by setting a variable: > | |
363 :let no_plugin_maps = 1 | |
364 < | |
365 | |
366 *ftplugin-overrule* | |
367 If a global filetype plugin does not do exactly what you want, there are three | |
368 ways to change this: | |
369 | |
370 1. Add a few settings. | |
371 You must create a new filetype plugin in a directory early in | |
372 'runtimepath'. For Unix, for example you could use this file: > | |
373 vim ~/.vim/ftplugin/fortran.vim | |
374 < You can set those settings and mappings that you would like to add. Note | |
375 that the global plugin will be loaded after this, it may overrule the | |
376 settings that you do here. If this is the case, you need to use one of the | |
377 following two methods. | |
378 | |
379 2. Make a copy of the plugin and change it. | |
380 You must put the copy in a directory early in 'runtimepath'. For Unix, for | |
381 example, you could do this: > | |
382 cp $VIMRUNTIME/ftplugin/fortran.vim ~/.vim/ftplugin/fortran.vim | |
383 < Then you can edit the copied file to your liking. Since the b:did_ftplugin | |
384 variable will be set, the global plugin will not be loaded. | |
385 A disadvantage of this method is that when the distributed plugin gets | |
386 improved, you will have to copy and modify it again. | |
387 | |
388 3. Overrule the settings after loading the global plugin. | |
389 You must create a new filetype plugin in a directory from the end of | |
390 'runtimepath'. For Unix, for example, you could use this file: > | |
391 vim ~/.vim/after/ftplugin/fortran.vim | |
392 < In this file you can change just those settings that you want to change. | |
393 | |
394 ============================================================================== | |
395 3. Docs for the default filetype plugins. *ftplugin-docs* | |
396 | |
397 | |
501 | 398 CHANGELOG *ft-changelog-plugin* |
7 | 399 |
237 | 400 Allows for easy entrance of Changelog entries in Changelog files. There are |
7 | 401 some commands, mappings, and variables worth exploring: |
402 | |
403 Options: | |
404 'comments' is made empty to not mess up formatting. | |
405 'textwidth' is set to 78, which is standard. | |
406 'formatoptions' the 't' flag is added to wrap when inserting text. | |
407 | |
408 Commands: | |
409 NewChangelogEntry Adds a new Changelog entry in an intelligent fashion | |
410 (see below). | |
411 | |
412 Local mappings: | |
413 <Leader>o Starts a new Changelog entry in an equally intelligent | |
414 fashion (see below). | |
415 | |
416 Global mappings: | |
417 NOTE: The global mappings are accessed by sourcing the | |
418 ftplugin/changelog.vim file first, e.g. with > | |
497 | 419 runtime ftplugin/changelog.vim |
7 | 420 < in your |.vimrc|. |
421 <Leader>o Switches to the ChangeLog buffer opened for the | |
422 current directory, or opens it in a new buffer if it | |
423 exists in the current directory. Then it does the | |
424 same as the local <Leader>o described above. | |
425 | |
426 Variables: | |
1226 | 427 g:changelog_timeformat Deprecated; use g:changelog_dateformat instead. |
428 g:changelog_dateformat The date (and time) format used in ChangeLog entries. | |
7 | 429 The format accepted is the same as for the |
430 |strftime()| function. | |
431 The default is "%Y-%m-%d" which is the standard format | |
432 for many ChangeLog layouts. | |
433 g:changelog_username The name and email address of the user. | |
434 The default is deduced from environment variables and | |
435 system files. It searches /etc/passwd for the comment | |
436 part of the current user, which informally contains | |
437 the real name of the user up to the first separating | |
438 comma. then it checks the $NAME environment variable | |
439 and finally runs `whoami` and `hostname` to build an | |
440 email address. The final form is > | |
441 Full Name <user@host> | |
442 < | |
443 g:changelog_new_date_format | |
444 The format to use when creating a new date-entry. | |
445 The following table describes special tokens in the | |
446 string: | |
447 %% insert a single '%' character | |
448 %d insert the date from above | |
449 %u insert the user from above | |
5568 | 450 %p insert result of b:changelog_entry_prefix |
7 | 451 %c where to position cursor when done |
5568 | 452 The default is "%d %u\n\n\t* %p%c\n\n", which produces |
7 | 453 something like (| is where cursor will be, unless at |
454 the start of the line where it denotes the beginning | |
455 of the line) > | |
456 |2003-01-14 Full Name <user@host> | |
457 | | |
5568 | 458 | * prefix| |
7 | 459 < |
460 g:changelog_new_entry_format | |
461 The format used when creating a new entry. | |
462 The following table describes special tokens in the | |
463 string: | |
5568 | 464 %p insert result of b:changelog_entry_prefix |
7 | 465 %c where to position cursor when done |
466 The default is "\t*%c", which produces something | |
467 similar to > | |
5568 | 468 | * prefix| |
7 | 469 < |
470 g:changelog_date_entry_search | |
471 The search pattern to use when searching for a | |
472 date-entry. | |
473 The same tokens that can be used for | |
474 g:changelog_new_date_format can be used here as well. | |
475 The default is '^\s*%d\_s*%u' which finds lines | |
476 matching the form > | |
477 |2003-01-14 Full Name <user@host> | |
478 < and some similar formats. | |
479 | |
1226 | 480 g:changelog_date_end_entry_search |
481 The search pattern to use when searching for the end | |
482 of a date-entry. | |
483 The same tokens that can be used for | |
484 g:changelog_new_date_format can be used here as well. | |
485 The default is '^\s*$' which finds lines that contain | |
486 only whitespace or are completely empty. | |
487 | |
1698 | 488 b:changelog_name *b:changelog_name* |
489 Name of the ChangeLog file to look for. | |
490 The default is 'ChangeLog'. | |
491 | |
492 b:changelog_path | |
493 Path of the ChangeLog to use for the current buffer. | |
494 The default is empty, thus looking for a file named | |
495 |b:changelog_name| in the same directory as the | |
496 current buffer. If not found, the parent directory of | |
497 the current buffer is searched. This continues | |
498 recursively until a file is found or there are no more | |
499 parent directories to search. | |
500 | |
501 b:changelog_entry_prefix | |
502 Name of a function to call to generate a prefix to a | |
503 new entry. This function takes no arguments and | |
504 should return a string containing the prefix. | |
505 Returning an empty prefix is fine. | |
506 The default generates the shortest path between the | |
507 ChangeLog's pathname and the current buffers pathname. | |
508 In the future, it will also be possible to use other | |
509 variable contexts for this variable, for example, g:. | |
510 | |
7 | 511 The Changelog entries are inserted where they add the least amount of text. |
512 After figuring out the current date and user, the file is searched for an | |
513 entry beginning with the current date and user and if found adds another item | |
237 | 514 under it. If not found, a new entry and item is prepended to the beginning of |
7 | 515 the Changelog. |
516 | |
517 | |
501 | 518 FORTRAN *ft-fortran-plugin* |
7 | 519 |
520 Options: | |
521 'expandtab' is switched on to avoid tabs as required by the Fortran | |
522 standards unless the user has set fortran_have_tabs in .vimrc. | |
523 'textwidth' is set to 72 for fixed source format as required by the | |
524 Fortran standards and to 80 for free source format. | |
525 'formatoptions' is set to break code and comment lines and to preserve long | |
237 | 526 lines. You can format comments with |gq|. |
7 | 527 For further discussion of fortran_have_tabs and the method used for the |
501 | 528 detection of source format see |ft-fortran-syntax|. |
7 | 529 |
530 | |
1624 | 531 GIT COMMIT *ft-gitcommit-plugin* |
532 | |
533 One command, :DiffGitCached, is provided to show a diff of the current commit | |
534 in the preview window. It is equivalent to calling "git diff --cached" plus | |
535 any arguments given to the command. | |
536 | |
537 | |
501 | 538 MAIL *ft-mail-plugin* |
7 | 539 |
540 Options: | |
541 'modeline' is switched off to avoid the danger of trojan horses, and to | |
542 avoid that a Subject line with "Vim:" in it will cause an | |
543 error message. | |
544 'textwidth' is set to 72. This is often recommended for e-mail. | |
545 'formatoptions' is set to break text lines and to repeat the comment leader | |
546 in new lines, so that a leading ">" for quotes is repeated. | |
547 You can also format quoted text with |gq|. | |
548 | |
549 Local mappings: | |
550 <LocalLeader>q or \\MailQuote | |
551 Quotes the text selected in Visual mode, or from the cursor position | |
552 to the end of the file in Normal mode. This means "> " is inserted in | |
553 each line. | |
554 | |
7315
444efa5f5015
commit https://github.com/vim/vim/commit/2c5e8e80eacf491d4f266983f534a77776c7ae83
Christian Brabandt <cb@256bit.org>
parents:
7272
diff
changeset
|
555 MAN *ft-man-plugin* *:Man* *man.vim* |
7 | 556 |
557 Displays a manual page in a nice way. Also see the user manual | |
558 |find-manpage|. | |
559 | |
560 To start using the ":Man" command before any manual page was loaded, source | |
561 this script from your startup vimrc file: > | |
562 | |
563 runtime ftplugin/man.vim | |
564 | |
565 Options: | |
566 'iskeyword' the '.' character is added to be able to use CTRL-] on the | |
567 manual page name. | |
568 | |
569 Commands: | |
570 Man {name} Display the manual page for {name} in a window. | |
571 Man {number} {name} | |
572 Display the manual page for {name} in a section {number}. | |
573 | |
574 Global mapping: | |
575 <Leader>K Displays the manual page for the word under the cursor. | |
576 | |
577 Local mappings: | |
578 CTRL-] Jump to the manual page for the word under the cursor. | |
579 CTRL-T Jump back to the previous manual page. | |
7272
17333ebd2bbd
commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents:
5568
diff
changeset
|
580 q Same as ":quit" |
17333ebd2bbd
commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents:
5568
diff
changeset
|
581 |
9344
33c1b85d408c
commit https://github.com/vim/vim/commit/802a0d902fca423acb15f835d7b09183883d79a0
Christian Brabandt <cb@256bit.org>
parents:
9116
diff
changeset
|
582 To use a vertical split instead of horizontal: > |
33c1b85d408c
commit https://github.com/vim/vim/commit/802a0d902fca423acb15f835d7b09183883d79a0
Christian Brabandt <cb@256bit.org>
parents:
9116
diff
changeset
|
583 let g:ft_man_open_mode = 'vert' |
33c1b85d408c
commit https://github.com/vim/vim/commit/802a0d902fca423acb15f835d7b09183883d79a0
Christian Brabandt <cb@256bit.org>
parents:
9116
diff
changeset
|
584 To use a new tab: > |
33c1b85d408c
commit https://github.com/vim/vim/commit/802a0d902fca423acb15f835d7b09183883d79a0
Christian Brabandt <cb@256bit.org>
parents:
9116
diff
changeset
|
585 let g:ft_man_open_mode = 'tab' |
33c1b85d408c
commit https://github.com/vim/vim/commit/802a0d902fca423acb15f835d7b09183883d79a0
Christian Brabandt <cb@256bit.org>
parents:
9116
diff
changeset
|
586 |
7272
17333ebd2bbd
commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents:
5568
diff
changeset
|
587 To enable folding use this: > |
17333ebd2bbd
commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents:
5568
diff
changeset
|
588 let g:ft_man_folding_enable = 1 |
7384
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
589 If you do not like the default folding, use an autocommand to add your desired |
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
590 folding style instead. For example: > |
aea5ebf352c4
commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
591 autocmd FileType man setlocal foldmethod=indent foldenable |
7 | 592 |
9116
bc38030aec7d
commit https://github.com/vim/vim/commit/26852128a2b713ef49341a0c18daba928444e7eb
Christian Brabandt <cb@256bit.org>
parents:
9041
diff
changeset
|
593 You may also want to set 'keywordprg' to make the |K| command open a manual |
bc38030aec7d
commit https://github.com/vim/vim/commit/26852128a2b713ef49341a0c18daba928444e7eb
Christian Brabandt <cb@256bit.org>
parents:
9041
diff
changeset
|
594 page in a Vim window: > |
bc38030aec7d
commit https://github.com/vim/vim/commit/26852128a2b713ef49341a0c18daba928444e7eb
Christian Brabandt <cb@256bit.org>
parents:
9041
diff
changeset
|
595 set keywordprg=:Man |
bc38030aec7d
commit https://github.com/vim/vim/commit/26852128a2b713ef49341a0c18daba928444e7eb
Christian Brabandt <cb@256bit.org>
parents:
9041
diff
changeset
|
596 |
7 | 597 |
9041
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
598 MANPAGER *manpager.vim* |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
599 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
600 The :Man command allows you to turn Vim into a manpager (that syntax highlights |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
601 manpages and follows linked manpages on hitting CTRL-]). |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
602 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
603 Works on: |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
604 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
605 - Linux |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
606 - Mac OS |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
607 - FreeBSD |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
608 - Cygwin |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
609 - Win 10 under Bash |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
610 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
611 Untested: |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
612 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
613 - Amiga OS |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
614 - BeOS |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
615 - OS/2 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
616 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
617 For bash,zsh,ksh or dash by adding to the config file (.bashrc,.zshrc, ...) |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
618 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
619 export MANPAGER="env MAN_PN=1 vim -M +MANPAGER -" |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
620 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
621 For (t)csh by adding to the config file |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
622 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
623 setenv MANPAGER "env MAN_PN=1 vim -M +MANPAGER -" |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
624 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
625 For fish by adding to the config file |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
626 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
627 set -x MANPAGER "env MAN_PN=1 vim -M +MANPAGER -" |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
628 |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
629 If man sets the $MAN_PN environment variable, like man-db, the most common |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
630 implementation on Linux and Mac OS, then the "env MAN_PN=1 " part above is |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
631 superfluous. |
34c45ee4210d
commit https://github.com/vim/vim/commit/06481427005a9dae39721087df94855f7d4d1feb
Christian Brabandt <cb@256bit.org>
parents:
7384
diff
changeset
|
632 |
1624 | 633 PDF *ft-pdf-plugin* |
634 | |
635 Two maps, <C-]> and <C-T>, are provided to simulate a tag stack for navigating | |
636 the PDF. The following are treated as tags: | |
637 | |
638 - The byte offset after "startxref" to the xref table | |
639 - The byte offset after the /Prev key in the trailer to an earlier xref table | |
640 - A line of the form "0123456789 00000 n" in the xref table | |
641 - An object reference like "1 0 R" anywhere in the PDF | |
642 | |
643 These maps can be disabled with > | |
644 :let g:no_pdf_maps = 1 | |
645 < | |
646 | |
501 | 647 RPM SPEC *ft-spec-plugin* |
7 | 648 |
649 Since the text for this plugin is rather long it has been put in a separate | |
650 file: |pi_spec.txt|. | |
651 | |
652 | |
720 | 653 SQL *ft-sql* |
654 | |
655 Since the text for this plugin is rather long it has been put in a separate | |
1624 | 656 file: |ft_sql.txt|. |
720 | 657 |
658 | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2908
diff
changeset
|
659 TEX *ft-tex-plugin* *g:tex_flavor* |
798 | 660 |
661 If the first line of a *.tex file has the form > | |
662 %&<format> | |
663 then this determined the file type: plaintex (for plain TeX), context (for | |
664 ConTeXt), or tex (for LaTeX). Otherwise, the file is searched for keywords to | |
800 | 665 choose context or tex. If no keywords are found, it defaults to plaintex. |
666 You can change the default by defining the variable g:tex_flavor to the format | |
851 | 667 (not the file type) you use most. Use one of these: > |
668 let g:tex_flavor = "plain" | |
669 let g:tex_flavor = "context" | |
670 let g:tex_flavor = "latex" | |
671 Currently no other formats are recognized. | |
798 | 672 |
673 | |
7 | 674 vim:tw=78:ts=8:ft=help:norl: |