" -*- vim -*- " FILE: "D:\VIM\TeX\aux2tags.vim" " LAST MODIFICATION: "Thu, 30 Aug 2001 11:29:53 Eastern Daylight Time ()" " (C) 2001 by Benji Fisher, " Version 0.1 " Usage: ":TeXtags foo" will generate a tags file from foo.aux . If you " are currently editing foo.tex or foo.bar then ":TeXtags" alone will do. " The file you are editing must be in the same directory as the .aux file. command! -nargs=? TeXtags call TeXtags() " Generate a tags file from a LaTeX .aux file. " This version clobbers any existing tags file! fun! TeXtags(...) if a:0 let fname = a:1 " Get file name from argument list. else let fname = expand("%:t:r") " Get file name from current file. endif if !filereadable(fname . ".aux") echohl WarningMsg execute "echo 'TeXtags: could not find file " fname . ".aux'" echohl NONE else split %:p:h/tags %d " Clobber it! put='Tags file generated by TeXtags() Vim script' execute "r" fname . ".aux" v/^\\newlabel/d " v/^\\newlabel\|^\\bibcite/d let tagline = 'label:\1\t' . fname . '.tex\t' let tagline = tagline . '\/\\\\label{\\s\\*\1\\s\\*}\/' " let tagline = tagline . 'ijump \/\\\\label{\\s\\*\1\\s\\*}\/' execute '%s/^\\newlabel{\(.\{-}\)}.*/' . tagline wq endif endfun