1" Vim filetype plugin file 2" Language: C 3" Maintainer: Bram Moolenaar <[email protected]> 4" Last Change: 2020 Feb 01 5 6" Only do this when not done yet for this buffer 7if exists("b:did_ftplugin") 8 finish 9endif 10 11" Don't load another plugin for this buffer 12let b:did_ftplugin = 1 13 14" Using line continuation here. 15let s:cpo_save = &cpo 16set cpo-=C 17 18let b:undo_ftplugin = "setl fo< com< ofu< cms< def< inc< | if has('vms') | setl isk< | endif" 19 20" Set 'formatoptions' to break comment lines but not other lines, 21" and insert the comment leader when hitting <CR> or using "o". 22setlocal fo-=t fo+=croql 23 24" These options have the right value as default, but the user may have 25" overruled that. 26setlocal commentstring& define& include& 27 28" Set completion with CTRL-X CTRL-O to autoloaded function. 29if exists('&ofu') 30 setlocal ofu=ccomplete#Complete 31endif 32 33" Set 'comments' to format dashed lists in comments. 34setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// 35 36" In VMS C keywords contain '$' characters. 37if has("vms") 38 setlocal iskeyword+=$ 39endif 40 41" When the matchit plugin is loaded, this makes the % command skip parens and 42" braces in comments properly. 43let b:match_words = '^\s*#\s*if\(\|def\|ndef\)\>:^\s*#\s*elif\>:^\s*#\s*else\>:^\s*#\s*endif\>' 44let b:match_skip = 's:comment\|string\|character\|special' 45 46" Win32 can filter files in the browse dialog 47if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") 48 if &ft == "cpp" 49 let b:browsefilter = "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" . 50 \ "C Header Files (*.h)\t*.h\n" . 51 \ "C Source Files (*.c)\t*.c\n" . 52 \ "All Files (*.*)\t*.*\n" 53 elseif &ft == "ch" 54 let b:browsefilter = "Ch Source Files (*.ch *.chf)\t*.ch;*.chf\n" . 55 \ "C Header Files (*.h)\t*.h\n" . 56 \ "C Source Files (*.c)\t*.c\n" . 57 \ "All Files (*.*)\t*.*\n" 58 else 59 let b:browsefilter = "C Source Files (*.c)\t*.c\n" . 60 \ "C Header Files (*.h)\t*.h\n" . 61 \ "Ch Source Files (*.ch *.chf)\t*.ch;*.chf\n" . 62 \ "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" . 63 \ "All Files (*.*)\t*.*\n" 64 endif 65endif 66 67let &cpo = s:cpo_save 68unlet s:cpo_save 69