Merged from the latest developing branch.
[MacVim/jjgod.git] / runtime / ftplugin / vim.vim
blob78fb6ec3a87801b66fe0e8b1265973b085b5a80d
1 " Vim filetype plugin
2 " Language:     Vim
3 " Maintainer:   Bram Moolenaar <Bram@vim.org>
4 " Last Change:  2006 Sep 26
6 " Only do this when not done yet for this buffer
7 if exists("b:did_ftplugin")
8   finish
9 endif
11 " Don't load another plugin for this buffer
12 let b:did_ftplugin = 1
14 let cpo_save = &cpo
15 set cpo-=C
17 let b:undo_ftplugin = "setl fo< com< tw< commentstring<"
18         \ . "| unlet! b:match_ignorecase b:match_words b:match_skip"
20 " Set 'formatoptions' to break comment lines but not other lines,
21 " and insert the comment leader when hitting <CR> or using "o".
22 setlocal fo-=t fo+=croql
24 " Set 'comments' to format dashed lists in comments
25 setlocal com=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\"
27 " Format comments to be up to 78 characters long
28 if &tw == 0
29   setlocal tw=78
30 endif
32 " Comments start with a double quote
33 setlocal commentstring=\"%s
35 " Move around functions.
36 noremap <silent><buffer> [[ m':call search('^\s*fu\%[nction]\>', "bW")<CR>
37 noremap <silent><buffer> ]] m':call search('^\s*fu\%[nction]\>', "W")<CR>
38 noremap <silent><buffer> [] m':call search('^\s*endf*\%[unction]\>', "bW")<CR>
39 noremap <silent><buffer> ][ m':call search('^\s*endf*\%[unction]\>', "W")<CR>
41 " Move around comments
42 noremap <silent><buffer> ]" :call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR>
43 noremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
45 " Let the matchit plugin know what items can be matched.
46 if 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         \ '\<for\>:\<brea\%[k]\>:\<con\%[tinue]\>:\<endfo\%[r]\>,' .
52         \ '\<if\>:\<el\%[seif]\>:\<en\%[dif]\>,' .
53         \ '\<try\>:\<cat\%[ch]\>:\<fina\%[lly]\>:\<endt\%[ry]\>,' .
54         \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:\<aug\%[roup]\s\+END\>,' .
55         \ '(:)'
56   " Ignore ":syntax region" commands, the 'end' argument clobbers if-endif
57   let b:match_skip = 'getline(".") =~ "^\\s*sy\\%[ntax]\\s\\+region" ||
58         \ synIDattr(synID(line("."),col("."),1),"name") =~? "comment\\|string"'
59 endif
61 let &cpo = cpo_save
63 " removed this, because 'cpoptions' is a global option.
64 " setlocal cpo+=M               " makes \%( match \)