home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / runtime / dos / ftplugin / vim.vim < prev    next >
Encoding:
Text File  |  2012-05-31  |  3.1 KB  |  79 lines

  1. " Vim filetype plugin
  2. " Language:    Vim
  3. " Maintainer:    Bram Moolenaar <Bram@vim.org>
  4. " Last Change:    2012 Mar 21
  5.  
  6. " Only do this when not done yet for this buffer
  7. if exists("b:did_ftplugin")
  8.   finish
  9. endif
  10.  
  11. " Don't load another plugin for this buffer
  12. let b:did_ftplugin = 1
  13.  
  14. let s:cpo_save = &cpo
  15. set cpo-=C
  16.  
  17. let b:undo_ftplugin = "setl fo< isk< 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".
  22. setlocal fo-=t fo+=croql
  23.  
  24. " To make syntax highlighting of 'vimVar's work correctly we need the colon to
  25. " be part of keywords. This needs to be done prior to the 'isk+=#' below.
  26. setlocal isk+=:
  27.  
  28. " To allow tag lookup via CTRL-] for autoload functions, '#' must be a
  29. " keyword character.  E.g., for netrw#Nread().
  30. setlocal isk+=#
  31.  
  32. " Set 'comments' to format dashed lists in comments
  33. setlocal com=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\"
  34.  
  35. " Format comments to be up to 78 characters long
  36. if &tw == 0
  37.   setlocal tw=78
  38. endif
  39.  
  40. " Comments start with a double quote
  41. setlocal commentstring=\"%s
  42.  
  43. " Move around functions.
  44. nnoremap <silent><buffer> [[ m':call search('^\s*fu\%[nction]\>', "bW")<CR>
  45. vnoremap <silent><buffer> [[ m':<C-U>exe "normal! gv"<Bar>call search('^\s*fu\%[nction]\>', "bW")<CR>
  46. nnoremap <silent><buffer> ]] m':call search('^\s*fu\%[nction]\>', "W")<CR>
  47. vnoremap <silent><buffer> ]] m':<C-U>exe "normal! gv"<Bar>call search('^\s*fu\%[nction]\>', "W")<CR>
  48. nnoremap <silent><buffer> [] m':call search('^\s*endf*\%[unction]\>', "bW")<CR>
  49. vnoremap <silent><buffer> [] m':<C-U>exe "normal! gv"<Bar>call search('^\s*endf*\%[unction]\>', "bW")<CR>
  50. nnoremap <silent><buffer> ][ m':call search('^\s*endf*\%[unction]\>', "W")<CR>
  51. vnoremap <silent><buffer> ][ m':<C-U>exe "normal! gv"<Bar>call search('^\s*endf*\%[unction]\>', "W")<CR>
  52.  
  53. " Move around comments
  54. nnoremap <silent><buffer> ]" :call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR>
  55. vnoremap <silent><buffer> ]" :<C-U>exe "normal! gv"<Bar>call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR>
  56. nnoremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
  57. vnoremap <silent><buffer> [" :<C-U>exe "normal! gv"<Bar>call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
  58.  
  59. " Let the matchit plugin know what items can be matched.
  60. if exists("loaded_matchit")
  61.   let b:match_ignorecase = 0
  62.   let b:match_words =
  63.     \ '\<fu\%[nction]\>:\<retu\%[rn]\>:\<endf\%[unction]\>,' .
  64.      \ '\<\(wh\%[ile]\|for\)\>:\<brea\%[k]\>:\<con\%[tinue]\>:\<end\(w\%[hile]\|fo\%[r]\)\>,' .
  65.     \ '\<if\>:\<el\%[seif]\>:\<en\%[dif]\>,' .
  66.     \ '\<try\>:\<cat\%[ch]\>:\<fina\%[lly]\>:\<endt\%[ry]\>,' .
  67.     \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:\<aug\%[roup]\s\+END\>,' .
  68.     \ '(:)'
  69.   " Ignore ":syntax region" commands, the 'end' argument clobbers if-endif
  70.   let b:match_skip = 'getline(".") =~ "^\\s*sy\\%[ntax]\\s\\+region" ||
  71.     \ synIDattr(synID(line("."),col("."),1),"name") =~? "comment\\|string"'
  72. endif
  73.  
  74. let &cpo = s:cpo_save
  75. unlet s:cpo_save
  76.  
  77. " removed this, because 'cpoptions' is a global option.
  78. " setlocal cpo+=M        " makes \%( match \)
  79.