c.vim 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. " Vim filetype plugin file
  2. " Language: C
  3. " Maintainer: Bram Moolenaar <Bram@vim.org>
  4. " Last Change: 2017 Sep 28
  5. " Only do this when not done yet for this buffer
  6. if exists("b:did_ftplugin")
  7. finish
  8. endif
  9. " Don't load another plugin for this buffer
  10. let b:did_ftplugin = 1
  11. " Using line continuation here.
  12. let s:cpo_save = &cpo
  13. set cpo-=C
  14. let b:undo_ftplugin = "setl fo< com< ofu<"
  15. " Set 'formatoptions' to break comment lines but not other lines,
  16. " and insert the comment leader when hitting <CR> or using "o".
  17. setlocal fo-=t fo+=croql
  18. " Set completion with CTRL-X CTRL-O to autoloaded function.
  19. if exists('&ofu')
  20. setlocal ofu=ccomplete#Complete
  21. endif
  22. " Set 'comments' to format dashed lists in comments.
  23. setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
  24. " When the matchit plugin is loaded, this makes the % command skip parens and
  25. " braces in comments properly.
  26. let b:match_words = '^\s*#\s*if\(\|def\|ndef\)\>:^\s*#\s*elif\>:^\s*#\s*else\>:^\s*#\s*endif\>'
  27. let b:match_skip = 's:comment\|string\|character\|special'
  28. " Win32 can filter files in the browse dialog
  29. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  30. if &ft == "cpp"
  31. let b:browsefilter = "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" .
  32. \ "C Header Files (*.h)\t*.h\n" .
  33. \ "C Source Files (*.c)\t*.c\n" .
  34. \ "All Files (*.*)\t*.*\n"
  35. elseif &ft == "ch"
  36. let b:browsefilter = "Ch Source Files (*.ch *.chf)\t*.ch;*.chf\n" .
  37. \ "C Header Files (*.h)\t*.h\n" .
  38. \ "C Source Files (*.c)\t*.c\n" .
  39. \ "All Files (*.*)\t*.*\n"
  40. else
  41. let b:browsefilter = "C Source Files (*.c)\t*.c\n" .
  42. \ "C Header Files (*.h)\t*.h\n" .
  43. \ "Ch Source Files (*.ch *.chf)\t*.ch;*.chf\n" .
  44. \ "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" .
  45. \ "All Files (*.*)\t*.*\n"
  46. endif
  47. endif
  48. let b:man_default_sects = '3,2'
  49. let &cpo = s:cpo_save
  50. unlet s:cpo_save