Now, when I do set ft=X from the command line, it happens that the ftplugin X doesn't get loaded because it finishes when b:did_ftplugin is set.
What I actually meant by this was: the ftplugin X doesn't get loaded when a filetype was already set before, i.e. when a filetype plugin already defined b:did_ftplugin.

ftplugins should define b:undo_ftplugin .
   :h undo_ftplugin
If this var exists and its commands get executed then (only then) also
b:did_ftplugin will be unset.

Executing b:undo_ftplugin is one of the first things  :setf X  tries
to do.
Thanks, in the meantime I already found this help page. But it doesn't seem to solve the problem.

Here's what I do (vim is 7.0-204):

in ~/.vim/ftplugin/test.vim

   if &cp || exists("b:did_ftplugin")
       echom 'b:did_ftplugin already set!'
       finish
   endif
   let b:did_ftplugin = 1

   echom "Test ftplugin!"

on the command line:
gvim -u NONE

in vim:
:set nocompatible
:syntax on
:filetype plugin on
:help
:set ft=test

Result: 'b:did_ftplugin already set!' is printed in the echo area. b:did_ftplugin obviously is set by the help ftplugin (b:undo_ftplugin is set to "setl fo< tw<") but is never unset.

Is this really the intended behaviour? Is the user meant to manually unlet b:did_ftplugin in such a situation? Do I misunderstand here something quite fundamentally?

Regards,
Thomas.

Reply via email to