Re: Plugin for specific file type
- On 28/04/11 17:55, Ben Fritz wrote:
>If it's a bulky script, you could put it someplace out of the way (let's
> On Apr 28, 11:26 am, JuanPabloAJ<jabar...@...> wrote:
>> but, if this plugin is for many language,
>> I cant use the&ft variable ?
> Sure you can, but that's not what you asked. You have a few options:
> 1. Always load the plugin for all file types by placing it in your
> ~/.vim/plugin directory, but for every feature in the plugin, make it
> do nothing unless&ft is the desired file type.
> 2. Only load the plugin for certain file types, by using the filetype
> plugin method mentioned, and copying it for every desired file type.
say, name it ~/.vim/macros/foobar.vim ) then add several one-liners to
source it: e.g. either add
either as part or all of each of
or else place in your vimrc the single autocommand (this is method 3 below)
For both of these (which correspond to methods 2 above and 3 below) your
script will be sourced once for each editfile to which it applies: so it
should use :setlocal (not :set), :lcd (not :cd), :let b:var = value (not
:let var = value) etc.
One example of the latter would be, quite near the begin of your script:
let b:did_run_foobar = 1
to avoid sourcing the script twice for the same buffer.
> 3. Only load the plugin for certain file types, by sourcing the scriptBest regards,
> in a FileType autocmd for the desired file types.
> 4. Some other method you may be able to think of, Vim has lots of ways
> to automatically do arbitrary things, including the sourcing of
If God wanted us to be brave, why did he give us legs?
-- Marvin Kitman
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php