tex.vim 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. " LaTeX filetype plugin
  2. " Language: LaTeX (ft=tex)
  3. " Maintainer: Benji Fisher, Ph.D. <benji@member.AMS.org>
  4. " Version: 1.4
  5. " Last Change: Wed 19 Apr 2006
  6. " URL: http://www.vim.org/script.php?script_id=411
  7. " Only do this when not done yet for this buffer.
  8. if exists("b:did_ftplugin")
  9. finish
  10. endif
  11. " Start with plain TeX. This will also define b:did_ftplugin .
  12. source $VIMRUNTIME/ftplugin/plaintex.vim
  13. " Avoid problems if running in 'compatible' mode.
  14. let s:save_cpo = &cpo
  15. set cpo&vim
  16. let b:undo_ftplugin .= "| setl inex<"
  17. " Allow "[d" to be used to find a macro definition:
  18. " Recognize plain TeX \def as well as LaTeX \newcommand and \renewcommand .
  19. " I may as well add the AMS-LaTeX DeclareMathOperator as well.
  20. let &l:define .= '\|\\\(re\)\=new\(boolean\|command\|counter\|environment\|font'
  21. \ . '\|if\|length\|savebox\|theorem\(style\)\=\)\s*\*\=\s*{\='
  22. \ . '\|DeclareMathOperator\s*{\=\s*'
  23. " Tell Vim how to recognize LaTeX \include{foo} and plain \input bar :
  24. let &l:include .= '\|\\include{'
  25. " On some file systems, "{" and "}" are included in 'isfname'. In case the
  26. " TeX file has \include{fname} (LaTeX only), strip everything except "fname".
  27. let &l:includeexpr = "substitute(v:fname, '^.\\{-}{\\|}.*', '', 'g')"
  28. " The following lines enable the matchit.vim plugin for
  29. " extended matching with the % key.
  30. " ftplugin/plaintex.vim already defines b:match_skip and b:match_ignorecase
  31. " and matches \(, \), \[, \], \{, and \} .
  32. if exists("loaded_matchit")
  33. let b:match_words .= ',\\begin\s*\({\a\+\*\=}\):\\end\s*\1'
  34. endif " exists("loaded_matchit")
  35. let &cpo = s:save_cpo
  36. unlet s:save_cpo
  37. " vim:sts=2:sw=2: