1 " Vim filetype plugin file
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.info>
4 " Last Change: 2007 Dec 16
6 if exists("b:did_ftplugin")
11 setlocal commentstring=%%s
13 let b:undo_ftplugin = "setlocal cms< com< | unlet! b:match_words"
15 if exists("g:loaded_matchit")
16 let b:match_words = '\<\%(\d\+\s\+\d\+\s\+\)obj\>:\<endobj\>,\<stream$:\<endstream\>,\<xref\>:\<trailer\>,<<:>>'
19 if exists("g:no_plugin_maps") || exists("g:no_pdf_maps") || v:version < 700
23 if !exists("b:pdf_tagstack")
24 let b:pdf_tagstack = []
27 let b:undo_ftplugin .= " | silent! nunmap <buffer> <C-]> | silent! nunmap <buffer> <C-T>"
28 nnoremap <silent><buffer> <C-]> :call <SID>Tag()<CR>
29 " Inline, so the error from an empty tag stack will be simple.
30 nnoremap <silent><buffer> <C-T> :if len(b:pdf_tagstack) > 0 <Bar> call setpos('.',remove(b:pdf_tagstack, -1)) <Bar> else <Bar> exe "norm! \<Lt>C-T>" <Bar> endif<CR>
33 call add(b:pdf_tagstack,getpos('.'))
34 if getline('.') =~ '^\d\+$' && getline(line('.')-1) == 'startxref'
35 return s:dodigits(getline('.'))
36 elseif getline('.') =~ '/Prev\s\+\d\+\>\%(\s\+\d\)\@!' && expand("<cword>") =~ '^\d\+$'
37 return s:dodigits(expand("<cword>"))
38 elseif getline('.') =~ '^\d\{10\} \d\{5\} '
39 return s:dodigits(matchstr(getline('.'),'^\d\+'))
41 let line = getline(".")
43 let pat = '\<\d\+\s\+\d\+\s\+R\>'
45 let beg = match(line,'\C'.pat,lastend)
46 let end = matchend(line,'\C'.pat,lastend)
47 if beg < col(".") && end >= col(".")
48 return s:doobject(matchstr(line,'\C'.pat,lastend))
56 function! s:doobject(string)
57 let first = matchstr(a:string,'^\s*\zs\d\+')
58 let second = matchstr(a:string,'^\s*\d\+\s\+\zs\d\+')
60 if first != '' && second != ''
61 let oldline = line('.')
64 if !search('^\s*'.first.'\s\+'.second.'\s\+obj\>')
66 exe 'norm! '.oldcol.'|'
72 function! s:dodigits(digits)
73 let digits = 0 + substitute(a:digits,'^0*','','')
78 " Go one character before the destination and advance. This method
79 " lands us after a newline rather than before, if that is our target.
80 exe "goto ".(digits)."|norm! 1 "
85 silent! call remove(b:pdf_tagstack,-1)
87 echo "E426: tag not found"