Loading ...
Sorry, an error occurred while loading the content.

Re: ~/.vim/ftplugin/

Expand Messages
  • Benji Fisher
    ... It is not quite automatic. It does work this way if you have a line something like filetype plugin on in your vimrc file. ... If you already have the line
    Message 1 of 3 , Jun 30 9:40 AM
    • 0 Attachment
      William Norris wrote:
      > it is my understanding that the files in the system ftplugin folder are
      > automatically sourced by vim based on the filetype. for example, when I
      > edit an email in mutt, then vim will source the files
      > `/usr/local/share/vim/ftplugin/mail*.vim`
      > is that correct?

      It is not quite automatic. It does work this way if you have a line
      something like

      filetype plugin on

      in your vimrc file.

      > I read somewhere online (can't find the page now) that this also held
      > true for a local plugin directory `~/.vim/ftplugin/`. However, this
      > doesn't seem to be holding true for me. Is there a way to have vim
      > automatically source files in this 'local' ftplugin folder? I like the
      > idea of keeping them in my home directory so they move with me, but I
      > also like the auto-sourcing feature.

      If you already have the line I mentioned in your vimrc file, it is likely
      that both the default ftplugins (under /usr/local/share/vim/ ) and your personal
      ones (under ~/.vim/ ) are being :source'd . Yours come first (assuming the
      usual setting of the 'runtimepath' option) so youe settings may get undone by
      the default ftplugins. Either put your ftplugins under ~/.vim/after/ftplugin/
      or have your ftplugin define the b:did_ftplugin variable so that the defaults
      bail out.

      :help ftplugin-overrule

      HTH --Benji Fisher
    Your message has been successfully submitted and would be delivered to recipients shortly.