ruby.vim 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. " Vim filetype plugin
  2. " Language: Ruby
  3. " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
  4. " URL: https://github.com/vim-ruby/vim-ruby
  5. " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
  6. " ----------------------------------------------------------------------------
  7. if (exists("b:did_ftplugin"))
  8. finish
  9. endif
  10. let b:did_ftplugin = 1
  11. let s:cpo_save = &cpo
  12. set cpo&vim
  13. if has("gui_running") && !has("gui_win32")
  14. setlocal keywordprg=ri\ -T\ -f\ bs
  15. else
  16. setlocal keywordprg=ri
  17. endif
  18. " Matchit support
  19. if exists("loaded_matchit") && !exists("b:match_words")
  20. let b:match_ignorecase = 0
  21. let b:match_words =
  22. \ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|begin\)\>=\@!' .
  23. \ ':' .
  24. \ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' .
  25. \ ':' .
  26. \ '\%(^\|[^.\:@$]\)\@<=\<end\:\@!\>' .
  27. \ ',{:},\[:\],(:)'
  28. let b:match_skip =
  29. \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" .
  30. \ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Escape\\|" .
  31. \ "Regexp\\|RegexpDelimiter\\|" .
  32. \ "Interpolation\\|NoInterpolation\\|Comment\\|Documentation\\|" .
  33. \ "ConditionalModifier\\|RepeatModifier\\|OptionalDo\\|" .
  34. \ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" .
  35. \ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'"
  36. endif
  37. setlocal formatoptions-=t formatoptions+=croql
  38. setlocal include=^\\s*\\<\\(load\\>\\\|require\\>\\\|autoload\\s*:\\=[\"']\\=\\h\\w*[\"']\\=,\\)
  39. setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'\%(\.rb\)\=$','.rb','')
  40. setlocal suffixesadd=.rb
  41. if exists("&ofu") && has("ruby")
  42. setlocal omnifunc=rubycomplete#Complete
  43. endif
  44. " To activate, :set ballooneval
  45. if has('balloon_eval') && exists('+balloonexpr')
  46. setlocal balloonexpr=RubyBalloonexpr()
  47. endif
  48. " TODO:
  49. "setlocal define=^\\s*def
  50. setlocal comments=:#
  51. setlocal commentstring=#\ %s
  52. if !exists('g:ruby_version_paths')
  53. let g:ruby_version_paths = {}
  54. endif
  55. function! s:query_path(root) abort
  56. let code = "print $:.join %q{,}"
  57. if &shell =~# 'sh'
  58. let prefix = 'env PATH='.shellescape($PATH).' '
  59. else
  60. let prefix = ''
  61. endif
  62. if &shellxquote == "'"
  63. let path_check = prefix.'ruby --disable-gems -e "' . code . '"'
  64. else
  65. let path_check = prefix."ruby --disable-gems -e '" . code . "'"
  66. endif
  67. let cd = haslocaldir() ? 'lcd' : 'cd'
  68. let cwd = fnameescape(getcwd())
  69. try
  70. exe cd fnameescape(a:root)
  71. let path = split(system(path_check),',')
  72. exe cd cwd
  73. return path
  74. finally
  75. exe cd cwd
  76. endtry
  77. endfunction
  78. function! s:build_path(path) abort
  79. let path = join(map(copy(a:path), 'v:val ==# "." ? "" : v:val'), ',')
  80. if &g:path !~# '\v^\.%(,/%(usr|emx)/include)=,,$'
  81. let path = substitute(&g:path,',,$',',','') . ',' . path
  82. endif
  83. return path
  84. endfunction
  85. if !exists('b:ruby_version') && !exists('g:ruby_path') && isdirectory(expand('%:p:h'))
  86. let s:version_file = findfile('.ruby-version', '.;')
  87. if !empty(s:version_file) && filereadable(s:version_file)
  88. let b:ruby_version = get(readfile(s:version_file, '', 1), '')
  89. if !has_key(g:ruby_version_paths, b:ruby_version)
  90. let g:ruby_version_paths[b:ruby_version] = s:query_path(fnamemodify(s:version_file, ':p:h'))
  91. endif
  92. endif
  93. endif
  94. if exists("g:ruby_path")
  95. let s:ruby_path = type(g:ruby_path) == type([]) ? join(g:ruby_path, ',') : g:ruby_path
  96. elseif has_key(g:ruby_version_paths, get(b:, 'ruby_version', ''))
  97. let s:ruby_paths = g:ruby_version_paths[b:ruby_version]
  98. let s:ruby_path = s:build_path(s:ruby_paths)
  99. else
  100. if !exists('g:ruby_default_path')
  101. if has("ruby") && has("win32")
  102. ruby ::VIM::command( 'let g:ruby_default_path = split("%s",",")' % $:.join(%q{,}) )
  103. elseif executable('ruby')
  104. let g:ruby_default_path = s:query_path($HOME)
  105. else
  106. let g:ruby_default_path = map(split($RUBYLIB,':'), 'v:val ==# "." ? "" : v:val')
  107. endif
  108. endif
  109. let s:ruby_paths = g:ruby_default_path
  110. let s:ruby_path = s:build_path(s:ruby_paths)
  111. endif
  112. if stridx(&l:path, s:ruby_path) == -1
  113. let &l:path = s:ruby_path
  114. endif
  115. if exists('s:ruby_paths') && stridx(&l:tags, join(map(copy(s:ruby_paths),'v:val."/tags"'),',')) == -1
  116. let &l:tags = &tags . ',' . join(map(copy(s:ruby_paths),'v:val."/tags"'),',')
  117. endif
  118. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  119. let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" .
  120. \ "All Files (*.*)\t*.*\n"
  121. endif
  122. let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< tags< kp<"
  123. \."| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip"
  124. \."| if exists('&ofu') && has('ruby') | setl ofu< | endif"
  125. \."| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif"
  126. function! s:map(mode, flags, map) abort
  127. let from = matchstr(a:map, '\S\+')
  128. if empty(mapcheck(from, a:mode))
  129. exe a:mode.'map' '<buffer>'.(a:0 ? a:1 : '') a:map
  130. let b:undo_ftplugin .= '|sil! '.a:mode.'unmap <buffer> '.from
  131. endif
  132. endfunction
  133. cmap <buffer><script><expr> <Plug><cword> substitute(RubyCursorIdentifier(),'^$',"\022\027",'')
  134. cmap <buffer><script><expr> <Plug><cfile> substitute(RubyCursorFile(),'^$',"\022\006",'')
  135. let b:undo_ftplugin .= "| sil! cunmap <buffer> <Plug><cword>| sil! cunmap <buffer> <Plug><cfile>"
  136. if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
  137. nmap <buffer><script> <SID>: :<C-U>
  138. nmap <buffer><script> <SID>c: :<C-U><C-R>=v:count ? v:count : ''<CR>
  139. nnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b','n')<CR>
  140. nnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','','n')<CR>
  141. nnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b','n')<CR>
  142. nnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','','n')<CR>
  143. xnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b','v')<CR>
  144. xnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','','v')<CR>
  145. xnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b','v')<CR>
  146. xnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','','v')<CR>
  147. nnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b','n')<CR>
  148. nnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','','n')<CR>
  149. nnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b','n')<CR>
  150. nnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','','n')<CR>
  151. xnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b','v')<CR>
  152. xnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','','v')<CR>
  153. xnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b','v')<CR>
  154. xnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','','v')<CR>
  155. let b:undo_ftplugin = b:undo_ftplugin
  156. \."| sil! exe 'unmap <buffer> [[' | sil! exe 'unmap <buffer> ]]' | sil! exe 'unmap <buffer> []' | sil! exe 'unmap <buffer> ]['"
  157. \."| sil! exe 'unmap <buffer> [m' | sil! exe 'unmap <buffer> ]m' | sil! exe 'unmap <buffer> [M' | sil! exe 'unmap <buffer> ]M'"
  158. if maparg('im','x') == '' && maparg('im','o') == '' && maparg('am','x') == '' && maparg('am','o') == ''
  159. onoremap <silent> <buffer> im :<C-U>call <SID>wrap_i('[m',']M')<CR>
  160. onoremap <silent> <buffer> am :<C-U>call <SID>wrap_a('[m',']M')<CR>
  161. xnoremap <silent> <buffer> im :<C-U>call <SID>wrap_i('[m',']M')<CR>
  162. xnoremap <silent> <buffer> am :<C-U>call <SID>wrap_a('[m',']M')<CR>
  163. let b:undo_ftplugin = b:undo_ftplugin
  164. \."| sil! exe 'ounmap <buffer> im' | sil! exe 'ounmap <buffer> am'"
  165. \."| sil! exe 'xunmap <buffer> im' | sil! exe 'xunmap <buffer> am'"
  166. endif
  167. if maparg('iM','x') == '' && maparg('iM','o') == '' && maparg('aM','x') == '' && maparg('aM','o') == ''
  168. onoremap <silent> <buffer> iM :<C-U>call <SID>wrap_i('[[','][')<CR>
  169. onoremap <silent> <buffer> aM :<C-U>call <SID>wrap_a('[[','][')<CR>
  170. xnoremap <silent> <buffer> iM :<C-U>call <SID>wrap_i('[[','][')<CR>
  171. xnoremap <silent> <buffer> aM :<C-U>call <SID>wrap_a('[[','][')<CR>
  172. let b:undo_ftplugin = b:undo_ftplugin
  173. \."| sil! exe 'ounmap <buffer> iM' | sil! exe 'ounmap <buffer> aM'"
  174. \."| sil! exe 'xunmap <buffer> iM' | sil! exe 'xunmap <buffer> aM'"
  175. endif
  176. call s:map('c', '', '<C-R><C-W> <Plug><cword>')
  177. call s:map('c', '', '<C-R><C-F> <Plug><cfile>')
  178. cmap <buffer><script><expr> <SID>tagzv &foldopen =~# 'tag' ? '<Bar>norm! zv' : ''
  179. call s:map('n', '<silent>', '<C-]> <SID>:exe v:count1."tag <Plug><cword>"<SID>tagzv<CR>')
  180. call s:map('n', '<silent>', 'g<C-]> <SID>:exe "tjump <Plug><cword>"<SID>tagzv<CR>')
  181. call s:map('n', '<silent>', 'g] <SID>:exe "tselect <Plug><cword>"<SID>tagzv<CR>')
  182. call s:map('n', '<silent>', '<C-W>] <SID>:exe v:count1."stag <Plug><cword>"<SID>tagzv<CR>')
  183. call s:map('n', '<silent>', '<C-W><C-]> <SID>:exe v:count1."stag <Plug><cword>"<SID>tagzv<CR>')
  184. call s:map('n', '<silent>', '<C-W>g<C-]> <SID>:exe "stjump <Plug><cword>"<SID>tagzv<CR>')
  185. call s:map('n', '<silent>', '<C-W>g] <SID>:exe "stselect <Plug><cword>"<SID>tagzv<CR>')
  186. call s:map('n', '<silent>', '<C-W>} <SID>:exe v:count1."ptag <Plug><cword>"<CR>')
  187. call s:map('n', '<silent>', '<C-W>g} <SID>:exe "ptjump <Plug><cword>"<CR>')
  188. call s:map('n', '<silent>', 'gf <SID>c:find <Plug><cfile><CR>')
  189. call s:map('n', '<silent>', '<C-W>f <SID>c:sfind <Plug><cfile><CR>')
  190. call s:map('n', '<silent>', '<C-W><C-F> <SID>c:sfind <Plug><cfile><CR>')
  191. call s:map('n', '<silent>', '<C-W>gf <SID>c:tabfind <Plug><cfile><CR>')
  192. endif
  193. let &cpo = s:cpo_save
  194. unlet s:cpo_save
  195. if exists("g:did_ruby_ftplugin_functions")
  196. finish
  197. endif
  198. let g:did_ruby_ftplugin_functions = 1
  199. function! RubyBalloonexpr() abort
  200. if !exists('s:ri_found')
  201. let s:ri_found = executable('ri')
  202. endif
  203. if s:ri_found
  204. let line = getline(v:beval_lnum)
  205. let b = matchstr(strpart(line,0,v:beval_col),'\%(\w\|[:.]\)*$')
  206. let a = substitute(matchstr(strpart(line,v:beval_col),'^\w*\%([?!]\|\s*=\)\?'),'\s\+','','g')
  207. let str = b.a
  208. let before = strpart(line,0,v:beval_col-strlen(b))
  209. let after = strpart(line,v:beval_col+strlen(a))
  210. if str =~ '^\.'
  211. let str = substitute(str,'^\.','#','g')
  212. if before =~ '\]\s*$'
  213. let str = 'Array'.str
  214. elseif before =~ '}\s*$'
  215. " False positives from blocks here
  216. let str = 'Hash'.str
  217. elseif before =~ "[\"'`]\\s*$" || before =~ '\$\d\+\s*$'
  218. let str = 'String'.str
  219. elseif before =~ '\$\d\+\.\d\+\s*$'
  220. let str = 'Float'.str
  221. elseif before =~ '\$\d\+\s*$'
  222. let str = 'Integer'.str
  223. elseif before =~ '/\s*$'
  224. let str = 'Regexp'.str
  225. else
  226. let str = substitute(str,'^#','.','')
  227. endif
  228. endif
  229. let str = substitute(str,'.*\.\s*to_f\s*\.\s*','Float#','')
  230. let str = substitute(str,'.*\.\s*to_i\%(nt\)\=\s*\.\s*','Integer#','')
  231. let str = substitute(str,'.*\.\s*to_s\%(tr\)\=\s*\.\s*','String#','')
  232. let str = substitute(str,'.*\.\s*to_sym\s*\.\s*','Symbol#','')
  233. let str = substitute(str,'.*\.\s*to_a\%(ry\)\=\s*\.\s*','Array#','')
  234. let str = substitute(str,'.*\.\s*to_proc\s*\.\s*','Proc#','')
  235. if str !~ '^\w'
  236. return ''
  237. endif
  238. silent! let res = substitute(system("ri -f rdoc -T \"".str.'"'),'\n$','','')
  239. if res =~ '^Nothing known about' || res =~ '^Bad argument:' || res =~ '^More than one method'
  240. return ''
  241. endif
  242. return res
  243. else
  244. return ""
  245. endif
  246. endfunction
  247. function! s:searchsyn(pattern, syn, flags, mode) abort
  248. let cnt = v:count1
  249. norm! m'
  250. if a:mode ==# 'v'
  251. norm! gv
  252. endif
  253. let i = 0
  254. while i < cnt
  255. let i = i + 1
  256. let line = line('.')
  257. let col = col('.')
  258. let pos = search(a:pattern,'W'.a:flags)
  259. while pos != 0 && s:synname() !~# a:syn
  260. let pos = search(a:pattern,'W'.a:flags)
  261. endwhile
  262. if pos == 0
  263. call cursor(line,col)
  264. return
  265. endif
  266. endwhile
  267. endfunction
  268. function! s:synname() abort
  269. return synIDattr(synID(line('.'),col('.'),0),'name')
  270. endfunction
  271. function! s:wrap_i(back,forward) abort
  272. execute 'norm k'.a:forward
  273. let line = line('.')
  274. execute 'norm '.a:back
  275. if line('.') == line - 1
  276. return s:wrap_a(a:back,a:forward)
  277. endif
  278. execute 'norm jV'.a:forward.'k'
  279. endfunction
  280. function! s:wrap_a(back,forward) abort
  281. execute 'norm '.a:forward
  282. if line('.') < line('$') && getline(line('.')+1) ==# ''
  283. let after = 1
  284. endif
  285. execute 'norm '.a:back
  286. while getline(line('.')-1) =~# '^\s*#' && line('.')
  287. -
  288. endwhile
  289. if exists('after')
  290. execute 'norm V'.a:forward.'j'
  291. elseif line('.') > 1 && getline(line('.')-1) =~# '^\s*$'
  292. execute 'norm kV'.a:forward
  293. else
  294. execute 'norm V'.a:forward
  295. endif
  296. endfunction
  297. function! RubyCursorIdentifier() abort
  298. let asciicode = '\%(\w\|[]})\"'."'".']\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)'
  299. let number = '\%(\%(\w\|[]})\"'."'".']\s*\)\@<!-\)\=\%(\<[[:digit:]_]\+\%(\.[[:digit:]_]\+\)\=\%([Ee][[:digit:]_]\+\)\=\>\|\<0[xXbBoOdD][[:xdigit:]_]\+\>\)\|'.asciicode
  300. let operator = '\%(\[\]\|<<\|<=>\|[!<>]=\=\|===\=\|[!=]\~\|>>\|\*\*\|\.\.\.\=\|=>\|[~^&|*/%+-]\)'
  301. let method = '\%(\.[_a-zA-Z]\w*\s*=>\@!\|\<[_a-zA-Z]\w*\>[?!]\=\)'
  302. let global = '$\%([!$&"'."'".'*+,./:;<=>?@\`~]\|-\=\w\+\>\)'
  303. let symbolizable = '\%(\%(@@\=\)\w\+\>\|'.global.'\|'.method.'\|'.operator.'\)'
  304. let pattern = '\C\s*\%('.number.'\|\%(:\@<!:\)\='.symbolizable.'\)'
  305. let [lnum, col] = searchpos(pattern,'bcn',line('.'))
  306. let raw = matchstr(getline('.')[col-1 : ],pattern)
  307. let stripped = substitute(substitute(raw,'\s\+=$','=',''),'^\s*[:.]\=','','')
  308. return stripped == '' ? expand("<cword>") : stripped
  309. endfunction
  310. function! RubyCursorFile() abort
  311. let isfname = &isfname
  312. try
  313. set isfname+=:
  314. let cfile = expand('<cfile>')
  315. finally
  316. let isfname = &isfname
  317. endtry
  318. let pre = matchstr(strpart(getline('.'), 0, col('.')-1), '.*\f\@<!')
  319. let post = matchstr(strpart(getline('.'), col('.')), '\f\@!.*')
  320. let ext = getline('.') =~# '^\s*\%(require\%(_relative\)\=\|autoload\)\>' && cfile !~# '\.rb$' ? '.rb' : ''
  321. if s:synname() ==# 'rubyConstant'
  322. let cfile = substitute(cfile,'\.\w\+[?!=]\=$','','')
  323. let cfile = substitute(cfile,'::','/','g')
  324. let cfile = substitute(cfile,'\(\u\+\)\(\u\l\)','\1_\2', 'g')
  325. let cfile = substitute(cfile,'\(\l\|\d\)\(\u\)','\1_\2', 'g')
  326. return tolower(cfile) . '.rb'
  327. elseif getline('.') =~# '^\s*require_relative\s*\(["'']\).*\1\s*$'
  328. let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext
  329. elseif getline('.') =~# '^\s*\%(require[( ]\|load[( ]\|autoload[( ]:\w\+,\)\s*\%(::\)\=File\.expand_path(\(["'']\)\.\./.*\1,\s*__FILE__)\s*$'
  330. let target = matchstr(getline('.'),'\(["'']\)\.\.\zs/.\{-\}\ze\1')
  331. let cfile = expand('%:p:h') . target . ext
  332. elseif getline('.') =~# '^\s*\%(require \|load \|autoload :\w\+,\)\s*\(["'']\).*\1\s*$'
  333. let cfile = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext
  334. elseif pre.post =~# '\<File.expand_path[( ].*[''"]\{2\}, *__FILE__\>' && cfile =~# '^\.\.'
  335. let cfile = expand('%:p:h') . strpart(cfile, 2)
  336. else
  337. return substitute(cfile, '\C\v^(.*):(\d+)%(:in)=$', '+\2 \1', '')
  338. endif
  339. let cwdpat = '^\M' . substitute(getcwd(), '[\/]', '\\[\\/]', 'g').'\ze\[\/]'
  340. let cfile = substitute(cfile, cwdpat, '.', '')
  341. if fnameescape(cfile) !=# cfile
  342. return '+ '.fnameescape(cfile)
  343. else
  344. return cfile
  345. endif
  346. endfunction
  347. "
  348. " Instructions for enabling "matchit" support:
  349. "
  350. " 1. Look for the latest "matchit" plugin at
  351. "
  352. " http://www.vim.org/scripts/script.php?script_id=39
  353. "
  354. " It is also packaged with Vim, in the $VIMRUNTIME/macros directory.
  355. "
  356. " 2. Copy "matchit.txt" into a "doc" directory (e.g. $HOME/.vim/doc).
  357. "
  358. " 3. Copy "matchit.vim" into a "plugin" directory (e.g. $HOME/.vim/plugin).
  359. "
  360. " 4. Ensure this file (ftplugin/ruby.vim) is installed.
  361. "
  362. " 5. Ensure you have this line in your $HOME/.vimrc:
  363. " filetype plugin on
  364. "
  365. " 6. Restart Vim and create the matchit documentation:
  366. "
  367. " :helptags ~/.vim/doc
  368. "
  369. " Now you can do ":help matchit", and you should be able to use "%" on Ruby
  370. " keywords. Try ":echo b:match_words" to be sure.
  371. "
  372. " Thanks to Mark J. Reed for the instructions. See ":help vimrc" for the
  373. " locations of plugin directories, etc., as there are several options, and it
  374. " differs on Windows. Email gsinclair@soyabean.com.au if you need help.
  375. "
  376. " vim: nowrap sw=2 sts=2 ts=8: