On 28/04/11 17:55, Ben Fritz wrote:
On Apr 28, 11:26 am, JuanPabloAJ<[email protected]> 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.
If it's a bulky script, you could put it someplace out of the way (let's
say, name it ~/.vim/macros/foobar.vim ) then add several one-liners to
source it: e.g. either add
runtime macros/foobar.vim
either as part or all of each of
~/.vim/ftplugin/c.vim
~/.vim/ftplugin/cpp.vim
~/.vim/ftplugin/css.vim
~/.vim/ftplugin/javascript.vim
or else place in your vimrc the single autocommand (this is method 3 below)
autocmd FileType c,cpp,css,javascript runtime macros/foobar.vim
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:
if exists('b:did_run_foobar')
finish
endif
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 script
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
scripts.
Best regards,
Tony.
--
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