ftplugin.vim 971 B

123456789101112131415161718192021222324252627282930313233343536
  1. " Vim support file to switch on loading plugins for file types
  2. "
  3. " Maintainer: Bram Moolenaar <Bram@vim.org>
  4. " Last change: 2006 Apr 30
  5. if exists("did_load_ftplugin")
  6. finish
  7. endif
  8. let did_load_ftplugin = 1
  9. augroup filetypeplugin
  10. au FileType * call s:LoadFTPlugin()
  11. func! s:LoadFTPlugin()
  12. if exists("b:undo_ftplugin")
  13. exe b:undo_ftplugin
  14. unlet! b:undo_ftplugin b:did_ftplugin
  15. endif
  16. let s = expand("<amatch>")
  17. if s != ""
  18. if &cpo =~# "S" && exists("b:did_ftplugin")
  19. " In compatible mode options are reset to the global values, need to
  20. " set the local values also when a plugin was already used.
  21. unlet b:did_ftplugin
  22. endif
  23. " When there is a dot it is used to separate filetype names. Thus for
  24. " "aaa.bbb" load "aaa" and then "bbb".
  25. for name in split(s, '\.')
  26. exe 'runtime! ftplugin/' . name . '.vim ftplugin/' . name . '_*.vim ftplugin/' . name . '/*.vim'
  27. endfor
  28. endif
  29. endfunc
  30. augroup END