4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: When adding detection of a specific filetype for a plugin you need
12 to edit "filetype.vim".
13 Solution: Source files from the "ftdetect" directory, so that a filetype
14 detection plugin only needs to be dropped in a directory.
15 Files: runtime/doc/filetype.txt, runtime/doc/usr_05.txt,
16 runtime/doc/usr_41.txt, runtime/filetype.vim
19 *** ../vim-6.2.072/runtime/doc/filetype.txt Sun Jun 1 12:20:32 2003
20 --- runtime/doc/filetype.txt Thu Aug 14 11:22:30 2003
23 ! *filetype.txt* For Vim version 6.2. Last change: 2003 Apr 25
26 VIM REFERENCE MANUAL by Bram Moolenaar
28 ! *filetype.txt* For Vim version 6.2. Last change: 2003 Aug 14
31 VIM REFERENCE MANUAL by Bram Moolenaar
34 This means that the contents of compressed files are not inspected.
37 ! If a file type that you want to use is not detected yet, there are two ways to
38 ! add it. In any way, it's better not modify the $VIMRUNTIME/filetype.vim file.
39 ! It will be overwritten when installing a new version of Vim.
41 ! A. If your file type can be detected by the file name.
42 1. Create your user runtime directory. You would normally use the first
43 item of the 'runtimepath' option. Example for Unix: >
46 This means that the contents of compressed files are not inspected.
49 ! If a file type that you want to use is not detected yet, there are three ways
50 ! to add it. In any way, it's better not modify the $VIMRUNTIME/filetype.vim
51 ! file. It will be overwritten when installing a new version of Vim.
53 ! A. If you want to overrule all default file type checks.
54 ! This works by writing one file for each filetype. The disadvantage is that
55 ! means there can be many files. The advantage is that you can simply drop
56 ! this file in the right directory to make it work.
58 ! 1. Create your user runtime directory. You would normally use the first
59 ! item of the 'runtimepath' option. Then create the directory "ftdetect"
60 ! inside it. Example for Unix: >
62 ! :!mkdir ~/.vim/ftdetect
64 ! 2. Create a file that contains an autocommand to detect the file type.
66 ! au BufRead,BufNewFile *.mine set filetype=mine
67 ! < Note that there is no "augroup" command, this has already been done
68 ! when sourcing your file. You could also use the pattern "*" and then
69 ! check the contents of the file to recognize it.
70 ! Write this file as "mine.vim" in the "filetype" directory in your user
71 ! runtime directory. For example, for Unix: >
72 ! :w ~/.vim/ftdetect/mine.vim
74 ! < 3. To use the new filetype detection you must restart Vim.
76 ! The files in the "filetype" directory are used after all the default
77 ! checks, thus they can overrule a previously detected file type. You can
78 ! also use that in your command. For example, to use the file type
79 ! "mypascal" when "pascal" has been detected: >
80 ! au BufRead,BufNewFile * if ft == 'pascal' | set ft=mypascal
83 ! B. If your file type can be detected by the file name.
84 1. Create your user runtime directory. You would normally use the first
85 item of the 'runtimepath' option. Example for Unix: >
89 ":setfiletype" command will make sure that no other autocommands will set
90 'filetype' after this.
91 *new-filetype-scripts*
92 ! B. If your filetype can only be detected by inspecting the contents of the
95 1. Create your user runtime directory. You would normally use the first
97 ":setfiletype" command will make sure that no other autocommands will set
98 'filetype' after this.
99 *new-filetype-scripts*
100 ! C. If your filetype can only be detected by inspecting the contents of the
103 1. Create your user runtime directory. You would normally use the first
104 *** ../vim-6.2.072/runtime/doc/usr_05.txt Sun Jun 1 12:20:36 2003
105 --- runtime/doc/usr_05.txt Wed Aug 13 22:15:03 2003
108 ! *usr_05.txt* For Vim version 6.2. Last change: 2003 Mar 15
110 VIM USER MANUAL - by Bram Moolenaar
113 ! *usr_05.txt* For Vim version 6.2. Last change: 2003 Aug 13
115 VIM USER MANUAL - by Bram Moolenaar
120 |write-plugin| How to write a plugin script.
121 |plugin-details| For more information about using plugins or when your
123 + |new-filetype| How to detect a new file type.
125 ==============================================================================
126 *05.5* Adding a help file *add-local-help* *matchit-install*
127 *** ../vim-6.2.072/runtime/doc/usr_41.txt Sat Jul 5 19:20:12 2003
128 --- runtime/doc/usr_41.txt Thu Aug 14 11:22:51 2003
131 ! *usr_41.txt* For Vim version 6.2. Last change: 2003 Jun 03
133 VIM USER MANUAL - by Bram Moolenaar
136 ! *usr_41.txt* For Vim version 6.2. Last change: 2003 Aug 14
138 VIM USER MANUAL - by Bram Moolenaar
144 Using references to other parts of the help in || is recommended. This makes
145 it easy for the user to find associated help.
148 + FILETYPE DETECTION *plugin-filetype*
150 + If your filetype is not already detected by Vim, you should create a filetype
151 + detection snippet in a separate file. It is usually in the form of an
152 + autocommand that sets the filetype when the file name matches a pattern.
155 + au BufNewFile,BufRead *.foo set filetype=foofoo
157 + Write this single-line file as "ftdetect/foofoo.vim" in the first directory
158 + that appears in 'runtimepath'. For Unix that would be
159 + "~/.vim/ftdetect/foofoo.vim". The convention is to use the name of the
160 + filetype for the script name.
162 + You can make more complicated checks if you like, for example to inspect the
163 + contents of the file to recognize the language. Also see |new-filetype|.
166 SUMMARY *plugin-special*
167 *** ../vim-6.2.072/runtime/filetype.vim Fri Jul 25 21:39:40 2003
168 --- runtime/filetype.vim Sun Aug 17 22:05:19 2003
171 " Vim support file to detect file types
173 " Maintainer: Bram Moolenaar <Bram@vim.org>
174 ! " Last Change: 2003 Jul 23
176 " Listen very carefully, I will say this only once
177 if exists("did_load_filetypes")
179 " Vim support file to detect file types
181 " Maintainer: Bram Moolenaar <Bram@vim.org>
182 ! " Last Change: 2003 Aug 17
184 " Listen very carefully, I will say this only once
185 if exists("did_load_filetypes")
189 \ || getline(4) =~ '^#' || getline(5) =~ '^#') |
193 + " Use the plugin-filetype checks last, they may overrule any of the previously
194 + " detected filetypes.
195 + runtime! ftdetect/*.vim
199 *** ../vim-6.2.072/src/version.c Tue Sep 2 22:22:59 2003
200 --- src/version.c Tue Sep 9 22:14:57 2003
204 { /* Add new patch number below this line */
210 The war between Emacs and Vi is over. Vi has won with 3 to 1.
211 http://www.ssc.com/lg/issue30/raymond.html
213 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
214 /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
215 \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
216 \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///