On 2009-05-21, Erik Wognsen wrote:
> On Wed, May 20, 2009 at 16:51, Ben Fritz <[email protected]> wrote:
> >
> > On May 20, 2:22 am, Erik Wognsen <[email protected]> wrote:
> >> Hi,
> >> when I open a php file, both ~/.vim/ftplugin/php.vim and
> >> ~/.vim/ftplugin/html.vim are sourced. And in that order, which makes
> >> the latter override the former. I have the same problem with C++ and
> >> C.
> >>
> >> I see the stuff in $VIMRUNTIME/ftplugin/ runtimes the others, but can
> >> I get it the other way round without tampering with the global files?
> >>
> >
> > What do you mean? php.vim sources html.vim VERY early in the file,
> > before it sets any options. html.vim is not sourced after php.vim, it
> > is sourced DURING the execution of php.vim. It is php.vim that
> > overrides html.vim, not the other way around.
> You're right. But the problem is still there.
>
> I moved my whole ~/.vim tree and created a new one with just these two files:
>
> ~/.vim/ftplugin/html.vim
> ~/.vim/ftplugin/php.vim
>
> containing one line each:
>
> nn <buffer> <F2> Ahtml<esc>
> nn <buffer> <F2> Aphp<esc>
>
> respectively. Now I edit a php file and press F2....
>
> I get "html" :-(
Right. When you open a php file, vim loads all the php.vim files[1]
in your 'runtimepath', typically (for Unix):
$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
So in your case, vim will load, in this order,
~/.vim/ftplugin/php.vim
$VIMRUNTIME/ftplugin/php.vim
That second file contains this line:
runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
which will cause vim to load
~/.vim/ftplugin/html.vim
$VIMRUNTIME/ftplugin/html.vim
thereby leaving <F2> set to add "html".
To do what you want to do, a better place to put your customizations
is in the ~/.vim/after/ftplugin directory, i.e., in the files
~/.vim/after/ftplugin/html.vim
~/.vim/after/ftplugin/php.vim
The loading order for all these plugins would then be:
~/.vim/ftplugin/php.vim
$VIMRUNTIME/ftplugin/php.vim
~/.vim/ftplugin/html.vim
$VIMRUNTIME/ftplugin/html.vim
~/.vim/after/ftplugin/html.vim
~/.vim/after/ftplugin/php.vim
BTW, the convention is this group is to bottom post, not top post.
Regards,
Gary
----------
[1] This is a simplification, but adequate for the current purpose.
See ":help ftplugin-name" for more.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---