1" Vim filetype plugin 2" Language: Vim 3" Maintainer: Bram Moolenaar <[email protected]> 4" Last Change: 2004 Sep 13 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 14let cpo_save = &cpo 15set cpo-=C 16 17let b:undo_ftplugin = "setl fo< com< tw< commentstring<" 18 \ . "| unlet! b:match_ignorecase b:match_words b:match_skip" 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" Set 'comments' to format dashed lists in comments 25setlocal com=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\" 26 27" Format comments to be up to 78 characters long 28if &tw == 0 29 setlocal tw=78 30endif 31 32" Comments start with a double quote 33setlocal commentstring=\"%s 34 35" Move around functions. 36noremap <silent><buffer> [[ m':call search('^\s*fu\%[nction]\>', "bW")<CR> 37noremap <silent><buffer> ]] m':call search('^\s*fu\%[nction]\>', "W")<CR> 38noremap <silent><buffer> [] m':call search('^\s*endf*\%[unction]\>', "bW")<CR> 39noremap <silent><buffer> ][ m':call search('^\s*endf*\%[unction]\>', "W")<CR> 40 41" Move around comments 42noremap <silent><buffer> ]" :call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR> 43noremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR> 44 45" Let the matchit plugin know what items can be matched. 46if exists("loaded_matchit") 47 let b:match_ignorecase = 0 48 let b:match_words = 49 \ '\<fu\%[nction]\>:\<retu\%[rn]\>:\<endf\%[unction]\>,' . 50 \ '\<wh\%[ile]\>:\<brea\%[k]\>:\<con\%[tinue]\>:\<endw\%[hile]\>,' . 51 \ '\<if\>:\<el\%[seif]\>:\<en\%[dif]\>,' . 52 \ '\<try\>:\<cat\%[ch]\>:\<fina\%[lly]\>:\<endt\%[ry]\>,' . 53 \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:\<aug\%[roup]\s\+END\>,' . 54 \ '(:)' 55 " Ignore ":syntax region" commands, the 'end' argument clobbers if-endif 56 let b:match_skip = 'getline(".") =~ "^\\s*sy\\%[ntax]\\s\\+region" || 57 \ synIDattr(synID(line("."),col("."),1),"name") =~? "comment\\|string"' 58endif 59 60let &cpo = cpo_save 61setlocal cpo+=M " makes \%( match \) 62