1 " Vimball Archiver by Charles E. Campbell, Jr., Ph.D.
4 ftplugin/ATP_files/LatexBox_common.vim [[[1
6 " Author: David Munger (latexbox vim plugin)
7 " Description: LaTeX Box common functions
8 " Maintainer: Marcin Szamotulski
9 " Note: This file is a part of Automatic Tex Plugin for Vim.
10 " URL: https://launchpad.net/automatictexplugin
13 let s:sourced = exists("s:sourced") ? 1 : 0
18 if !exists('g:LatexBox_completion_close_braces')
19 let g:LatexBox_completion_close_braces = 1
21 if !exists('g:LatexBox_bibtex_wild_spaces')
22 let g:LatexBox_bibtex_wild_spaces = 1
25 if !exists('g:LatexBox_cite_pattern')
26 let g:LatexBox_cite_pattern = '\C\\cite\(p\|t\)\?\*\?\_\s*{'
28 if !exists('g:LatexBox_ref_pattern')
29 let g:LatexBox_ref_pattern = '\C\\v\?\(eq\|page\)\?ref\*\?\_\s*{'
32 if !exists('g:LatexBox_completion_environments')
33 let g:LatexBox_completion_environments = [
34 \ {'word': 'itemize', 'menu': 'bullet list' },
35 \ {'word': 'enumerate', 'menu': 'numbered list' },
36 \ {'word': 'description', 'menu': 'description' },
37 \ {'word': 'center', 'menu': 'centered text' },
38 \ {'word': 'figure', 'menu': 'floating figure' },
39 \ {'word': 'table', 'menu': 'floating table' },
40 \ {'word': 'equation', 'menu': 'equation (numbered)' },
41 \ {'word': 'align', 'menu': 'aligned equations (numbered)' },
42 \ {'word': 'align*', 'menu': 'aligned equations' },
43 \ {'word': 'document' },
44 \ {'word': 'abstract' },
48 if !exists('g:LatexBox_completion_commands')
49 let g:LatexBox_completion_commands = [
50 \ {'word': '\begin{' },
53 \ {'word': '\label{' },
55 \ {'word': '\eqref{eq:' },
56 \ {'word': '\cite{' },
57 \ {'word': '\chapter{' },
58 \ {'word': '\section{' },
59 \ {'word': '\subsection{' },
60 \ {'word': '\subsubsection{' },
61 \ {'word': '\paragraph{' },
62 \ {'word': '\nonumber' },
63 \ {'word': '\bibliography' },
64 \ {'word': '\bibliographystyle' },
70 if !exists('g:LatexBox_split_width')
71 let g:LatexBox_split_width = 30
83 if !exists('g:vim_program')
85 " attempt autodetection of vim executable
86 let g:vim_program = ''
87 let tmpfile = tempname()
88 silent execute '!ps -o command= -p $PPID > ' . tmpfile
89 for line in readfile(tmpfile)
90 let line = matchstr(line, '^\S\+\>')
91 if !empty(line) && executable(line)
92 let g:vim_program = line . ' -g'
98 if empty(g:vim_program)
100 let g:vim_program = '/Applications/MacVim.app/Contents/MacOS/Vim -g'
102 let g:vim_program = v:progname
108 if !exists('g:LatexBox_latexmk_options')
109 let g:LatexBox_latexmk_options = ''
111 if !exists('g:LatexBox_output_type')
112 let g:LatexBox_output_type = 'pdf'
114 if !exists('g:LatexBox_viewer')
115 let g:LatexBox_viewer = b:atp_Viewer
119 " Filename utilities {{{
121 function! LatexBox_GetMainTexFile()
122 return atplib#FullPath(b:atp_MainFile)
125 " Return the directory of the main tex file
126 function! LatexBox_GetTexRoot()
127 return fnamemodify(LatexBox_GetMainTexFile(), ':h')
130 function! LatexBox_GetTexBasename(with_dir)
132 return fnamemodify(LatexBox_GetMainTexFile(), ':r')
134 return fnamemodify(LatexBox_GetMainTexFile(), ':t:r')
138 function! LatexBox_GetAuxFile()
139 return LatexBox_GetTexBasename(1) . '.aux'
142 function! LatexBox_GetLogFile()
143 return LatexBox_GetTexBasename(1) . '.log'
146 function! LatexBox_GetOutputFile()
147 return LatexBox_GetTexBasename(1) . '.' . g:LatexBox_output_type
152 " LatexBox_InComment([line], [col])
153 " return true if inside comment
154 function! LatexBox_InComment(...)
155 let line = a:0 >= 1 ? a:1 : line('.')
156 let col = a:0 >= 2 ? a:2 : col('.')
157 return synIDattr(synID(line("."), col("."), 0), "name") =~# '^texComment'
161 " Get Current Environment {{{
162 " LatexBox_GetCurrentEnvironment([with_pos])
164 " - environment if with_pos is not given
165 " - [envirnoment, lnum_begin, cnum_begin, lnum_end, cnum_end] if with_pos is nonzero
166 function! LatexBox_GetCurrentEnvironment(...)
174 let begin_pat = '\C\\begin\_\s*{[^}]*}\|\\\[\|\\('
175 let end_pat = '\C\\end\_\s*{[^}]*}\|\\\]\|\\)'
176 let saved_pos = getpos('.')
178 " move to the left until on a backslash
179 let [bufnum, lnum, cnum, off] = getpos('.')
180 let line = getline(lnum)
181 while cnum > 1 && line[cnum - 1] != '\'
184 call cursor(lnum, cnum)
186 " match begin/end pairs but skip comments
188 if strpart(getline('.'), col('.') - 1) =~ '^\%(' . begin_pat . '\)'
191 let [lnum1, cnum1] = searchpairpos(begin_pat, '', end_pat, flags, 'LatexBox_InComment()')
197 let line = strpart(getline(lnum1), cnum1 - 1)
200 let env = matchstr(line, '\m^\C\\begin\_\s*{\zs[^}]*\ze}')
203 let env = matchstr(line, '^\\\[')
206 let env = matchstr(line, '^\\(')
214 if !(lnum1 == lnum && cnum1 == cnum)
218 let [lnum2, cnum2] = searchpairpos(begin_pat, '', end_pat, flags, 'LatexBox_InComment()')
219 return [env, lnum1, cnum1, lnum2, cnum2]
221 call setpos('.', saved_pos)
229 " vim:fdm=marker:ff=unix:noet:ts=4:sw=4
230 ftplugin/ATP_files/LatexBox_complete.vim [[[1
232 " Author: David Mnuger (latexbox vim plugin)
233 " Maintainer: Marcin Szamotulski
234 " Note: This file is a part of Automatic Tex Plugin for Vim.
235 " URL: https://launchpad.net/automatictexplugin
236 " Email: mszamot [AT] gmail [DOT] com
239 let s:sourced = exists("s:sourced") ? 1 : 0
244 let s:atp_MainFile = ( g:atp_RelativePath ? globpath(b:atp_ProjectDir, fnamemodify(b:atp_MainFile, ":t")) : b:atp_MainFile )
246 " latex-box/complete.vim
249 return matchstr(expand('<sfile>'), '\m\zs<SNR>\d\+_\ze.*$')
251 let s:SID = s:GetSID()
252 call extend(g:atp_compiler_SID,{ fnamemodify(expand('<sfile>'),':t') : s:SID })
253 " a:1 is the file where the function is defined.
254 function! s:SIDWrap(func,...)
256 return s:SID . a:func
258 let l:sid=get(g:atp_compiler_SID, 'tex_atp.vim', 'error')
260 echoerr 'atp sid error'
263 return l:sid . a:func
269 " Omni Completion {{{
271 let s:completion_type = ''
273 function! LatexBox_Complete(findstart, base)
275 " return the starting position of the word
276 let line = getline('.')
277 let pos = col('.') - 1
278 while pos > 0 && line[pos - 1] !~ '\\\|{'
282 let line_start = line[:pos-1]
283 if line_start =~ '\C\\begin\_\s*{$'
284 let s:completion_type = 'begin'
285 elseif line_start =~ '\C\\end\_\s*{$'
286 let s:completion_type = 'end'
287 elseif line_start =~ g:LatexBox_ref_pattern . '$'
288 let s:completion_type = 'ref'
289 elseif line_start =~ g:LatexBox_cite_pattern . '$'
290 let s:completion_type = 'bib'
291 " check for multiple citations
292 let pos = col('.') - 1
293 while pos > 0 && line[pos - 1] !~ '{\|,'
297 let s:completion_type = 'command'
298 if line[pos - 1] == '\'
304 " return suggestions in an array
307 if s:completion_type == 'begin'
308 " suggest known environments
309 for entry in g:LatexBox_completion_environments
310 if entry.word =~ '^' . escape(a:base, '\')
311 if g:LatexBox_completion_close_braces && !s:NextCharsMatch('^}')
313 let entry = copy(entry)
314 let entry.abbr = entry.word
315 let entry.word = entry.word . '}'
317 call add(suggestions, entry)
320 elseif s:completion_type == 'end'
321 " suggest known environments
322 let env = LatexBox_GetCurrentEnvironment()
324 if g:LatexBox_completion_close_braces && !s:NextCharsMatch('^\s*[,}]')
325 call add(suggestions, {'word': env . '}', 'abbr': env})
327 call add(suggestions, env)
330 elseif s:completion_type == 'command'
331 " suggest known commands
332 for entry in g:LatexBox_completion_commands
333 if entry.word =~ '^' . escape(a:base, '\')
334 " do not display trailing '{'
336 let entry.abbr = entry.word[0:-2]
338 call add(suggestions, entry)
341 elseif s:completion_type == 'ref'
342 let suggestions = s:CompleteLabels(a:base)
343 elseif s:completion_type == 'bib'
344 " suggest BibTeX entries
345 let suggestions = LatexBox_BibComplete(a:base)
347 if !has('gui_running')
357 " find the \bibliography{...} commands
358 " the optional argument is the file name to be searched
359 function! LatexBox_kpsewhich(file)
360 let old_dir = getcwd()
361 execute 'lcd ' . LatexBox_GetTexRoot()
363 silent execute '!kpsewhich ' . a:file
366 let out = split(out, "\<NL>")[-1]
367 let out = substitute(out, '\r', '', 'g')
368 let out = glob(fnamemodify(out, ':p'), 1)
370 execute 'lcd ' . old_dir
375 function! s:FindBibData(...)
378 let file = ( g:atp_RelativePath ? globpath(b:atp_ProjectDir, fnamemodify(b:atp_MainFile, ":t")) : b:atp_MainFile )
383 if empty(glob(file, 1))
387 let lines = readfile(file)
389 let bibdata_list = []
392 \ map(filter(copy(lines), 'v:val =~ ''\C\\bibliography\s*{[^}]\+}'''),
393 \ 'matchstr(v:val, ''\m\C\\bibliography\s*{\zs[^}]\+\ze}'')')
396 \ map(filter(copy(lines), 'v:val =~ ''\C\\\%(input\|include\)\s*{[^}]\+}'''),
397 \ 's:FindBibData(LatexBox_kpsewhich(matchstr(v:val, ''\m\C\\\%(input\|include\)\s*{\zs[^}]\+\ze}'')))')
400 \ map(filter(copy(lines), 'v:val =~ ''\C\\\%(input\|include\)\s\+\S\+'''),
401 \ 's:FindBibData(LatexBox_kpsewhich(matchstr(v:val, ''\m\C\\\%(input\|include\)\s\+\zs\S\+\ze'')))')
403 let bibdata = join(bibdata_list, ',')
408 let s:bstfile = expand('<sfile>:p:h') . '/vimcomplete'
410 function! LatexBox_BibSearch(regexp)
413 let bibdata = s:FindBibData()
415 echomsg 'error: no \bibliography{...} command found'
419 " write temporary aux file
420 let tmpbase = b:atp_ProjectDir . '/_LatexBox_BibComplete'
421 let auxfile = tmpbase . '.aux'
422 let bblfile = tmpbase . '.bbl'
423 let blgfile = tmpbase . '.blg'
425 call writefile(['\citation{*}', '\bibstyle{' . s:bstfile . '}', '\bibdata{' . bibdata . '}'], auxfile)
427 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
428 silent execute '! cd ' shellescape(fnamemodify(atp_MainFile,":h")) .
429 \ ' ; bibtex -terse ' . fnamemodify(auxfile, ':t') . ' >/dev/null'
434 let lines = split(substitute(join(readfile(bblfile), "\n"), '\n\n\@!\(\s\=\)\s*\|{\|}', '\1', 'g'), "\n")
436 for line in filter(lines, 'v:val =~ a:regexp')
437 let matches = matchlist(line, '^\(.*\)||\(.*\)||\(.*\)||\(.*\)||\(.*\)')
438 if !empty(matches) && !empty(matches[1])
439 call add(res, {'key': matches[1], 'type': matches[2],
440 \ 'author': matches[3], 'year': matches[4], 'title': matches[5]})
452 " BibTeX completion {{{
453 function! LatexBox_BibComplete(regexp)
455 " treat spaces as '.*' if needed
456 if g:LatexBox_bibtex_wild_spaces
457 "let regexp = substitute(a:regexp, '\s\+', '.*', 'g')
458 let regexp = '.*' . substitute(a:regexp, '\s\+', '\\\&.*', 'g')
460 let regexp = a:regexp
464 for m in LatexBox_BibSearch(regexp)
466 let w = {'word': m['key'],
467 \ 'abbr': '[' . m['type'] . '] ' . m['author'] . ' (' . m['year'] . ')',
468 \ 'menu': m['title']}
470 " close braces if needed
471 if g:LatexBox_completion_close_braces && !s:NextCharsMatch('^\s*[,}]')
472 let w.word = w.word . '}'
481 " Complete Labels {{{
482 " the optional argument is the file name to be searched
483 function! s:CompleteLabels(regex, ...)
486 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
487 let file = fnamemodify(atp_MainFile, ":r") . ".aux"
492 " Fill in suggestions with the labels in the current buffer.
495 for line in filter(getline(1,'$'),'v:val =~ ''\\label{'.a:regex.'''')
496 " Trim down the comments
497 let line=substitute(line,'\\\@<!%.*','','')
498 " Add every remaining label to the list of suggestions
499 let index=match(line,'\\label{\zs')
500 let endbracket = match(line,'}',index)
502 while index > -1 && endbracket>-1
503 call add(suggestions,line[index : endbracket-1])
504 let line=line[endbracket+1 :]
505 let index=match(line,'\\label{\zs')
506 let endbracket = match(line,'}',index)
510 let g:test=copy(suggestions)
512 if empty(glob(file, 1))
517 "let suggestions = []
519 " search for the target equation number
520 for line in filter(readfile(file), 'v:val =~ ''^\\newlabel{\|^\\@input{''')
522 echomsg "matching line: " . line
524 " search for matching label
525 let matches = matchlist(line, '^\\newlabel{\(' . a:regex . '[^}]*\)}{{\([^}]*\)}{\([^}]*\)}.*}')
528 " also try to match label and number
529 let regex_split = split(a:regex)
530 if len(regex_split) > 1
531 let base = regex_split[0]
532 let number = escape(join(regex_split[1:], ' '), '.')
533 let matches = matchlist(line, '^\\newlabel{\(' . base . '[^}]*\)}{{\(' . number . '\)}{\([^}]*\)}.*}')
538 " also try to match number
539 let matches = matchlist(line, '^\\newlabel{\([^}]*\)}{{\(' . escape(a:regex, '.') . '\)}{\([^}]*\)}.*}')
544 let entry = {'word': matches[1], 'menu': '(' . matches[2] . ') [p.' . matches[3] . ']'}
546 if g:LatexBox_completion_close_braces && !s:NextCharsMatch('^\s*[,}]')
548 let entry = copy(entry)
549 let entry.abbr = entry.word
550 let entry.word = entry.word . '}'
552 let index=index(suggestions,matches[1])
554 let suggestions[index] = entry
556 call add(suggestions, entry)
560 " search for included files
561 let included_file = matchstr(line, '\m^\\@input{\zs[^}]*\ze}')
562 if included_file != ''
563 let included_file = LatexBox_kpsewhich(included_file)
564 call extend(suggestions, s:CompleteLabels(a:regex, included_file))
573 " Change Environment {{{
574 function! s:ChangeEnvPrompt()
576 let [env, lnum, cnum, lnum2, cnum2] = LatexBox_GetCurrentEnvironment(1)
578 let new_env = input('change ' . env . ' for: ', '', 'customlist,' . s:SIDWrap('GetEnvironmentList'))
583 if new_env == '\[' || new_env == '['
586 elseif new_env == '\(' || new_env == '('
590 let l:begin = '\begin{' . new_env . '}'
591 let l:end = '\end{' . new_env . '}'
594 if env == '\[' || env == '\('
595 let line = getline(lnum2)
596 let line = strpart(line, 0, cnum2 - 1) . l:end . strpart(line, cnum2 + 1)
597 call setline(lnum2, line)
599 let line = getline(lnum)
600 let line = strpart(line, 0, cnum - 1) . l:begin . strpart(line, cnum + 1)
601 call setline(lnum, line)
603 let line = getline(lnum2)
604 let line = strpart(line, 0, cnum2 - 1) . l:end . strpart(line, cnum2 + len(env) + 5)
605 call setline(lnum2, line)
607 let line = getline(lnum)
608 let line = strpart(line, 0, cnum - 1) . l:begin . strpart(line, cnum + len(env) + 7)
609 call setline(lnum, line)
614 function! s:GetEnvironmentList(lead, cmdline, pos)
617 if !exists("b:atp_LocalEnvironments")
620 let l:completion_list=atplib#Extend(g:atp_Environments,b:atp_LocalEnvironments)
622 for entry in l:completion_list
623 " let env = entry.word
624 if entry =~ '^' . a:lead
625 call add(suggestions, entry)
629 if len(suggestions) > 5
630 call sort(suggestions)
637 " Next Charaters Match {{{
638 function! s:NextCharsMatch(regex)
639 let rest_of_line = strpart(getline('.'), col('.') - 1)
640 return rest_of_line =~ a:regex
645 nmap <Plug>LatexChangeEnv :call <SID>ChangeEnvPrompt()<CR>
648 ftplugin/ATP_files/LatexBox_indent.vim [[[1
650 " Title: vim indent file for tex files.
651 " Author: David Munger (mungerd@gmail.com)
652 " Maintainer: Marcin Szamotulski
653 " Note: This file is a part of Automatic Tex Plugin for Vim.
654 " URL: https://launchpad.net/automatictexplugin
657 if exists("b:did_indent")
663 setlocal indentexpr=LatexBox_TexIndent()
664 setlocal indentkeys==\end,=\item,),],},o,O,0\\,!^F
666 let s:itemize_envs = ['itemize', 'enumerate', 'description']
668 " indent on \left( and on \(, but not on (
669 " indent on \left[ and on \[, but not on [
670 " indent on \left\{ and on \{, and on {
671 let s:open_pat = '\\begin\>\|\%(\\left\s*\)\=\\\=[{]\|\%(\\left\s*\|\\\)[[(]'
672 let s:close_pat = '\\end\>\|\%(\\right\s*\)\=\\\=[}]\|\%(\\right\s*\|\\\)[])]'
676 function! s:ComputeLevel(lnum_prev, open_pat, close_pat)
680 let line_prev = getline(a:lnum_prev)
683 let line_prev = substitute(line_prev, '\\\@<!%.*', '', 'g')
685 " find unmatched opening patterns on previous line
686 let n += len(substitute(substitute(line_prev, a:open_pat, "\n", 'g'), "[^\n]", '', 'g'))
687 let n -= len(substitute(substitute(line_prev, a:close_pat, "\n", 'g'), "[^\n]", '', 'g'))
689 " reduce indentation if current line starts with a closing pattern
690 if getline(v:lnum) =~ '^\s*\%(' . a:close_pat . '\)'
694 " compensate indentation if previous line starts with a closing pattern
695 if line_prev =~ '^\s*\%(' . a:close_pat . '\)'
704 function! LatexBox_TexIndent()
706 let lnum_prev = prevnonblank(v:lnum - 1)
714 let n += s:ComputeLevel(lnum_prev, s:open_pat, s:close_pat)
716 let n += s:ComputeLevel(lnum_prev, '\\begin{\%(' . join(s:itemize_envs, '\|') . '\)}',
717 \ '\\end{\%(' . join(s:itemize_envs, '\|') . '\)}')
719 " less shift for lines starting with \item
720 let item_here = getline(v:lnum) =~ '^\s*\\item'
721 let item_above = getline(lnum_prev) =~ '^\s*\\item'
722 if !item_here && item_above
724 elseif item_here && !item_above
728 return indent(lnum_prev) + n * &sw
732 " vim:fdm=marker:tw=85:ff=unix:noet:ts=8:sw=4:fdc=1
733 ftplugin/ATP_files/LatexBox_mappings.vim [[[1
735 " Author: David Mungerd
736 " Maintainer: Marcin Szamotulski
737 " URL: https://launchpad.net/automatictexplugin
738 " Note: This file is a part of Automatic Tex Plugin for Vim.
741 let s:loaded = ( !exists("s:loaded") ? 1 : s:loaded+1 )
743 " begin/end pairs {{{
744 nmap <buffer> % <Plug>LatexBox_JumpToMatch
745 xmap <buffer> % <Plug>LatexBox_JumpToMatch
746 " xmap <buffer> <C-%> <Plug>LatexBox_BackJumpToMatch
747 vmap <buffer> ie <Plug>LatexBox_SelectCurrentEnvInner
748 vmap <buffer> iE <Plug>LatexBox_SelectCurrentEnVInner
749 vmap <buffer> ae <Plug>LatexBox_SelectCurrentEnvOuter
750 omap <buffer> ie :normal vie<CR>
751 omap <buffer> ae :normal vae<CR>
752 vmap <buffer> im <Plug>LatexBox_SelectInlineMathInner
753 vmap <buffer> am <Plug>LatexBox_SelectInlineMathOuter
754 omap <buffer> im :normal vim<CR>
755 omap <buffer> am :normal vam<CR>
757 setlocal omnifunc=LatexBox_Complete
759 ftplugin/ATP_files/LatexBox_motion.vim [[[1
762 " Author: David Mnuger (latexbox vim plugin)
763 " Maintainer: Marcin Szamotulski
764 " Note: This file is a part of Automatic Tex Plugin for Vim.
765 " URL: https://launchpad.net/automatictexplugin
768 " Some things is enough to source once
769 let s:sourced = exists("s:sourced") ? 1 : 0
773 " s:HasSyntax(syntaxName, [line], [col])
774 function! s:HasSyntax(syntaxName, ...)
775 let line = a:0 >= 1 ? a:1 : line('.')
776 let col = a:0 >= 2 ? a:2 : col('.')
777 return index(map(synstack(line, col), 'synIDattr(v:val, "name") == "' . a:syntaxName . '"'), 1) >= 0
781 " Search and Skip Comments {{{
782 " s:SearchAndSkipComments(pattern, [flags], [stopline])
783 function! s:SearchAndSkipComments(pat, ...)
784 let flags = a:0 >= 1 ? a:1 : ''
785 let stopline = a:0 >= 2 ? a:2 : 0
786 let saved_pos = getpos('.')
789 let ret = search(a:pat, flags, stopline)
792 " do not match at current position if inside comment
793 let flags = substitute(flags, 'c', '', 'g')
795 " keep searching while in comment
796 while LatexBox_InComment()
797 let ret = search(a:pat, flags, stopline)
805 " if no match found, restore position
806 keepjumps call setpos('.', saved_pos)
813 " begin/end pairs {{{
815 " s:JumpToMatch(mode, [backward])
816 " - search backwards if backward is given and nonzero
817 " - search forward otherwise
819 function! s:JumpToMatch(mode, ...)
827 let sflags = backward ? 'cbW' : 'cW'
829 " selection is lost upon function call, reselect
834 " open/close pairs (dollars signs are treated apart)
835 let open_pats = ['{', '\[', '(', '\\begin\>', '\\left\>']
836 let close_pats = ['}', '\]', ')', '\\end\>', '\\right\>']
837 let dollar_pat = '\\\@<!\$'
838 let two_dollar_pat = '\\\@<!\$\$'
840 let saved_pos = getpos('.')
842 " move to the left until not on alphabetic characters
843 call search('\A', 'cbW', line('.'))
845 " go to next opening/closing pattern on same line
846 if !s:SearchAndSkipComments(
847 \ '\m\C\%(' . join(open_pats + close_pats + [dollar_pat], '\|') . '\)',
849 " abort if no match or if match is inside a comment
850 keepjumps call setpos('.', saved_pos)
854 let rest_of_line = strpart(getline('.'), col('.') - 1)
856 " match for '$' pairs
857 if rest_of_line =~ '^\$'
859 " check if next character is in inline math
860 let [lnum, cnum] = searchpos('.', 'nW')
861 if lnum && s:HasSyntax('texMathZoneX', lnum, cnum)
862 call s:SearchAndSkipComments(dollar_pat, 'W')
863 elseif !s:HasSyntax('texMathZoneY', lnum, cnum)
864 call s:SearchAndSkipComments(dollar_pat, 'bW')
867 if lnum && s:HasSyntax('texMathZoneY', lnum, cnum)
868 call s:SearchAndSkipComments(two_dollar_pat, 'W')
870 call s:SearchAndSkipComments(two_dollar_pat, 'bW')
875 for i in range(len(open_pats))
876 let open_pat = open_pats[i]
877 let close_pat = close_pats[i]
879 if rest_of_line =~ '^\C\%(' . open_pat . '\)'
880 " if on opening pattern, go to closing pattern
881 call searchpair('\C' . open_pat, '', '\C' . close_pat, 'W', 'LatexBox_InComment()')
883 elseif rest_of_line =~ '^\C\%(' . close_pat . '\)'
884 " if on closing pattern, go to opening pattern
885 call searchpair('\C' . open_pat, '', '\C' . close_pat, 'bW', 'LatexBox_InComment()')
894 nnoremap <silent> <Plug>LatexBox_JumpToMatch :call <SID>JumpToMatch('n')<CR>
895 vnoremap <silent> <Plug>LatexBox_JumpToMatch :<C-U>call <SID>JumpToMatch('v')<CR>
896 nnoremap <silent> <Plug>LatexBox_BackJumpToMatch :call <SID>JumpToMatch('n', 1)<CR>
897 vnoremap <silent> <Plug>LatexBox_BackJumpToMatch :<C-U>call <SID>JumpToMatch('v', 1)<CR>
900 " select inline math {{{
901 " s:SelectInlineMath(seltype)
902 " where seltype is either 'inner' or 'outer'
903 function! s:SelectInlineMath(seltype)
905 let saved_pos = getpos('.')
907 let synstack = map(synstack(line("."),col(".")), 'synIDattr(v:val, "name")')
909 if len(filter(synstack, "v:val =~ '^texMathZone[A-L]S\\?'"))
910 call s:SelectCurrentEnv(a:seltype)
914 let ZoneX_pat_O = '\\\@<!\$'
915 let ZoneX_pat_C = '\\\@<!\$'
916 let ZoneY_pat_O = '\\\@<!\$\$'
917 let ZoneY_pat_C = a:seltype == 'inner' ? '\\\@<!\$\$' : '\\\@<!\$\$'
918 let ZoneV_pat_O = '\\\@<!\\('
919 let ZoneV_pat_C = a:seltype == 'inner' ? '\\\@<!\\)' : '\\\@<!\\\zs)'
920 let ZoneW_pat_O = '\\\@<!\\\['
921 let ZoneW_pat_C = a:seltype == 'inner' ? '\\\@<!\\\]' : '\\\@<!\\\zs\]'
923 if ( s:HasSyntax('texMathZoneV', line("."), max([1,col(".")-1])) ||
924 \ s:HasSyntax('texMathZoneW', line("."), max([1,col(".")-1])) ||
925 \ s:HasSyntax('texMathZoneX', line("."), max([1,col(".")-1])) ||
926 \ s:HasSyntax('texMathZoneY', line("."), max([1,col(".")-1])) && b:atp_TexFlavor == 'plaintex' ) &&
929 elseif ( s:HasSyntax('texMathZoneV', line("."), max([1,col(".")-2])) ||
930 \ s:HasSyntax('texMathZoneW', line("."), max([1,col(".")-2])) ||
931 \ s:HasSyntax('texMathZoneY', line("."), max([1,col(".")-2])) && b:atp_TexFlavor == 'plaintex' ) &&
937 let math_zones = ( b:atp_TexFlavor == 'plaintex' ? [ 'V', 'W', 'X', 'Y'] : [ 'V', 'W', 'X'] )
939 if s:HasSyntax('texMathZone'. L, line(".")) ||
940 \ s:HasSyntax('texMathZone'. L, line("."), max([1, col(".")-1]))
941 call s:SearchAndSkipComments(Zone{L}_pat_O, 'cbW')
948 call cursor(saved_pos[1], saved_pos[2])
952 if a:seltype == 'inner'
953 if zone =~ '^V\|W$' || zone == 'Y' && b:atp_TexFlavor == 'plaintex'
958 if getline(".")[col(".")-1] == ' '
963 if visualmode() ==# 'V'
969 call s:SearchAndSkipComments(Zone{zone}_pat_C, 'W')
971 if a:seltype == 'inner'
972 if getline(".")[col(".")-2] == ' '
976 call cursor(line("."),col(".")-1)
978 call cursor(line(".")-1, len(getline(line(".")-1)))
983 if a:seltype == 'outer' && zone == 'Y'
984 call cursor(line("."),col(".")+1)
989 vnoremap <silent> <Plug>LatexBox_SelectInlineMathInner :<C-U>call <SID>SelectInlineMath('inner')<CR>
990 vnoremap <silent> <Plug>LatexBox_SelectInlineMathOuter :<C-U>call <SID>SelectInlineMath('outer')<CR>
994 " syntax groups 'texDocZone' and 'texSectionZone' need to be synchronized
995 " before ':syntax sync fromstart' which is quite slow. It is better to provide
996 " other method of doing this. (If s:SelectSyntax is not syncing the syntax
997 " then the behaviour is unpredictable).
998 function! s:SelectSyntax(syntax)
1000 " mark the current position
1003 let synstack = map(synstack(line("."),col(".")), 'synIDattr(v:val, "name")')
1004 " there are better method for texDocZone and texSectionZone:
1005 call filter(synstack, "v:val != 'texDocZone' && v:val != 'texSectionZone'")
1011 if a:syntax == 'inner'
1013 let len = len(synstack)
1014 let syntax = synstack[max([0, len-1])]
1016 elseif a:syntax == 'outer'
1017 let syntax = synstack[0]
1020 let syntax = a:syntax
1026 let save_pos = getpos(".")
1029 if !count(map(synstack(line("."),col(".")), 'synIDattr(v:val, "name")'), syntax)
1034 while count(map(synstack(line("."),col(".")), 'synIDattr(v:val, "name")'), syntax)
1036 " for some syntax groups do not move to previous line
1037 if col(".") == 1 && count(['texStatement', 'texTypeSize'], syntax)
1045 if getpos(".")[2] < len(getline("."))
1046 call cursor(line("."),col(".")+1)
1049 call cursor(line(".")+1, 1)
1053 if visualmode() ==# 'V'
1061 call cursor(save_pos[1], save_pos[2])
1062 while count(map(synstack(line("."),max([1, min([col("."), len(getline("."))])])), 'synIDattr(v:val, "name")'), syntax) || len(getline(".")) == 0
1064 " for some syntax groups do not move to next line
1065 if col(".") == len(getline(".")) && count(['texStatement', 'texTypeSize'], syntax)
1072 if len(getline(".")) == 0
1073 call cursor(line(".")-1,len(getline(line(".")-1)))
1075 if count(['texParen', 'texLength', 'Delimiter', 'texStatement', 'texTypeSize', 'texRefZone', 'texSectionMarker', 'texTypeStyle'], syntax)
1077 call cursor(line("."),col(".")-1)
1080 call cursor(line(".")-1,len(getline(line(".")-1)))
1083 elseif count(['texMathZoneV', 'texMathZoneW', 'texMathZoneY'], syntax)
1084 call cursor(line("."),col(".")+1)
1092 " select current environment {{{
1093 function! s:SelectCurrentEnv(seltype)
1094 let [env, lnum, cnum, lnum2, cnum2] = LatexBox_GetCurrentEnvironment(1)
1095 call cursor(lnum, cnum)
1096 if a:seltype == 'inner'
1098 call search('\\.\_\s*\S', 'eW')
1100 " call search('}\%(\_\s*\[\_[^]]*\]\)\?\%(\_\s*\\label\s*{[^}]*}\)\?\_\s*\S', 'eW')
1101 call search('}\%(\_\s*\[\_[^]]*\]\)\?\_\s*\S', 'eW')
1104 if visualmode() ==# 'V'
1109 call cursor(lnum2, cnum2)
1110 if a:seltype == 'inner'
1111 call search('\S\_\s*', 'bW')
1116 call search('}', 'eW')
1121 function! s:SelectCurrentEnV()
1122 call s:SelectCurrentEnv('inner')
1124 call s:JumpToMatch('n', 1)
1130 " Jump to the next braces {{{
1132 function! LatexBox_JumpToNextBraces(backward)
1140 if search('[][}{]', flags) > 0
1143 let prev = strpart(getline('.'), col('.') - 2, 1)
1144 let next = strpart(getline('.'), col('.') - 1, 1)
1145 if next =~ '[]}]' && prev !~ '[][{}]'
1153 " Highlight Matching Pair {{{
1154 " TODO: Redefine NoMatchParen and DoMatchParen functions to handle
1155 " s:HighlightMatchingPair function.
1156 " TODO: do not match for \begin{document}:\end{document}
1157 " or limit matches to the window (anyway it is done every time the
1159 " winheight(0) returns window height
1160 " winsaveview()['topline'] returns the top line
1161 function! s:HighlightMatchingPair()
1165 if LatexBox_InComment()
1169 " let open_pats = ['\\begin\>\ze\%(\s*{\s*document\s*}\)\@!', '\\left\>', '\c\\bigg\=\>\%((\|{\|\\{\|\[\)' ]
1170 " let close_pats = ['\\end\>\ze\%(\s*{\s*document\s*}\)\@!', '\\right\>', '\c\\bigg\=\>\%()\|}\|\\}\|\]\)' ]
1171 let open_pats = ['\\begin\>\ze', '\\left\>', '\c\\bigg\=l\=\>\%((\|{\|\\{\|\[\)' ]
1172 let close_pats = ['\\end\>\ze', '\\right\>', '\c\\bigg\=r\=\>\%()\|}\|\\}\|\]\)' ]
1173 let dollar_pat = '\\\@<!\$'
1174 let two_dollar_pat = '\\\@<!\$\$'
1176 let saved_pos = getpos('.')
1178 if getline('.')[col('.') - 1] == '$'
1180 if strpart(getline('.'), col('.') - 2, 1) == '\'
1185 let lnum = line('.')
1188 " check if next or previous character is \$
1189 let two_dollars = ( getline('.')[col('.') - 2] == '$' ? 'p' :
1190 \ ( getline('.')[col('.') ] == '$' ? 'n' : '0' ) )
1192 if two_dollars == '0' || b:atp_TexFlavor == 'tex'
1194 " check if next character is in inline math
1195 let [lnum2, cnum2] = searchpos('.', 'nW')
1196 if lnum2 && s:HasSyntax('texMathZoneX', lnum2, cnum2)
1197 call s:SearchAndSkipComments(dollar_pat, 'W')
1199 call s:SearchAndSkipComments(dollar_pat, 'bW')
1202 execute '2match MatchParen /\%(\%' . lnum . 'l\%' . cnum . 'c\$'
1203 \ . '\|\%' . line('.') . 'l\%' . col('.') . 'c\$\)/'
1205 elseif b:atp_TexFlavor == 'plaintex'
1207 " check if next character is in inline math
1208 if two_dollars == 'n'
1209 call cursor(line('.'), col('.')+1)
1211 " position of the openning \$\$
1212 let cnum = col('.')-1
1213 let [lnum2, cnum2] = searchpos( '.' , 'nW')
1214 if lnum2 && s:HasSyntax('texMathZoneY', lnum2, cnum2)
1215 call s:SearchAndSkipComments(two_dollar_pat, 'W')
1217 " searching backward needs the cursor to be placed
1218 " before closing $$.
1219 if col(".") - 2 >= 1
1220 call cursor(line("."), col(".")-2)
1222 call cursor(line(".")-1, 1)
1223 call cursor(line("."), col("$"))
1225 call s:SearchAndSkipComments(two_dollar_pat, 'bW')
1228 let cnum_E = col('.')
1229 let cnum_Ee = cnum_E+1
1230 execute '2match MatchParen /\%(\%' . lnum . 'l\%' . cnum . 'c\$'
1231 \ . '\|\%' . lnum . 'l\%' . cnum_e . 'c\$'
1232 \ . '\|\%' . line('.') . 'l\%' . cnum_E . 'c\$'
1233 \ . '\|\%' . line('.') . 'l\%' . cnum_Ee . 'c\$\)/'
1240 " find first non-alpha character to the left on the same line
1241 let [lnum, cnum] = searchpos('\A', 'cbW', line('.'))
1242 if strpart(getline(lnum), 0, cnum) =~ '\\\%(begin\|end\){[^}]*}\=$'
1243 let [lnum, cnum] = searchpos('\\', 'cbW', line('.'))
1246 let delim = matchstr(getline(lnum), '^\m\(' . join(open_pats + close_pats, '\|') . '\)', cnum - 1)
1249 call setpos('.', saved_pos)
1253 for i in range(len(open_pats))
1254 let open_pat = open_pats[i]
1255 let close_pat = close_pats[i]
1257 if delim =~# '^' . open_pat
1258 " if on opening pattern, go to closing pattern
1259 let stop_line=winheight(0)+winsaveview()['topline']
1260 call searchpair('\C' . open_pat, '', '\C' . close_pat, 'W', 'LatexBox_InComment()', stop_line)
1261 execute '2match MatchParen /\%(\%' . lnum . 'l\%' . cnum . 'c' . open_pats[i]
1262 \ . '\|\%' . line('.') . 'l\%' . col('.') . 'c' . close_pats[i] . '\)/'
1264 elseif delim =~# '^' . close_pat
1265 " if on closing pattern, go to opening pattern
1266 let stop_line=winsaveview()['topline']
1267 if close_pat =~ '\\end'
1268 call searchpair('\C\\begin\>', '', '\C\\end\>\zs' , 'bW', 'LatexBox_InComment()', stop_line)
1270 call searchpair('\C' . open_pat, '', '\C' . close_pat, 'bW', 'LatexBox_InComment()', stop_line)
1272 execute '2match MatchParen /\%(\%' . line('.') . 'l\%' . col('.') . 'c' . open_pats[i]
1273 \ . '\|\%' . lnum . 'l\%' . cnum . 'c' . close_pats[i] . '\)/'
1279 call setpos('.', saved_pos)
1283 " select current paragraph {{{
1284 function! s:SelectCurrentParagraph(seltype)
1285 if a:seltype == "inner"
1286 let [ bline, bcol ] = searchpos('\%(^\s*$\|^[^%]*\%(\ze\\par\>\|\ze\\newline\>\|\\end\s*{[^}]*}\s*\|\\begin\s*{[^}]*}\s*\%(\%({\|\[\)[^]}]*\%(\]\|}\)\)\=\s*\%({[^}]*}\)\=\s*\%(\%(\\label\s*{[^}]*}\)\s*\%(\\footnote\s*\%(\n\|[^}]\)*}\)\=\|\s*\%(\\footnote\s*\%(\n\|[^}]\)*}\)\s*\%(\\label\s*{[^}]*}\)\=\)\=\)\|\\item\%(\s*\[[^\]]*\]\)\=\|\\\%(part\*\=\|chapter\*\=\|section\*\=\|subsection\*\=\|subsubsection\*\=\|paragraph\*\=\|subparagraph\*\=\)\s*\%(\[[^]]*\]\)\=\s*{[^}]*}\s*\%({^}]*}\)\=\|\\\@<!\\\]\s*$\|\\\@<!\$\$\s*$\|\\\\\*\=\)', 'ebcnW')
1287 let [ eline, ecol ] = searchpos('\%(^\s*$\|^[^%]*\%(\zs\\par\>\|\zs\\newline\>\|\\end\s*{\|\\begin\s*{[^}]*}\s*\%(\[[^]]*\]\)\=\)\|\\item\|\\\%(part\*\=\|chapter\*\=\|section\*\=\|subsection\*\=\|\<subsubsection\*\=\|\<paragraph\*\=\|\<subparagraph\*\=\){[^}]*}\s*\%(\[[^]]*\]\)\=\s*\%({^}]*}\)\=\|^\s*\\\@<!\\\[\|^\s*\\\@<!\$\$\|\\\\\*\=\)', 'nW')
1288 " inner type ends and start with \[:\] if \[ is at the begining of
1289 " line (possibly with white spaces) and \] is at the end of line
1290 " (possibly with white spaces, aswell).
1291 " This can cause some asymetry. So I prefer the simpler solution: \[:\]
1292 " alwasy ends inner paragraph. But how I use tex it is 'gantz egal'
1293 " but this solution can make a difference for some users, so I keep
1297 let [ bline, bcol ] = searchpos('^\s*$\|^[^%]*\zs\\par\>', 'bcnW')
1298 let [ eline, ecol ] = searchpos('^\s*$\|^[^%]*\zs\\par\>', 'nW')
1300 " let [ g:bline, g:bcol] = deepcopy([ bline, bcol])
1301 " let [ g:eline, g:ecol] = deepcopy([ eline, ecol])
1302 if getline(bline) =~ '\\par\|\\newline'
1303 " move to the beginning of \par
1306 " or to the begining of line
1310 if getline(eline) =~ '\\par'
1316 call cursor(bline, bcol)
1318 execute "normal " . bmove
1322 if visualmode() ==# 'V'
1329 call cursor(eline, ecol)
1330 execute "normal " . emove
1334 " {{{ select comment
1335 " This only works with lines which begin with the comment sign '%'.
1336 function! SelectComment()
1337 if getline(".") !~ '^\s*%'
1340 call search('^\(\s*%.*\n\)\@<!\zs\(\s*%\)', "cbW")
1341 if visualmode() ==# 'V'
1346 call search('\%(^\s*%.*\zs\n\)\%(^\s*%\)\@!', "cW")
1350 " {{{ LatexBox_HighlightPairs augroup
1351 augroup LatexBox_HighlightPairs
1352 " Replace all matchparen autocommands
1354 au! CursorMoved *.tex call s:HighlightMatchingPair()
1357 " Highlight bold and italic, by M. Szamotulski
1358 " (to add: optionaly only in gui)
1359 " this function should do that for every \texbf on the screen
1362 function! HighlightEmphText()
1364 let saved_pos = getpos('.')
1366 let top_line = winsaveview()['topline']
1367 let end_line = top_line + winheight(0)
1369 call cursor(top_line, 1)
1371 keepjumps let [start_lnum, start_cnum] = searchpos('\\\%(textbf{\|bf\)\zs', 'W', end_line)
1372 let [lnum, cnum] = copy([ start_lnum, start_cnum])
1374 " if there are no matches, return.
1375 if [ lnum, cnum] == [0, 0]
1379 while start_lnum <= end_line && [lnum, cnum] != [0, 0]
1381 let [lnum, cnum] = copy([ start_lnum, start_cnum])
1383 if [lnum, cnum] == [ 0, 0]
1384 keepjumps call setpos( '.', saved_pos)
1388 " echomsg lnum . " " . cnum
1389 while s:HasSyntax('texMatcher', lnum, cnum)
1390 if cnum < len(getline(lnum))
1399 let stop_lnum = lnum-1
1400 let stop_cnum = len(getline(stop_lnum))
1402 let stop_lnum = lnum
1403 let stop_cnum = cnum
1411 call matchadd( 'textBold', '\%>' . start_lnum . 'l\%>' . start_cnum . 'c' . '\%<' . stop_lnum . 'l\%<' . stop_cnum . 'c')
1413 let [start_lnum, start_cnum] = searchpos('\\\%(textbf{\|bf\)\zs', 'W', end_line)
1417 keepjumps call setpos( '.', saved_pos)
1419 " return [start_lnum, start_cnum, stop_lnum, stop_cnum]
1421 " the 2match function can be run once:
1422 " call s:HighlightEmphText()
1423 " augroup HighlightEmphText
1424 " " Replace all matchparen autocommands
1425 " autocmd CursorMoved *.tex call HighlightEmphText()
1431 vnoremap <silent> <buffer> <Plug>SelectInnerSyntax <ESC>:<C-U>call <SID>SelectSyntax('inner')<CR>
1432 vnoremap <silent> <buffer> <Plug>SelectOuterSyntax <ESC>:<C-U>call <SID>SelectSyntax('outer')<CR>
1433 vnoremap <silent> <Plug>LatexBox_SelectCurrentEnvInner :<C-U>call <SID>SelectCurrentEnv('inner')<CR>
1434 vnoremap <silent> <Plug>LatexBox_SelectCurrentEnVInner :<C-U>call <SID>SelectCurrentEnV()<CR>
1435 vnoremap <silent> <Plug>LatexBox_SelectCurrentEnvOuter :<C-U>call <SID>SelectCurrentEnv('outer')<CR>
1436 vnoremap <silent> <Plug>ATP_SelectCurrentParagraphInner :<C-U>call <SID>SelectCurrentParagraph('inner')<CR>
1437 vnoremap <silent> <Plug>ATP_SelectCurrentParagraphOuter :<C-U>call <SID>SelectCurrentParagraph('outer')<CR>
1438 vmap <silent><buffer> <Plug>vSelectComment :<C-U>call SelectComment()<CR>
1439 ftplugin/ATP_files/LatexBox_latexmk.vim [[[1
1441 " Author: David Munger (mungerd@gmail.com)
1442 " Maintainer: Marcin Szamotulski
1443 " Note: This file is a part of Automatic Tex Plugin for Vim.
1444 " URL: https://launchpad.net/automatictexplugin
1447 let s:sourced = exists("s:sourced") ? 1 : 0
1451 function! s:GetSID()
1452 return matchstr(expand('<sfile>'), '\zs<SNR>\d\+_\ze.*$')
1454 let s:SID = s:GetSID()
1455 function! s:SIDWrap(func)
1456 return s:SID . a:func
1460 " dictionary of latexmk PID's (basename: pid)
1461 let s:latexmk_running_pids = {}
1464 function! s:LatexmkSetPID(basename, pid)
1465 let s:latexmk_running_pids[a:basename] = a:pid
1470 function! s:LatexmkCallback(basename, status)
1471 "let pos = getpos('.')
1473 echomsg "latexmk exited with status " . a:status
1475 echomsg "latexmk finished"
1477 call remove(s:latexmk_running_pids, a:basename)
1478 call LatexBox_LatexErrors(0, a:basename)
1479 "call setpos('.', pos)
1484 function! LatexBox_Latexmk(force)
1486 if empty(v:servername)
1487 echoerr "cannot run latexmk in background without a VIM server"
1491 let basename = LatexBox_GetTexBasename(1)
1493 if has_key(s:latexmk_running_pids, basename)
1494 echomsg "latexmk is already running for `" . fnamemodify(basename, ':t') . "'"
1498 let callsetpid = s:SIDWrap('LatexmkSetPID')
1499 let callback = s:SIDWrap('LatexmkCallback')
1501 let l:options = '-' . g:LatexBox_output_type . ' -quiet ' . g:LatexBox_latexmk_options
1503 let l:options .= ' -g'
1505 let l:options .= " -e '$pdflatex =~ s/ / -file-line-error /'"
1506 let l:options .= " -e '$latex =~ s/ / -file-line-error /'"
1508 " callback to set the pid
1509 let vimsetpid = g:vim_program . ' --servername ' . v:servername . ' --remote-expr ' .
1510 \ shellescape(callsetpid) . '\(\"' . fnameescape(basename) . '\",$$\)'
1513 let cmd = 'cd ' . shellescape(LatexBox_GetTexRoot()) . ' ; latexmk ' . l:options
1514 \ . ' ' . shellescape(LatexBox_GetMainTexFile())
1516 " callback after latexmk is finished
1517 let vimcmd = g:vim_program . ' --servername ' . v:servername . ' --remote-expr ' .
1518 \ shellescape(callback) . '\(\"' . fnameescape(basename) . '\",$?\)'
1520 silent execute '! ( ' . vimsetpid . ' ; ( ' . cmd . ' ) ; ' . vimcmd . ' ) &'
1525 function! LatexBox_LatexmkStop()
1527 let basename = LatexBox_GetTexBasename(1)
1529 if !has_key(s:latexmk_running_pids, basename)
1530 echomsg "latexmk is not running for `" . fnamemodify(basename, ':t') . "'"
1534 call s:kill_latexmk(s:latexmk_running_pids[basename])
1536 call remove(s:latexmk_running_pids, basename)
1537 echomsg "latexmk stopped for `" . fnamemodify(basename, ':t') . "'"
1542 function! s:kill_latexmk(gpid)
1544 " This version doesn't work on systems on which pkill is not installed:
1545 "!silent execute '! pkill -g ' . pid
1547 " This version is more portable, but still doesn't work on Mac OS X:
1548 "!silent execute '! kill `ps -o pid= -g ' . pid . '`'
1550 " Since 'ps' behaves differently on different platforms, we must use brute force:
1551 " - list all processes in a temporary file
1552 " - match by process group ID
1555 let tmpfile = tempname()
1556 silent execute '!ps x -o pgid,pid > ' . tmpfile
1557 for line in readfile(tmpfile)
1558 let pid = matchstr(line, '^\s*' . a:gpid . '\s\+\zs\d\+\ze')
1563 call delete(tmpfile)
1565 silent execute '! kill ' . join(pids)
1570 " kill_all_latexmk {{{
1571 function! s:kill_all_latexmk()
1572 for gpid in values(s:latexmk_running_pids)
1573 call s:kill_latexmk(gpid)
1575 let s:latexmk_running_pids = {}
1580 function! LatexBox_LatexmkClean(cleanall)
1583 let l:options = '-C'
1585 let l:options = '-c'
1588 let l:cmd = 'cd ' . shellescape(LatexBox_GetTexRoot()) . ' ; latexmk ' . l:options
1589 \ . ' ' . shellescape(LatexBox_GetMainTexFile())
1591 silent execute '! ' . l:cmd
1592 echomsg "latexmk clean finished"
1597 function! LatexBox_LatexmkStatus(detailed)
1600 if empty(s:latexmk_running_pids)
1601 echo "latexmk is not running"
1604 for [basename, pid] in items(s:latexmk_running_pids)
1608 let plist .= fnamemodify(basename, ':t') . ':' . pid
1610 echo "latexmk is running (" . plist . ")"
1613 let basename = LatexBox_GetTexBasename(1)
1614 if has_key(s:latexmk_running_pids, basename)
1615 echo "latexmk is running"
1617 echo "latexmk is not running"
1625 " LatexBox_LatexErrors(jump, [basename])
1626 function! LatexBox_LatexErrors(jump, ...)
1628 let log = a:1 . '.log'
1630 let log = LatexBox_GetLogFile()
1634 execute 'cfile ' . fnameescape(log)
1636 execute 'cgetfile ' . fnameescape(log)
1643 command! -buffer Latexmk call LatexBox_Latexmk(0)
1644 command! -buffer LatexmkForce call LatexBox_Latexmk(1)
1645 command! -buffer LatexmkClean call LatexBox_LatexmkClean(0)
1646 command! -buffer LatexmkCleanAll call LatexBox_LatexmkClean(1)
1647 command! -buffer LatexmkStatus call LatexBox_LatexmkStatus(0)
1648 command! -buffer LatexmkStatusDetailed call LatexBox_LatexmkStatus(1)
1649 command! -buffer LatexmkStop call LatexBox_LatexmkStop()
1650 command! -buffer LatexErrors call LatexBox_LatexErrors(1)
1653 autocmd VimLeavePre * call <SID>kill_all_latexmk()
1655 " vim:fdm=marker:ff=unix:noet:ts=4:sw=4
1656 ftplugin/ATP_files/LatexBox_variables.vim [[[1
1658 " Author: David Munger
1659 " Maintainer: Marcin Szamotulski
1660 " Note: This file is a part of Automatic Tex Plugin for Vim.
1661 " URL: https://launchpad.net/automatictexplugin
1664 let s:sourced = exists("s:sourced") ? 1 : 0
1669 " Latex_Box variables used by tools from David Munger.
1670 if g:atp_LatexBox == 1 || (g:atp_check_if_LatexBox && len(split(globpath(&rtp,'ftplugin/tex_LatexBox.vim'))))
1672 if !exists('g:LatexBox_cite_pattern')
1673 let g:LatexBox_cite_pattern = '\\cite\(p\|t\)\?\*\?\_\s*{'
1676 if !exists('g:LatexBox_ref_pattern')
1677 let g:LatexBox_ref_pattern = '\\v\?\(eq\|page\)\?ref\*\?\_\s*{'
1680 let g:LatexBox_complete_with_brackets = 1
1681 let g:LatexBox_bibtex_wild_spaces = 1
1683 let g:LatexBox_completion_environments = [
1684 \ {'word': 'itemize', 'menu': 'bullet list' },
1685 \ {'word': 'enumerate', 'menu': 'numbered list' },
1686 \ {'word': 'description', 'menu': 'description' },
1687 \ {'word': 'center', 'menu': 'centered text' },
1688 \ {'word': 'figure', 'menu': 'floating figure' },
1689 \ {'word': 'table', 'menu': 'floating table' },
1690 \ {'word': 'equation', 'menu': 'equation (numbered)' },
1691 \ {'word': 'align', 'menu': 'aligned equations (numbered)' },
1692 \ {'word': 'align*', 'menu': 'aligned equations' },
1693 \ {'word': 'document' },
1694 \ {'word': 'abstract' },
1697 let g:LatexBox_completion_commands = [
1698 \ {'word': '\begin{' },
1699 \ {'word': '\end{' },
1700 \ {'word': '\item' },
1701 \ {'word': '\label{' },
1702 \ {'word': '\ref{' },
1703 \ {'word': '\eqref{eq:' },
1704 \ {'word': '\cite{' },
1705 \ {'word': '\nonumber' },
1706 \ {'word': '\bibliography' },
1707 \ {'word': '\bibliographystyle' },
1711 ftplugin/ATP_files/project.vim [[[1
1713 " Author: Marcin Szamotulski
1714 " Description: A vim script which stores values of variables in a project script.
1715 " It is read, and written via autocommands.
1716 " Note: This file is a part of Automatic Tex Plugin for Vim.
1717 " URL: https://launchpad.net/automatictexplugin
1720 let s:sourced = exists("s:sourced") ? 1 : 0
1725 " If the user set g:atp_RelativePath
1726 " if exists("g:atp_RelativePath") && g:atp_RelativePath
1730 let s:file = expand('<sfile>:p')
1732 " This gives some debug info: which project scripts are loaded, loading time,
1733 " which project scripts are written.
1734 " Debug File: /tmp/ATP_ProjectScriptDebug.vim / only for s:WriteProjectScript() /
1735 if !exists("g:atp_debugProject")
1736 let g:atp_debugProject = 0
1738 if !exists("g:atp_debugLPS")
1739 " debug <SID>LoadProjectScript (project.vim)
1740 let g:atp_debugLPS = 0
1742 if !exists("g:atp_RelativePath")
1743 let g:atp_RelativePath = 1
1745 " Also can be set in vimrc file or atprc file! (tested)
1746 " The default value (0) is set in options.vim
1749 let s:windows = has("win16") || has("win32") || has("win64") || has("win95")
1751 " This variable is set if the projectr script was loaded by s:LoadScript()
1753 " s:project_Load = { type : 0/1 }
1755 if !exists("s:project_Load")
1756 " Load once in s:LoadScript() function
1757 let s:project_Load = {}
1758 let g:project_Load = s:project_Load
1760 if !exists("g:atp_CommonScriptDirectory")
1761 let g:atp_CommonScriptDirectory = expand('<sfile>:p:h')
1763 if !isdirectory(g:atp_CommonScriptDirectory)
1764 " Make common script dir if it doesn't exist (and all intermediate directories).
1765 call mkdir(g:atp_CommonScriptDirectory, "p")
1768 " Mimic names of vim view files
1769 let s:common_project_script = s:windows ? g:atp_CommonScriptDirectory . '\common_var.vim' : g:atp_CommonScriptDirectory . '/common_var.vim'
1771 " These local variables will be saved:
1772 let g:atp_cached_local_variables = [
1774 \ 'b:atp_ProjectScript',
1775 \ 'b:atp_LocalCommands', 'b:atp_LocalEnvironments',
1776 \ 'b:atp_LocalColors',
1777 \ 'b:TreeOfFiles', 'b:ListOfFiles',
1778 \ 'b:TypeDict', 'b:LevelDict',
1780 " Note: b:atp_ProjectDir is not here by default by the following reason: it is
1781 " specific to the host, without it sharing the project file is possible.
1782 " b:atp_PackageList is another variable that could be put into project script.
1784 " This are common variable to all tex files.
1785 let g:atp_cached_common_variables = ['g:atp_latexpackages', 'g:atp_latexclasses', 'g:atp_Library']
1788 " Functions: (soure once)
1791 "{{{ s:LoadScript(), :LoadScript, autocommads
1792 " s:LoadScript({bang}, {project_script}, {type}, {load_variables}, [silent], [ch_load])
1794 " a:bang == "!" ignore texmf tree and ignore b:atp_ProjectScript, g:atp_ProjectScript
1796 " a:project_script file to source
1797 " a:type = 'local'/'global'
1798 " a:load_variabels load variables after loading project script
1799 " can be used on startup to load variables which depend
1800 " on things set in project script.
1801 " a:1 = 'silent'/'' echo messages
1802 " a:2 = ch_load check if project script was already loaded
1803 " a:3 = ignore ignore b:atp_ProjectScript and g:atp_ProjectScript variables
1805 function! <SID>LoadScript(bang, project_script, type, load_variables, ...) "{{{
1807 if g:atp_debugProject
1808 redir! >> /tmp/ATP_ProjectScriptDebug.vim
1809 let hist_time = reltime()
1811 echomsg "ATP_ProjectScript: LoadScript " . a:type . " file " . string(a:project_script)
1814 let silent = a:0 >= 1 ? a:1 : "0"
1815 let silent = silent || silent == "silent" ? "silent" : ""
1816 let ch_load = a:0 >= 2 ? a:2 : 0
1817 let ignore = a:0 >= 3 ? a:3 : 0
1819 " Is project script on/off
1820 " The local variable overrides the global ones!
1823 " When starting the vim b:atp_ProjectScript might not be yet defined (will be
1824 " defined later, and g:atp_ProjectScript might already be defined, so not always
1825 " global variables override local ones).
1827 " Global variable overrides local one
1828 if !ignore && ( exists("g:atp_ProjectScript") && !g:atp_ProjectScript || exists("b:atp_ProjectScript") && ( !b:atp_ProjectScript && (!exists("g:atp_ProjectScript") || exists("g:atp_ProjectScript") && !g:atp_ProjectScript )) )
1829 exe silent . ' echomsg "ATP LoadScirpt: not loading project script."'
1831 if g:atp_debugProject
1832 echomsg "b:atp_ProjectScript=" . ( exists("b:atp_ProjectScript") ? b:atp_ProjectScript : -1 ) . " g:atp_ProjectScript=" . ( exists("g:atp_ProjectScript") ? g:atp_ProjectScript : -1 ) . "\n"
1833 echomsg "ATP_ProjectScript : END " !ignore
1839 " Load once feature (if ch_load) - this is used on starup
1840 if ch_load && get(get(s:project_Load, expand("%:p"), []), a:type, 0) >= 1
1841 echomsg "Project script " . a:type . " already loaded for this buffer."
1842 if g:atp_debugProject
1848 let cond_A = get(s:project_Load, expand("%:p"), 0)
1849 let cond_B = get(get(s:project_Load, expand("%:p"), []), a:type, 0)
1850 if empty(expand("%:p"))
1851 echoerr "ATP Error : File name is empty. Not loading project script."
1852 if g:atp_debugProject
1858 let s:project_Load[expand("%:p")][a:type][0] += 1
1860 let s:project_Load[expand("%:p")] = { a:type : 1 }
1862 let s:hisotory_Load= { expand("%:p") : { a:type : 1 } }
1865 if a:bang == "" && expand("%:p") =~ 'texmf'
1866 if g:atp_debugProject
1872 let b:atp_histloaded=1
1873 if a:type == "local"
1874 let save_loclist = getloclist(0)
1876 silent exe 'lvimgrep /\Clet\s\+b:atp_ProjectScript\>\s*=/j ' . a:project_script
1879 let loclist = getloclist(0)
1880 call setloclist(0, save_loclist)
1881 execute get(get(loclist, 0, {}), 'text', "")
1882 if exists("b:atp_ProjectScript") && !b:atp_ProjectScript
1883 if g:atp_debugProject
1884 silent echomsg "ATP_ProjectScript: b:atp_ProjectScript == 0 in the project script."
1891 " Load first b:atp_ProjectScript variable
1893 if filereadable(a:project_script)
1894 execute "silent! source " . a:project_script
1897 if g:atp_debugProject
1898 echomsg "ATP_ProjectScript: sourcing " . a:project_script
1903 if g:atp_debugProject
1904 echomsg "ATP_ProjectScript: sourcing time: " . reltimestr(reltime(hist_time))
1909 if !exists("b:atp_project")
1910 if exists("b:LevelDict") && max(values(filter(deepcopy(b:LevelDict), "get(b:TypeDict, v:key, '')=='input'"))) >= 1
1911 let b:atp_project = 1
1913 let b:atp_project = 0
1918 " if a:type == 'local'
1922 " This functoin finds recursilevy (upward) all project scripts.
1923 " {{{ FindProjectScripts()
1924 function! FindProjectScripts()
1925 let dir = fnamemodify(resolve(expand("%:p")), ":p:h")
1928 while glob('*.project.vim', 1) == ''
1930 let dir = fnamemodify(dir, ":h")
1931 if dir == $HOME || dir == dir_l
1936 let project_files = map(split(glob('*project.vim', 1), "\n"), "fnamemodify(v:val, \":p\")")
1938 return project_files
1940 " This function looks to which project current buffer belongs.
1941 " {{{ GetProjectScript(project_files)
1942 " a:project_files = FindProjectScripts()
1943 function! GetProjectScript(project_files)
1944 for pfile in a:project_files
1946 echomsg "Checking " . pfile
1948 let save_loclist = getloclist(0)
1949 let file_name = s:windows ? escape(expand("%:p"), '\') : escape(expand("%:p"), '/')
1950 let sfile_name = expand("%:t")
1952 if !g:atp_RelativePath
1953 exe 'lvimgrep /^\s*let\s\+\%(b:atp_MainFile\s\+=\s*\%(''\|"\)\%(' . file_name . '\|' . sfile_name . '\)\>\%(''\|"\)\|b:ListOfFiles\s\+=.*\%(''\|"\)' . file_name . '\>\)/j ' . pfile
1955 exe 'lvimgrep /^\s*let\s\+\%(b:atp_MainFile\s\+=\s*\%(''\|"\)[^''"]*\<\%(' . sfile_name . '\)\>\%(''\|"\)\|b:ListOfFiles\s\+=.*\%(''\|"\)[^''"]*\<' . sfile_name . '\>\)/j ' . pfile
1958 if g:atp_debugProject
1959 silent echomsg "Script file " . pfile . " doesn't match."
1962 let loclist = getloclist(0)
1964 let bufnr = get(get(loclist, 0, {}), 'bufnr', 'no match')
1965 if bufnr != 'no match'
1966 let project_script = fnamemodify(bufname(bufnr), ":p")
1968 return project_script
1972 return "no project script found"
1974 " This function uses all three above functions: FindProjectScripts(),
1975 " GetProjectScript() and <SID>LoadScript()
1976 " {{{ <SID>LoadProjectScript
1977 " Note: bang has a meaning only for loading the common project script.
1978 function! <SID>LoadProjectScript(bang,...)
1980 if ( exists("g:atp_ProjectScript") && !g:atp_ProjectScript || exists("b:atp_ProjectScript") && ( !b:atp_ProjectScript && (!exists("g:atp_ProjectScript") || exists("g:atp_ProjectScript") && !g:atp_ProjectScript )) )
1981 redir! >> /tmp/ATP_rs_debug
1982 silent echo "+++ SCIPING : LOAD PROJECT SCRIPT +++"
1987 let local = (a:0 >= 1 ? a:1 : 'local' )
1989 let time = reltime()
1992 if local == 'global' || local == 'common'
1993 call s:LoadScript(a:bang,s:common_project_script, 'global', 0, '', 1)
1995 let g:LPS_time = reltimestr(reltime(time))
1996 echomsg "LPS time (common): " . g:LPS_time
2001 if !exists("b:atp_ProjectScriptFile")
2002 " Look for the project file
2003 " echo join(project_files, "\n")
2004 let project_files = FindProjectScripts()
2005 let g:project_files = project_files
2007 " Return if nothing was found
2008 if len(project_files) == 0
2009 let b:atp_ProjectScriptFile = resolve(expand("%:p")) . ".project.vim"
2010 let b:atp_ProjectDir = fnamemodify(b:atp_ProjectScriptFile, ":h")
2014 " Move project_file corresponding to the current buffer to the first
2015 " place if it exists.
2016 " This saves time :) when there are many project files
2017 " (especially when the projects are big)
2018 let index = index(project_files, expand("%:p") . ".project.vim")
2020 call remove(project_files, index)
2021 call extend(project_files, [ expand("%:p") . ".project.vim" ], 0)
2024 let save_loclist = getloclist(0)
2025 call setloclist(0, [])
2028 let project_script = GetProjectScript(project_files)
2029 if project_script != "no project script found"
2031 echomsg "Loading " . project_script
2033 call <SID>LoadScript("", project_script, "local", 0, "silent", 1, 0)
2034 let b:atp_ProjectScriptFile = project_script
2035 let b:atp_ProjectDir = fnamemodify(b:atp_ProjectScriptFile, ":h")
2037 " If there was no project script we set the variable and it will
2038 " be written when quiting vim by <SID>WriteProjectScript().
2039 let b:atp_ProjectScriptFile = resolve(expand("%:p")) . ".project.vim"
2040 let b:atp_ProjectDir = fnamemodify(b:atp_ProjectScriptFile, ":h")
2045 execute "silent! source " . b:atp_ProjectScriptFile
2046 let b:atp_ProjectDir = fnamemodify(b:atp_ProjectScriptFile, ":h")
2048 " this is used by the s:Babel() function.
2049 " if b:atp_ProjectDir is unset it returns.
2050 unlet b:atp_ProjectDir
2055 let g:LPS_time = reltimestr(reltime(time))
2056 echomsg "LPS time: " . g:LPS_time
2059 function! s:LocalCommonComp(ArgLead, CmdLine, CursorPos)
2060 return filter([ 'local', 'common'], 'v:val =~ "^" . a:ArgLead')
2064 " Write Project Script:
2065 "{{{ s:WriteProjectScript(), :WriteProjectScript, autocommands
2066 " This function writes the project file but only if there there are changes.
2067 " This is so, because writing very long lines is much slower than reading (it
2068 " reads the file and compare the variables with the existing ones).
2070 function! <SID>WriteProjectScript(bang, project_script, cached_variables, type)
2072 if g:atp_debugProject
2073 let g:project_script = a:project_script
2077 if g:atp_debugProject >= 2
2078 let time = reltime()
2081 if !exists("b:ListOfFiles")
2082 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
2083 call TreeOfFiles(atp_MainFile)
2086 if g:atp_debugProject
2088 redir! >> /tmp/ATP_ProjectScriptDebug.vim
2089 echomsg "ATP_ProjectScript: WriteProjectScript " . a:type
2090 let time = reltime()
2093 " If none of the variables exists -> return
2094 let exists=max(map(deepcopy(a:cached_variables), "exists(v:val)"))
2096 if g:atp_debugProject
2097 echomsg "no variable exists"
2099 if g:atp_debugProject >= 2
2100 echomsg "time " . reltimestr(reltime(time))
2105 if a:bang == "" && expand("%:p") =~ 'texmf'
2106 if g:atp_debugProject
2107 echomsg "texmf return"
2109 if g:atp_debugProject
2112 if g:atp_debugProject >= 2
2113 echomsg "time " . reltimestr(reltime(time))
2118 " a:bang == '!' then force to write project script even if it is turned off
2119 " localy or globaly.
2120 " The global variable overrides the local one!
2121 let cond = exists("g:atp_ProjectScript") && !g:atp_ProjectScript || exists("b:atp_ProjectScript") && ( !b:atp_ProjectScript && (!exists("g:atp_ProjectScript") || exists("g:atp_ProjectScript") && !g:atp_ProjectScript )) || !exists("b:atp_ProjectScript") && !exists("g:atp_ProjectScript")
2122 if a:bang == "" && cond
2123 echomsg "ATP WriteProjectScript: ProjectScript is turned off."
2124 if g:atp_debugProject
2127 if g:atp_debugProject
2130 if g:atp_debugProject >= 2
2131 echomsg "time " . reltimestr(reltime(time))
2136 let winsaveview = winsaveview()
2138 " Check if global variables where changed.
2139 " (1) copy global variable to l:variables
2140 " and remove defined global variables.
2141 " (2) source the project script and compare the results.
2142 " (3) resore variables and write the project script.
2143 if a:type == "global"
2144 let existing_variables = {}
2145 let g:existing_gvariables = existing_variables
2146 for var in a:cached_variables
2147 if g:atp_debugProject >= 2
2148 echomsg var . " EXISTS " . exists(var)
2151 " step (1) copy variables
2152 let lvar = "l:" . substitute(var, '^[bg]:', '', '')
2154 call extend(existing_variables, { var : string({var}) })
2155 exe "let " . lvar . "=" . string({var})
2157 " echomsg lvar . "=" . string({lvar})
2160 " step (2a) source project script
2161 if filereadable(a:project_script)
2162 execute "source " . a:project_script
2165 for var in a:cached_variables
2166 let lvar = "l:" . substitute(var, '^[bg]:', '', '')
2167 " step (2b) check if variables have changed
2168 if exists(var) && exists(lvar)
2169 let cond_A = ({lvar} != {var})
2170 if g:atp_debugProject
2171 echomsg var . " and " . lvar . " exist. cond_A=" . cond_A
2177 elseif !exists(var) && exists(lvar)
2178 if g:atp_debugProject
2179 echomsg var . " nexists but " . lvar . " exist."
2183 elseif exists(var) && !exists(lvar)
2184 if g:atp_debugProject
2185 echomsg var . " exists and " . lvar . " nexist."
2190 if g:atp_debugProject
2191 echomsg var . " and " . lvar . " nexist."
2196 if g:atp_debugProject
2197 let g:cond_global = cond
2198 echomsg "cond " . cond
2201 " step (3a) copy variables from local ones.
2202 for var in g:atp_cached_common_variables
2203 let lvar = "l:" . substitute(var, '^[bg]:', '', '')
2204 if g:atp_debugProject
2205 echomsg "(3a) " . var . " exists " . lvar . " " . ( exists(lvar) ? 'exists' : 'nexists' )
2208 if g:atp_debugProject
2209 echomsg "(3a) Restoring " . var . " from " . lvar
2214 exe "unlockvar " . var
2216 exe "lockvar " . var
2222 if g:atp_debugProject
2223 silent echomsg "Project script not changed " . "\n"
2224 silent echo "time = " . reltimestr(reltime(time)) . "\n"
2226 if g:atp_debugProject
2229 if g:atp_debugProject >= 2
2230 echomsg "time " . reltimestr(reltime(time))
2236 " Make a list of variables defined in project script
2237 let defined_variables = []
2238 let save_loclist = getloclist(0)
2239 silent! exe 'lvimgrep /^\s*\<let\>\s\+[bg]:/j ' . a:project_script
2240 let defined_variables = getloclist(0)
2241 call map(defined_variables, 'matchstr(v:val["text"], ''^\s*let\s\+\zs[bg]:[^[:blank:]=]*'')')
2242 call setloclist(0, save_loclist)
2243 if g:atp_debugProject
2244 let g:defined_variables = defined_variables
2248 let deleted_variables = []
2249 for var in defined_variables
2251 call add(deleted_variables, var)
2255 if g:atp_debugProject
2256 let g:existing_variables = []
2258 for var in a:cached_variables
2260 let lvar = 'l:' . substitute(var, '^[bg]:', '', '')
2262 if g:atp_debugProject
2263 call add(g:existing_variables, var)
2268 if g:atp_debugProject
2269 let g:deleted_variables = deleted_variables
2272 let hidden = &l:hidden
2275 let lazyredraw = &l:lazyredraw
2278 let bufnr = bufnr("%")
2280 silent! exe "keepalt edit +setl\\ noswapfile " . a:project_script
2283 echoerr "WriteProjectScript catched error while opening " . a:project_script . ". Project script not written."
2284 let &l:hidden = hidden
2285 let &l:lazyredraw = lazyredraw
2286 if g:atp_debugProject
2289 if g:atp_debugProject >= 2
2290 echomsg "time " . reltimestr(reltime(time))
2295 " Delete the variables which where unlet:
2296 for var in deleted_variables
2298 exe 'silent! %g/^\s*let\s\+' . var . '\>/d'
2303 " Write new variables:
2304 for var in a:cached_variables
2306 let lvar = "l:" . substitute(var, '^[bg]:', '', '')
2307 if g:atp_debugProject
2308 echomsg var . " " . exists(lvar)
2314 exe 'silent! %g/^\s*let\s\+' . var . '\>/d'
2317 call append('$', 'let ' . var . ' = ' . string({lvar}))
2320 " Save project script file:
2323 exe "silent keepalt b " . bufnr
2325 let &l:lazyredraw = lazyredraw
2326 call winrestview(winsaveview)
2328 if g:atp_debugProject
2329 silent echo "time = " . reltimestr(reltime(time))
2332 if g:atp_debugProject >= 2
2333 echomsg "time " . reltimestr(reltime(time))
2338 function! <SID>WriteProjectScriptInterface(bang,...)
2339 let type = ( a:0 >= 1 ? a:1 : 'local' )
2341 if type != 'global' && type != 'local'
2342 echoerr "WriteProjectScript Error : type can be: local or global."
2346 let script = ( type == 'local' ? b:atp_ProjectScriptFile : s:common_project_script )
2347 let variables = ( type == 'local' ? g:atp_cached_local_variables : g:atp_cached_common_variables )
2349 echomsg "Writing to " . b:atp_ProjectScriptFile
2351 call s:WriteProjectScript(a:bang, script, variables, type)
2353 function! s:WPSI_comp(ArgLead, CmdLine, CursorPos)
2354 return filter(['local', 'global'], 'v:val =~ a:ArgLead')
2356 "{{{ WriteProjectScript autocommands
2357 augroup ATP_WriteProjectScript
2359 " Before it was VimLeave
2360 au BufWrite *.tex call s:WriteProjectScript("", b:atp_ProjectScriptFile, g:atp_cached_local_variables, 'local')
2361 au BufWrite *.tex call s:WriteProjectScript("", s:common_project_script, g:atp_cached_common_variables, 'global')
2366 " Set Project Script: on/off
2367 " {{{ s:ProjectScript
2368 function! <SID>ProjectScript(...)
2369 let arg = ( a:0 >=1 ? a:1 : "" )
2371 let b:atp_ProjectScript=!b:atp_ProjectScript
2373 let b:atp_ProjectScript=1
2374 :WriteProjectScript!
2376 let b:atp_ProjectScript=0
2377 :WriteProjectScript!
2379 if b:atp_ProjectScript
2380 echomsg "Project Script is set on."
2382 echomsg "Project Script is set off."
2384 return b:atp_ProjectScript
2386 function! HistComp(ArgLead, CmdLine, CursorPos)
2387 return filter(['on', 'off'], 'v:val =~ a:ArgLead')
2390 " Delete Project Script:
2391 " s:DeleteProjectScript {{{
2392 " It has one argument a:1 == "local" or " a:0 == 0 " delete the
2393 " b:atp_ProjectScriptFile.
2394 " otherwise delete s:common_project_script. With bang it forces to delete the
2395 " s:common_project_script"
2396 " It also unlets the variables stored in s:common_project_script.
2397 function! <SID>DeleteProjectScript(bang,...)
2398 let type = ( a:0 >= 1 ? a:1 : "local" )
2401 let file = b:atp_ProjectScriptFile
2403 let file = s:common_project_script
2407 echo "Project Script " . file . " deleted."
2408 if type == "local" && a:bang == "!"
2409 let file = s:common_project_script
2411 echo "Project Script " . file . " deleted."
2413 if file == s:common_project_script
2414 for var in g:atp_cached_common_variables
2419 function! s:DelPS(CmdArg, CmdLine, CursorPos)
2420 let comp = [ "local", "common" ]
2421 call filter(comp, "v:val =~ '^' . a:CmdArg")
2424 " Show ProjectScript:
2425 " function! <SID>ShowProjectScript(bang)
2432 call <SID>LoadProjectScript("", "local")
2433 " Project script should by loaded now, and not by autocommands which are executed after
2434 " sourcing scripts. In this way variables set in project script will be used
2435 " when sourcing other atp scripts.
2436 call s:LoadScript("", s:common_project_script, 'global', 0, 'silent',1)
2439 command! -buffer -bang -nargs=? -complete=customlist,s:LocalCommonGlobalComp LoadProjectScript :call <SID>LoadProjectScript(<q-bang>,<f-args>)
2441 command! -buffer -bang -nargs=? -complete=customlist,s:WPSI_comp WriteProjectScript :call <SID>WriteProjectScriptInterface(<q-bang>,<f-args>)
2442 command! -buffer -nargs=* -complete=customlist,HistComp ProjectScript :call <SID>ProjectScript(<f-args>)
2445 command! -buffer -bang -complete=customlist,s:DelPS -nargs=? DeleteProjectScript :call s:DeleteProjectScript(<q-bang>, <f-args>)
2446 ftplugin/ATP_files/common.vim [[[1
2448 " Author: Marcin Szamotulski
2449 " Description: This script has functions which have to be called before ATP_files/options.vim
2450 " Note: This file is a part of Automatic Tex Plugin for Vim.
2451 " URL: https://launchpad.net/automatictexplugin
2454 let s:sourced = exists("s:sourced") ? 1 : 0
2457 if !exists("g:askfortheoutdir")
2458 let g:askfortheoutdir=0
2460 if !exists("g:atp_raw_texinputs")
2461 let g:atp_raw_texinputs = substitute(substitute(substitute(system("kpsewhich -show-path tex"),'!!','','g'),'\/\/\+','\/','g'), ':\|\n', ',', 'g')
2462 " lockvar g:atp_raw_texinputs
2465 " atp tex and bib inputs directories (kpsewhich)
2466 if !exists("g:atp_texinputs")
2467 let path_list = split(g:atp_raw_texinputs, ',')
2468 let idx = index(path_list, '.')
2470 let dot = remove(path_list, index(path_list,'.')) . ","
2474 call map(path_list, 'v:val . "**"')
2476 let g:atp_texinputs = dot . join(path_list, ',')
2478 " a list where tex looks for bib files
2479 " It must be defined before SetProjectName function.
2480 if !exists("g:atp_raw_bibinputs")
2481 let g:atp_raw_bibinputs=substitute(substitute(substitute(
2482 \ system("kpsewhich -show-path bib"),
2483 \ '\/\/\+', '\/', 'g'),
2484 \ '!\|\n', '', 'g'),
2487 if !exists("g:atp_bibinputs")
2488 let path_list = split(g:atp_raw_bibinputs, ',')
2489 let idx = index(path_list, '.')
2491 let dot = remove(path_list, index(path_list,'.')) . ","
2495 call map(path_list, 'v:val . "**"')
2497 let g:atp_bibinputs = dot . join(path_list, ',')
2501 " This file contains set of functions which are needed to set to set the atp
2502 " options and some common tools.
2504 " Functions: (source once)
2506 " Set the project name
2507 "{{{ SetProjectName (function and autocommands)
2508 " This function sets the main project name (b:atp_MainFile)
2510 " It is used by EditInputFile which copies the value of this variable to every
2511 " input file included in the main source file.
2513 " nmap gf (GotoFile function) is not using this function.
2515 " the b:atp_MainFile variable is set earlier in the startup
2516 " (by the augroup ATP_Syntax_TikzZone), calling SetProjectName to earlier cause
2517 " problems (g:atp_raw_bibinputs undefined).
2519 " ToDo: CHECK IF THIS IS WORKS RECURSIVELY?
2520 " ToDo: THIS FUNCTION SHUOLD NOT SET AUTOCOMMANDS FOR AuTeX function!
2521 " every tex file should be compiled (the compiler function calls the
2522 " right file to compile!
2524 " {{{ SetProjectName ( function )
2525 " store a list of all input files associated to some file
2526 fun! SetProjectName(...)
2527 let bang = ( a:0 >= 1 ? a:1 : "" ) " do we override b:atp_project
2528 let did = ( a:0 >= 2 ? a:2 : 1 ) " do we check if the project name was set
2529 " but also overrides the current b:atp_MainFile when 0
2531 " if the project name was already set do not set it for the second time
2532 " (which sets then b:atp_MainFile to wrong value!)
2533 if &filetype == "fd_atp"
2534 " this is needed for EditInputFile function to come back to the main
2536 let b:atp_MainFile = ( g:atp_RelativePath ? expand("%:t") : expand("%:p") )
2537 let b:did_project_name = 1
2540 if exists("b:did_project_name") && b:did_project_name && did
2541 return " project name was already set"
2543 let b:did_project_name = 1
2546 if !exists("b:atp_project") || bang == "!"
2547 let b:atp_MainFile = exists("b:atp_MainFile") && did ? b:atp_MainFile : ( g:atp_RelativePath ? expand("%:t") : expand("%:p") )
2548 " let b:atp_ProjectDir = fnamemodify(resolve(b:atp_MainFile), ":h")
2549 let pn_return = " set from history or just set to " . b:atp_MainFile . " exists=" . exists("b:atp_MainFile") . " did=" . did
2550 elseif exists("b:atp_project")
2551 let b:atp_MainFile = ( g:atp_RelativePath ? fnamemodify(b:atp_project, ":t") : b:atp_project )
2552 " let b:atp_ProjectDir = fnamemodify(resolve(b:atp_MainFile), ":h")
2553 let pn_return = " set from b:atp_project to " . b:atp_MainFile
2556 " we need to escape white spaces in b:atp_MainFile but not in all places so
2557 " this is not done here
2559 " Now we can run things that needs the project name:
2560 if !exists("b:atp_PackageList")
2561 let b:atp_PackageList = atplib#GrepPackageList()
2564 if !exists("b:atp_ProjectDir")
2565 let b:atp_ProjectDir = ( exists("b:atp_ProjectScriptFile") ? fnamemodify(b:atp_ProjectScriptFile, ":h") : fnamemodify(resolve(expand("%:p")), ":h") )
2572 " augroup ATP_SetProjectName
2573 " au BufEnter *.tex :call SetProjectName()
2574 " au BufEnter *.fd :call SetProjectName()
2579 " This functions sets the value of b:atp_OutDir variable
2581 " This options are set also when editing .cls files.
2582 " It can overwrite the value of b:atp_OutDir
2583 " if arg != 0 then set errorfile option accordingly to b:atp_OutDir
2584 " if a:0 >0 0 then b:atp_atp_OutDir is set iff it doesn't exsits.
2585 function! s:SetOutDir(arg, ...)
2587 " THIS FUNCTION SHOULD BE REVIEWED !!!
2589 if exists("b:atp_OutDir") && a:0 >= 1
2590 return "atp_OutDir EXISTS"
2594 " first we have to check if this is not a project file
2595 if exists("b:atp_project") || exists("s:inputfiles") &&
2596 \ ( index(keys(s:inputfiles),fnamemodify(bufname("%"),":t:r")) != '-1' ||
2597 \ index(keys(s:inputfiles),fnamemodify(bufname("%"),":t")) != '-1' )
2598 " if we are in a project input/include file take the correct value of b:atp_OutDir from the atplib#s:outdir_dict dictionary.
2600 if index(keys(s:inputfiles),fnamemodify(bufname("%"),":t:r")) != '-1'
2601 let b:atp_OutDir=substitute(g:outdir_dict[s:inputfiles[fnamemodify(bufname("%"),":t:r")][1]], '\\\s', ' ', 'g')
2602 elseif index(keys(s:inputfiles),fnamemodify(bufname("%"),":t")) != '-1'
2603 let b:atp_OutDir=substitute(g:outdir_dict[s:inputfiles[fnamemodify(bufname("%"),":t")][1]], '\\\s', ' ', 'g')
2607 " if we are not in a project input/include file set the b:atp_OutDir
2610 " if the user want to be asked for b:atp_OutDir
2611 if g:askfortheoutdir == 1
2612 let b:atp_OutDir=substitute(input("Where to put output? do not escape white spaces "), '\\\s', ' ', 'g')
2615 if ( get(getbufvar(bufname("%"),""),"outdir","optionnotset") == "optionnotset"
2616 \ && g:askfortheoutdir != 1
2617 \ || b:atp_OutDir == "" && g:askfortheoutdir == 1 )
2618 \ && !exists("$TEXMFOUTPUT")
2619 let b:atp_OutDir=substitute(fnamemodify(resolve(expand("%:p")),":h") . "/", '\\\s', ' ', 'g')
2620 " echomsg "Output Directory ".b:atp_OutDir
2622 elseif exists("$TEXMFOUTPUT")
2623 let b:atp_OutDir=substitute($TEXMFOUTPUT, '\\\s', ' ', 'g')
2626 " if arg != 0 then set errorfile option accordingly to b:atp_OutDir
2627 if bufname("") =~ ".tex$" && a:arg != 0
2628 call s:SetErrorFile()
2631 if exists("g:outdir_dict")
2632 let g:outdir_dict = extend(g:outdir_dict, {fnamemodify(bufname("%"),":p") : b:atp_OutDir })
2634 let g:outdir_dict = { fnamemodify(bufname("%"),":p") : b:atp_OutDir }
2641 " This function sets vim 'errorfile' option.
2642 " {{{ s:SetErrorFile (function and autocommands)
2643 " let &l:errorfile=b:atp_OutDir . fnameescape(fnamemodify(expand("%"),":t:r")) . ".log"
2645 function! s:SetErrorFile()
2647 " set b:atp_OutDir if it is not set
2648 if !exists("b:atp_OutDir")
2652 " set the b:atp_MainFile varibale if it is not set (the project name)
2653 if !exists("b:atp_MainFile")
2654 call SetProjectName()
2657 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
2659 " vim doesn't like escaped spaces in file names ( cg, filereadable(),
2660 " writefile(), readfile() - all acepts a non-escaped white spaces)
2661 if has("win16") || has("win32") || has("win64") || has("win95")
2662 let errorfile = substitute(atplib#append(b:atp_OutDir, '\') . fnamemodify(atp_MainFile,":t:r") . ".log", '\\\s', ' ', 'g')
2664 let errorfile = substitute(atplib#append(b:atp_OutDir, '/') . fnamemodify(atp_MainFile,":t:r") . ".log", '\\\s', ' ', 'g')
2666 let &l:errorfile = errorfile
2669 command! -buffer SetErrorFile :call s:SetErrorFile()
2673 augroup ATP_SetErrorFile
2674 au BufEnter *.tex call <SID>SetErrorFile()
2675 au BufRead $l:errorfile setlocal autoread
2680 " Make a tree of input files.
2682 " this is needed to make backward searching.
2684 " [ {tree}, {list} , {type_dict}, {level_dict} ]
2686 " is a tree of files of the form
2687 " { file : [ subtree, linenr ] }
2688 " where the linenr is the linenr of \input{file} iline the one level up
2691 " is just list of all found input files.
2693 " is a dictionary of types for files in {list}
2694 " type is one of: preambule, input, bib.
2696 " {flat} = 1 do not be recursive
2697 " {flat} = 0 the deflaut be recursive for input files (not bib and not preambule)
2698 " bib and preambule files are not added to the tree
2699 " {flat} = -1 include input and premabule files into the tree
2702 " Should match till the begining of the file name and not use \zs:\ze patterns.
2703 " It skips input files with extension other than '.tex' or '' (for example '.fd').
2704 if &filetype == 'plaintex'
2705 let g:atp_inputfile_pattern = '^[^%]*\\input\s*'
2707 let g:atp_inputfile_pattern = '^[^%]*\\\(input\s*{\=\|include\s*{\|bibliography\s*{\)'
2710 " TreeOfFiles({main_file}, [{pattern}, {flat}, {run_nr}])
2711 " debug file - /tmp/tof_log
2712 function! TreeOfFiles(main_file,...)
2713 " let time = reltime()
2715 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
2717 if !exists("b:atp_OutDir")
2718 call s:SetOutDir(0, 1)
2723 let pattern = a:0 >= 1 ? a:1 : g:atp_inputfile_pattern
2724 " flat = do a flat search, i.e. fo not search in input files at all.
2725 let flat = a:0 >= 2 ? a:2 : 0
2727 " This prevents from long runs on package files
2728 " for example babel.sty has lots of input files.
2729 if expand("%:e") != 'tex'
2731 return [ {}, [], {}, {} ]
2733 let run_nr = a:0 >= 3 ? a:3 : 1
2737 redir! > /tmp/tof_log
2739 redir! >> /tmp/tof_log
2744 silent echo run_nr . ") |".a:main_file."| expand=".expand("%:p")
2749 exe "lcd " . b:atp_ProjectDir
2759 let saved_llist = getloclist(0)
2760 if run_nr == 1 && &l:filetype =~ '^\(ams\)\=tex$'
2762 silent execute 'lvimgrep /\\begin\s*{\s*document\s*}/j ' . fnameescape(a:main_file)
2765 let end_preamb = get(get(getloclist(0), 0, {}), 'lnum', 0)
2771 silent execute "lvimgrep /".pattern."/jg " . fnameescape(a:main_file)
2774 let g:pattern = pattern
2775 let g:filename = fnameescape(a:main_file)
2777 let loclist = getloclist(0)
2778 call setloclist(0, saved_llist)
2779 let lines = map(loclist, "[ v:val['text'], v:val['lnum'], v:val['col'] ]")
2782 silent echo run_nr . ") Lines: " .string(lines)
2787 let [ line, lnum, cnum ] = entry
2788 " input name (iname) as appeared in the source file
2789 let iname = substitute(matchstr(line, pattern . '\zs\f*\ze'), '\s*$', '', '')
2791 silent echo run_nr . ") iname=".iname
2793 if line =~ '{\s*' . iname
2794 let iname = substitute(iname, '\\\@<!}\s*$', '', '')
2797 let iext = fnamemodify(iname, ":e")
2799 silent echo run_nr . ") iext=" . iext
2803 \( &filetype == "plaintex" && getbufvar(fnamemodify(b:atp_MainFile, ":t"), "&filetype") != "tex")
2804 \ && expand("%:p") =~ 'texmf'
2805 " if the extension is ldf (babel.sty) or the file type is plaintex
2806 " and the filetype of main file is not tex (it can be empty when the
2807 " buffer is not loaded) then match the full path of the file: if
2808 " matches then doesn't go below this file.
2810 silent echo run_nr . ") CONTINUE"
2815 " type: preambule,bib,input.
2816 if lnum < end_preamb && run_nr == 1
2817 let type = "preambule"
2818 elseif strpart(line, cnum-1) =~ '^\s*\\bibliography'
2825 silent echo run_nr . ") type=" . type
2830 let inames = [ atplib#append_ext(iname, '.tex') ]
2832 let inames = map(split(iname, ','), "atplib#append_ext(v:val, '.bib')")
2836 silent echo run_nr . ") inames " . string(inames)
2839 " Find the full path only if it is not already given.
2841 let saved_iname = iname
2842 if iname != fnamemodify(iname, ":p")
2844 let iname = atplib#KpsewhichFindFile('tex', iname, b:atp_OutDir . "," . g:atp_texinputs , 1, ':p', '^\%(\/home\|\.\)', '\(^\/usr\|texlive\|kpsewhich\|generic\|miktex\)')
2846 let iname = atplib#KpsewhichFindFile('bib', iname, b:atp_OutDir . "," . g:atp_bibinputs , 1, ':p')
2850 if fnamemodify(iname, ":t") == ""
2851 let iname = expand(saved_iname, ":p")
2855 silent echo run_nr . ") iname " . string(iname)
2858 if g:atp_RelativePath
2859 let iname = atplib#RelativePath(iname, (fnamemodify(resolve(b:atp_MainFile), ":h")))
2862 call add(ifiles, [ iname, lnum] )
2863 call add(list, iname)
2864 call extend(type_dict, { iname : type } )
2865 call extend(level_dict, { iname : run_nr } )
2870 silent echo run_nr . ") list=".string(list)
2873 " Be recursive if: flat is off, file is of input type.
2874 if !flat || flat <= -1
2875 for [ifile, line] in ifiles
2876 if type_dict[ifile] == "input" && flat <= 0 || ( type_dict[ifile] == "preambule" && flat <= -1 )
2877 let [ ntree, nlist, ntype_dict, nlevel_dict ] = TreeOfFiles(ifile, pattern, flat, run_nr+1)
2879 call extend(tree, { ifile : [ ntree, line ] } )
2880 call extend(list, nlist, index(list, ifile)+1)
2881 call extend(type_dict, ntype_dict)
2882 call extend(level_dict, nlevel_dict)
2886 " Make the flat tree
2887 for [ ifile, line ] in ifiles
2888 call extend(tree, { ifile : [ {}, line ] })
2892 " Showing time takes ~ 0.013sec.
2894 " echomsg "TIME:" . join(reltime(time), ".") . " main_file:" . a:main_file
2896 let [ b:TreeOfFiles, b:ListOfFiles, b:TypeDict, b:LevelDict ] = deepcopy([ tree, list, type_dict, level_dict])
2898 " restore current working directory
2904 if g:atp_debugTOF && run_nr == 1
2905 redir! >> /tmp/ATP_log
2906 silent! echo "========TreeOfFiles========================"
2907 silent! echo "TreeOfFiles b:ListOfFiles=" . string(b:ListOfFiles)
2912 return [ tree, list, type_dict, level_dict ]
2917 " This function finds all the input and bibliography files declared in the source files (recursive).
2918 " {{{ FindInputFiles
2919 " Returns a dictionary:
2920 " { <input_name> : [ 'bib', 'main file', 'full path' ] }
2921 " with the same format as the output of FindInputFiles
2922 " a:MainFile - main file (b:atp_MainFile)
2923 " a:1 = 0 [1] - use cached values of tree of files.
2924 function! FindInputFiles(MainFile,...)
2926 let cached_Tree = a:0 >= 1 ? a:1 : 0
2928 let saved_llist = getloclist(0)
2929 call setloclist(0, [])
2931 if cached_Tree && exists("b:TreeOfFiles")
2932 let [ TreeOfFiles, ListOfFiles, DictOfFiles, LevelDict ]= deepcopy([ b:TreeOfFiles, b:ListOfFiles, b:TypeDict, b:LevelDict ])
2935 if &filetype == "plaintex"
2941 let [ TreeOfFiles, ListOfFiles, DictOfFiles, LevelDict ]= TreeOfFiles(fnamemodify(a:MainFile, ":p"), g:atp_inputfile_pattern, flat)
2942 " Update the cached values:
2943 let [ b:TreeOfFiles, b:ListOfFiles, b:TypeDict, b:LevelDict ] = deepcopy([ TreeOfFiles, ListOfFiles, DictOfFiles, LevelDict ])
2946 let AllInputFiles = keys(filter(copy(DictOfFiles), " v:val == 'input' || v:val == 'preambule' "))
2947 let AllBibFiles = keys(filter(copy(DictOfFiles), " v:val == 'bib' "))
2949 let b:AllInputFiles = deepcopy(AllInputFiles)
2950 let b:AllBibFiles = deepcopy(AllBibFiles)
2952 " this variable will store unreadable bibfiles:
2953 let NotReadableInputFiles=[]
2955 " this variable will store the final result:
2958 for File in ListOfFiles
2959 let File_Path = atplib#FullPath(File)
2960 if filereadable(File)
2962 \ { fnamemodify(File_Path,":t:r") : [ DictOfFiles[File] , fnamemodify(a:MainFile, ":p"), File_Path ] })
2964 " echo warning if a bibfile is not readable
2965 " echohl WarningMsg | echomsg "File " . File . " not found." | echohl None
2966 if count(NotReadableInputFiles, File_Path) == 0
2967 call add(NotReadableInputFiles, File_Path)
2971 let g:NotReadableInputFiles = NotReadableInputFiles
2973 " return the list of readable bibfiles
2976 function! UpdateMainFile()
2977 if b:atp_MainFile =~ '^\s*\/'
2979 exe "lcd " . b:atp_ProjectDir
2980 let b:atp_MainFile = ( g:atp_RelativePath ? fnamemodify(b:atp_MainFile, ":.") : b:atp_MainFile )
2983 let b:atp_MainFile = ( g:atp_RelativePath ? b:atp_MainFile : atplib#FullPath(b:atp_MainFile) )
2989 " All Status Line related things:
2991 function! s:StatusOutDir() "{{{
2993 if exists("b:atp_OutDir")
2994 if b:atp_OutDir != ""
2995 let status= status . "Output dir: " . pathshorten(substitute(b:atp_OutDir,"\/\s*$","",""))
2997 let status= status . "Please set the Output directory, b:atp_OutDir"
3004 " There is a copy of this variable in compiler.vim
3006 function! ATPRunning() "{{{
3007 if exists("b:atp_running") && exists("g:atp_callback") && b:atp_running && g:atp_callback
3008 " let b:atp_running = b:atp_running < 0 ? 0 : b:atp_running
3011 for cmd in keys(g:CompilerMsg_Dict)
3012 if b:atp_TexCompiler =~ '^\s*' . cmd . '\s*$'
3013 let Compiler = g:CompilerMsg_Dict[cmd]
3016 let Compiler = b:atp_TexCompiler
3020 if b:atp_running >= 2
3021 return b:atp_running." ".Compiler." "
3022 elseif b:atp_running >= 1
3031 " {{{ Syntax and Hilighting
3033 " syntax match atp_statustitle /.*/
3034 " syntax match atp_statussection /.*/
3035 " syntax match atp_statusoutdir /.*/
3036 " hi link atp_statustitle Number
3037 " hi link atp_statussection Title
3038 " hi link atp_statusoutdir String
3041 function! s:SetNotificationColor() "{{{
3042 " use the value of the variable g:atp_notification_{g:colors_name}_guibg
3043 " if it doesn't exists use the default value (the same as the value of StatusLine
3044 " (it handles also the reverse option!)
3045 let colors_name = exists("g:colors_name") ? g:colors_name : "default"
3046 " let g:cname = colors_name
3047 " Note: the names of variable uses gui but equally well it could be cterm. As
3048 " they work in gui and vim.
3049 if has("gui_running")
3050 let notification_guibg = exists("g:atp_notification_".colors_name."_guibg") ?
3051 \ g:atp_notification_{colors_name}_guibg :
3052 \ ( synIDattr(synIDtrans(hlID("StatusLine")), "reverse") ?
3053 \ synIDattr(synIDtrans(hlID("StatusLine")), "fg#") :
3054 \ synIDattr(synIDtrans(hlID("StatusLine")), "bg#") )
3055 let notification_guifg = exists("g:atp_notification_".colors_name."_guifg") ?
3056 \ g:atp_notification_{colors_name}_guifg :
3057 \ ( synIDattr(synIDtrans(hlID("StatusLine")), "reverse") ?
3058 \ synIDattr(synIDtrans(hlID("StatusLine")), "bg#") :
3059 \ synIDattr(synIDtrans(hlID("StatusLine")), "fg#") )
3060 let notification_gui = exists("g:atp_notification_".colors_name."_gui") ?
3061 \ g:atp_notification_{colors_name}_gui :
3062 \ ( (synIDattr(synIDtrans(hlID("StatusLine")), "bold") ? "bold" : "" ) .
3063 \ (synIDattr(synIDtrans(hlID("StatusLine")), "underline") ? ",underline" : "" ) .
3064 \ (synIDattr(synIDtrans(hlID("StatusLine")), "underculr") ? ",undercurl" : "" ) .
3065 \ (synIDattr(synIDtrans(hlID("StatusLine")), "italic") ? ",italic" : "" ) )
3067 let notification_guibg = exists("g:atp_notification_".colors_name."_ctermbg") ?
3068 \ g:atp_notification_{colors_name}_ctermbg :
3069 \ ( synIDattr(synIDtrans(hlID("StatusLine")), "reverse") ?
3070 \ synIDattr(synIDtrans(hlID("StatusLine")), "fg#") :
3071 \ synIDattr(synIDtrans(hlID("StatusLine")), "bg#") )
3072 let notification_guifg = exists("g:atp_notification_".colors_name."_ctermfg") ?
3073 \ g:atp_notification_{colors_name}_ctermfg :
3074 \ ( synIDattr(synIDtrans(hlID("StatusLine")), "reverse") ?
3075 \ synIDattr(synIDtrans(hlID("StatusLine")), "bg#") :
3076 \ synIDattr(synIDtrans(hlID("StatusLine")), "fg#") )
3077 let notification_gui = exists("g:atp_notification_".colors_name."_cterm") ?
3078 \ g:atp_notification_{colors_name}_cterm :
3079 \ ( (synIDattr(synIDtrans(hlID("StatusLine")), "bold") ? "bold" : "" ) .
3080 \ (synIDattr(synIDtrans(hlID("StatusLine")), "underline") ? ",underline" : "" ) .
3081 \ (synIDattr(synIDtrans(hlID("StatusLine")), "underculr") ? ",undercurl" : "" ) .
3082 \ (synIDattr(synIDtrans(hlID("StatusLine")), "italic") ? ",italic" : "" ) )
3085 if has("gui_running")
3086 let g:notification_gui = notification_gui
3087 let g:notification_guibg = notification_guibg
3088 let g:notification_guifg = notification_guifg
3090 let g:notification_cterm = notification_gui
3091 let g:notification_ctermbg = notification_guibg
3092 let g:notification_ctermfg = notification_guifg
3094 if has("gui_running")
3097 let prefix = "cterm"
3099 let hi_gui = ( notification_gui != "" && notification_gui != -1 ? " ".prefix."=" . notification_gui : "" )
3100 let hi_guifg = ( notification_guifg != "" && notification_guifg != -1 ? " ".prefix."fg=" . notification_guifg : "" )
3101 let hi_guibg = ( notification_guibg != "" && notification_guibg != -1 ? " ".prefix."bg=" . notification_guibg : "" )
3103 if (notification_gui == -1 || notification_guifg == -1 || notification_guibg == -1)
3106 " Highlight command:
3108 execute "hi User".g:atp_statusNotifHi ." ". hi_gui . hi_guifg . hi_guibg
3115 " The main status function, it is called via autocommand defined in 'options.vim'.
3117 function! ATPStatus(bang) "{{{
3118 let g:status_OutDir = a:bang == "" && g:atp_statusOutDir || a:bang == "!" && !g:atp_statusOutDir ? s:StatusOutDir() : ""
3119 let status_CTOC = &filetype =~ '^\(ams\)\=tex' ? CTOC("return") : ''
3120 if g:atp_statusNotifHi > 9 || g:atp_statusNotifHi < 0
3121 let g:atp_statusNotifHi = 9
3123 echoerr "Wrong value of g:atp_statusNotifHi, should be 0,1,...,9. Setting it to 9."
3127 let status_NotifHi =
3128 \ ( g:atp_statusNotif && g:atp_statusNotifHi ? '%#User'.g:atp_statusNotifHi . '#' : '' )
3129 let status_NotifHiPost =
3130 \ ( g:atp_statusNotif && g:atp_statusNotifHi ? '%#StatusLine#' : '' )
3131 let status_Notif = ( g:atp_statusNotif ? '%{ATPRunning()}' : '' )
3132 let status_KeyMap = ( has("keymap") && g:atp_babel && exists("b:keymap_name")
3133 \ ? b:keymap_name : '' )
3135 let g:atp_StatusLine= '%<%f '.status_KeyMap.'%(%h%m%r%) %='.status_CTOC." ".status_NotifHi.status_Notif.status_NotifHiPost.'%{g:status_OutDir} %-14.16(%l,%c%V%)%P'
3136 set statusline=%!g:atp_StatusLine
3140 command -buffer -bang Status :call ATPStatus(<q-bang>)
3142 command! -buffer -bang ATPStatus :call ATPStatus(<q-bang>)
3148 call SetProjectName()
3149 call s:SetOutDir(0, 1)
3150 if expand("%:e") == "tex"
3151 " cls and sty files also have filetype 'tex', this prevents from setting the error
3153 call s:SetErrorFile()
3156 command! -buffer -bang SetProjectName :call SetProjectName(<q-bang>, 0)
3157 command! -buffer SetOutDir :call <SID>SetOutDir(1)
3158 command! -buffer InputFiles :call UpdateMainFile() | :call FindInputFiles(atplib#FullPath(b:atp_MainFile)) | echo join([b:atp_MainFile]+b:ListOfFiles, "\n")
3160 " This should set the variables and run s:SetNotificationColor function
3161 command! -buffer SetNotificationColor :call s:SetNotificationColor()
3162 augroup ATP_SetStatusLineNotificationColor
3164 au BufEnter *tex :call s:SetNotificationColor()
3165 au ColorScheme * :call s:SetNotificationColor()
3168 " vim:fdm=marker:tw=85:ff=unix:noet:ts=8:sw=4:fdc=1
3169 ftplugin/ATP_files/compiler.vim [[[1
3171 " Author: Marcin Szamotulski
3172 " Note: this file contain the main compiler function and related tools, to
3173 " view the output, see error file.
3174 " Note: This file is a part of Automatic Tex Plugin for Vim.
3175 " URL: https://launchpad.net/automatictexplugin
3178 " Some options (functions) should be set once:
3179 let s:sourced = exists("s:sourced") ? 1 : 0
3181 " Functions: (source once)
3183 " Internal Variables
3185 " This limits how many consecutive runs there can be maximally.
3188 let s:texinteraction = "nonstopmode"
3192 " This is the function to view output. It calls compiler if the output is a not
3195 " a:1 == "RevSearch" if run from RevSearch() function and the output file doesn't
3196 " exsists call compiler and RevSearch().
3197 function! <SID>ViewOutput(...)
3199 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
3201 let rev_search = ( a:0 == 1 && a:1 == "RevSearch" ? 1 : 0 )
3203 call atplib#outdir()
3205 " Set the correct output extension (if nothing matches set the default '.pdf')
3206 let ext = get(g:atp_CompilersDict, matchstr(b:atp_TexCompiler, '^\s*\zs\S\+\ze'), ".pdf")
3208 " Read the global options from g:atp_{b:atp_Viewer}Options variables
3209 let global_options = exists("g:atp_".matchstr(b:atp_Viewer, '^\s*\zs\S\+\ze')."Options") ? g:atp_{matchstr(b:atp_Viewer, '^\s*\zs\S\+\ze')}Options : ""
3210 let local_options = getbufvar(bufnr("%"), "atp_".matchstr(b:atp_Viewer, '^\s*\zs\S\+\ze')."Options")
3212 " let g:options = global_options ." ". local_options
3214 " Follow the symbolic link
3215 let link=system("readlink " . shellescape(atp_MainFile))
3217 let outfile = fnamemodify(link,":r") . ext
3219 let outfile = fnamemodify(atp_MainFile,":r"). ext
3222 if b:atp_Viewer == "xpdf"
3223 let viewer = b:atp_Viewer . " -remote " . shellescape(b:atp_XpdfServer) . " " . getbufvar("%", b:atp_Viewer.'Options')
3225 let viewer = b:atp_Viewer . " " . getbufvar("%", "atp_".b:atp_Viewer.'Options')
3228 let view_cmd = viewer . " " . global_options . " " . local_options . " " . shellescape(outfile) . " &"
3231 let g:view_cmd = view_cmd
3234 if filereadable(outfile)
3235 if b:atp_Viewer == "xpdf"
3236 call system(view_cmd)
3238 call system(view_cmd)
3242 echomsg "Output file do not exists. Calling " . b:atp_TexCompiler
3244 call s:Compiler( 0, 2, 1, 'silent' , "AU" , atp_MainFile, "")
3246 call s:Compiler( 0, 1, 1, 'silent' , "AU" , atp_MainFile, "")
3250 noremap <silent> <Plug>ATP_ViewOutput :call <SID>ViewOutput()<CR>
3253 " This function gets the pid of the running compiler
3254 " ToDo: review LatexBox has a better approach!
3255 "{{{ Get PID Functions
3256 function! <SID>getpid()
3257 let s:command="ps -ef | grep -v " . $SHELL . " | grep " . b:atp_TexCompiler . " | grep -v grep | grep " . fnameescape(expand("%")) . " | awk 'BEGIN {ORS=\" \"} {print $2}'"
3258 let s:var = system(s:command)
3261 function! <SID>GetPID()
3262 let s:var=s:getpid()
3264 echomsg b:atp_TexCompiler . " pid " . s:var
3266 let b:atp_running = 0
3267 echomsg b:atp_TexCompiler . " is not running"
3272 " To check if xpdf is running we use 'ps' unix program.
3274 if !exists("*s:xpdfpid")
3275 function! <SID>xpdfpid()
3276 let s:checkxpdf="ps -ef | grep -v grep | grep xpdf | grep '-remote '" . shellescape(b:atp_XpdfServer) . " | awk '{print $2}'"
3277 return substitute(system(s:checkxpdf),'\D','','')
3282 " This function compares two files: file written on the disk a:file and the current
3285 " relevant variables:
3286 " g:atp_compare_embedded_comments
3287 " g:atp_compare_double_empty_lines
3289 " This function is too slow it takes 0.35 sec on file with 2500 lines.
3291 " Maybe just compare current line!
3292 " (search for the current line in the written
3293 " file with vimgrep)
3294 function! <SID>compare(file)
3295 let l:buffer=getbufline(bufname("%"),"1","$")
3297 " rewrite l:buffer to remove all comments
3298 let l:buffer=filter(l:buffer, 'v:val !~ "^\s*%"')
3301 if g:atp_compare_double_empty_lines == 0 || g:atp_compare_embedded_comments == 0
3302 while l:i < len(l:buffer)-1
3304 " remove comment lines at the end of a line
3305 if g:atp_compare_embedded_comments == 0
3306 let l:buffer[l:i] = substitute(l:buffer[l:i],'%.*$','','')
3309 " remove double empty lines (i.e. from two conecutive empty lines
3310 " the first one is deleted, the second remains), if the line was
3311 " removed we do not need to add 1 to l:i (this is the role of
3313 if g:atp_compare_double_empty_lines == 0 && l:i< len(l:buffer)-2
3314 if l:buffer[l:i] =~ '^\s*$' && l:buffer[l:i+1] =~ '^\s*$'
3315 call remove(l:buffer,l:i)
3325 " do the same with a:file
3326 let l:file=filter(a:file, 'v:val !~ "^\s*%"')
3329 if g:atp_compare_double_empty_lines == 0 || g:atp_compare_embedded_comments == 0
3330 while l:i < len(l:file)-1
3332 " remove comment lines at the end of a line
3333 if g:atp_compare_embedded_comments == 0
3334 let l:file[l:i] = substitute(a:file[l:i],'%.*$','','')
3337 " remove double empty lines (i.e. from two conecutive empty lines
3338 " the first one is deleted, the second remains), if the line was
3339 " removed we do not need to add 1 to l:i (this is the role of
3341 if g:atp_compare_double_empty_lines == 0 && l:i < len(l:file)-2
3342 if l:file[l:i] =~ '^\s*$' && l:file[l:i+1] =~ '^\s*$'
3343 call remove(l:file,l:i)
3353 " This is the way to make it not sensitive on new line signs.
3354 " let file_j = join(l:file)
3355 " let buffer_j = join(l:buffer)
3356 " return file_j !=# buffer_j
3358 return l:file !=# l:buffer
3360 " function! s:sompare(file)
3361 " return Compare(a:file)
3363 " This is very fast (0.002 sec on file with 2500 lines)
3364 " but the proble is that vimgrep greps the buffer rather than the file!
3365 " so it will not indicate any differences.
3366 function! NewCompare()
3367 let line = getline(".")
3368 let lineNr = line(".")
3369 let saved_loclist = getloclist(0)
3371 exe "lvimgrep /^". escape(line, '\^$') . "$/j " . expand("%:p")
3374 " call setloclist(0, saved_loclist)
3375 let loclist = getloclist(0)
3376 call map(loclist, "v:val['lnum']")
3377 return !(index(loclist, lineNr)+1)
3382 " This function copies the file a:input to a:output
3384 function! <SID>copy(input,output)
3385 call writefile(readfile(a:input),a:output)
3390 " (with the help of David Munger - LatexBox)
3392 function! <SID>GetSid() "{{{
3393 return matchstr(expand('<sfile>'), '\zs<SNR>\d\+_\ze.*$')
3395 let s:compiler_SID = s:GetSid() "}}}
3397 " Make the SID visible outside the script:
3398 " /used in LatexBox_complete.vim file/
3399 let g:atp_compiler_SID = { fnamemodify(expand('<sfile>'),':t') : s:compiler_SID }
3401 function! <SID>SidWrap(func) "{{{
3402 return s:compiler_SID . a:func
3406 function! <SID>CatchStatus(status)
3407 let b:atp_TexStatus=a:status
3412 " a:mode = a:verbose of s:compiler ( one of 'default', 'silent',
3413 " 'debug', 'verbose')
3414 " a:commnad = a:commmand of s:compiler
3415 " ( a:commnad = 'AU' if run from background)
3417 " Uses b:atp_TexStatus which is equal to the value returned by tex
3419 function! <SID>CallBack(mode)
3420 if g:atp_debugCallBack
3424 for cmd in keys(g:CompilerMsg_Dict)
3425 if b:atp_TexCompiler =~ '^\s*' . cmd . '\s*$'
3426 let Compiler = g:CompilerMsg_Dict[cmd]
3429 let Compiler = b:atp_TexCompiler
3432 let b:atp_running = b:atp_running - 1
3437 " If the log file is open re read it / it has 'autoread' opion set /
3440 " redraw the status line /for the notification to appear as fast as
3442 if a:mode != 'verbose'
3446 if b:atp_TexStatus && t:atp_DebugMode != "silent"
3447 if b:atp_ReloadOnError
3448 echomsg Compiler." exited with status " . b:atp_TexStatus
3450 echomsg Compiler." exited with status " . b:atp_TexStatus . " output file not reloaded"
3452 elseif !g:atp_status_notification || !g:atp_statusline
3453 echomsg Compiler." finished"
3456 " End the debug mode if there are no errors
3457 if b:atp_TexStatus == 0 && t:atp_DebugMode == "debug"
3459 echomsg b :atp_TexCompiler." finished with status " . b:atp_TexStatus . " going out of debuging mode."
3460 let t:atp_DebugMode == g:atp_DefaultDebugMode
3463 if t:atp_DebugMode == "debug" || a:mode == "debug"
3464 if !t:atp_QuickFixOpen
3467 " In debug mode, go to first error.
3468 if t:atp_DebugMode == "debug"
3476 " This function is called to run TeX compiler and friends as many times as necessary.
3477 " Makes references and bibliographies (supports bibtex), indexes.
3479 " a:texfile full path to the tex file
3481 " 0 - do not check for making index in this run
3483 " a:0 == 0 || a:1 == 0 (i.e. the default) not run latex before /this might change in
3485 " a:1 != 0 run latex first, regardless of the state of log/aux files.
3488 " The arguments are path to logfile and auxfile.
3489 " To Do: add support for TOC !
3490 " To Do: when I will add proper check if bibtex should be done (by checking bbl file
3491 " or changes in bibliographies in input files), the bang will be used to update/or
3492 " not the aux|log|... files.
3493 " Function Arguments:
3494 " a:texfile = main tex file to use
3495 " a:did_bibtex = the number of times bibtex was already done MINUS 1 (should be 0 on start up)
3496 " a:did_index = 0/1 1 - did index
3497 " / to make an index it is enough to call:
3498 " latex ; makeindex ; latex /
3499 " a:time = [] - it will give time message (only if has("reltime"))
3500 " [0] - no time message.
3501 " a:did_firstrun = did the first run? (see a:1 below)
3502 " a:run = should be 1 on invocation: the number of the run
3503 " force = '!'/'' (see :h bang)
3504 " This only makes a difference with bibtex:
3505 " if removed citation to get the right Bibliography you need to use
3506 " 'Force' option in all other cases 'NoForce' is enough (and faster).
3508 " a:1 = do the first run (by default: NO) - to obtain/update log|aux|idx|toc|... files.
3509 " /this is a weak NO: if one of the needed files not
3510 " readable it is used/
3512 " Some explanation notes:
3513 " references = referes to the bibliography
3514 " the pattern to match in log is based on the
3515 " phrase: 'Citation .* undefined'
3516 " cross_references = referes to the internal labels
3517 " phrase to check in the log file:
3518 " 'Label(s) may have changed. Rerun to get cross references right.'
3519 " table of contents = 'No file \f*\.toc'
3521 " needs reltime feature (used already in the command)
3524 let g:MakeLatex_debug = 0
3525 " errorfile /tmp/mk_log
3528 function! <SID>MakeLatex(texfile, did_bibtex, did_index, time, did_firstrun, run, force, ...)
3530 if a:time == [] && has("reltime") && len(a:time) != 1
3531 let time = reltime()
3536 if &filetype == "plaintex"
3538 echo "plaintex is not supported"
3540 return "plaintex is not supported."
3543 " Prevent from infinite loops
3544 if a:run >= s:runlimit
3545 echoerr "ATP Error: MakeLatex in infinite loop."
3546 return "infinte loop."
3549 let b:atp_running= a:run == 1 ? b:atp_running+1 : 0
3550 let runtex_before = a:0 == 0 || a:1 == 0 ? 0 : 1
3551 let runtex_before = runtex_before
3553 if g:MakeLatex_debug
3555 redir! > /tmp/mk_log
3557 redir! >> /tmp/mk_log
3561 for cmd in keys(g:CompilerMsg_Dict)
3562 if b:atp_TexCompiler =~ '^\s*' . cmd . '\s*$'
3563 let Compiler = g:CompilerMsg_Dict[cmd]
3566 let Compiler = b:atp_TexCompiler
3570 let compiler_SID = s:compiler_SID
3573 let mode = ( g:atp_DefaultDebugMode == 'verbose' ? 'debug' : g:atp_DefaultDebugMode )
3574 let tex_options = " -interaction nonstopmode -output-directory=" . b:atp_OutDir . " " . b:atp_TexOptions
3576 " This supports b:atp_OutDir
3577 let texfile = b:atp_OutDir . fnamemodify(a:texfile, ":t")
3578 let logfile = fnamemodify(texfile, ":r") . ".log"
3579 let auxfile = fnamemodify(texfile, ":r") . ".aux"
3580 let bibfile = fnamemodify(texfile, ":r") . ".bbl"
3581 let idxfile = fnamemodify(texfile, ":r") . ".idx"
3582 let indfile = fnamemodify(texfile, ":r") . ".ind"
3583 let tocfile = fnamemodify(texfile, ":r") . ".toc"
3584 let loffile = fnamemodify(texfile, ":r") . ".lof"
3585 let lotfile = fnamemodify(texfile, ":r") . ".lot"
3586 let thmfile = fnamemodify(texfile, ":r") . ".thm"
3588 if b:atp_TexCompiler =~ '^\%(pdflatex\|pdftex\|xetex\|context\|luatex\)$'
3593 let outfile = fnamemodify(texfile, ":r") . ext
3595 if g:MakeLatex_debug
3596 silent echo a:run . " BEGIN " . strftime("%c")
3597 silent echo a:run . " logfile=" . logfile . " " . filereadable(logfile) . " auxfile=" . auxfile . " " . filereadable(auxfile). " runtex_before=" . runtex_before . " a:force=" . a:force
3600 let saved_pos = getpos(".")
3601 keepjumps call setpos(".", [0,1,1,0])
3602 keepjumps let stop_line=search('\m\\begin\s*{document}','nW')
3603 let makeidx = search('\m^[^%]*\\makeindex', 'n', stop_line)
3604 keepjumps call setpos(".", saved_pos)
3606 " We use location list which should be restored.
3607 let saved_loclist = copy(getloclist(0))
3609 " grep in aux file for
3610 " 'Citation .* undefined\|Rerun to get cross-references right\|Writing index file'
3611 let saved_llist = getloclist(0)
3612 execute "silent! lvimgrep /C\\n\\=i\\n\\=t\\n\\=a\\n\\=t\\n\\=i\\n\\=o\\n\\=n\\_s\\_.*\\_su\\n\\=n\\n\\=d\\n\\=e\\n\\=f\\n\\=i\\n\\=n\\n\\=e\\n\\=d\\|L\\n\\=a\\n\\=b\\n\\=e\\n\\=l\\n\\=(\\n\\=s\\n\\=)\\_sm\\n\\=a\\n\\=y\\_sh\\n\\=a\\n\\=v\\n\\=e\\_sc\\n\\=h\\n\\=a\\n\\=n\\n\\=g\\n\\=e\\n\\=d\\n\\=.\\|W\\n\\=r\\n\\=i\\n\\=t\\n\\=i\\n\\=n\\n\\=g\\_si\\n\\=n\\n\\=d\\n\\=e\\n\\=x\\_sf\\n\\=i\\n\\=l\\n\\=e/j " . fnameescape(logfile)
3613 let location_list = copy(getloclist(0))
3614 call setloclist(0, saved_llist)
3617 if g:MakeLatex_debug
3618 silent echo a:run . " location_list=" . string(len(location_list))
3619 silent echo a:run . " references_list=" . string(len(filter(copy(location_list), 'v:val["text"] =~ "Citation"')))
3621 let references = len(filter(copy(location_list), 'v:val["text"] =~ "Citation"')) == 0 ? 0 : 1
3623 " Check what to use to make the 'Bibliography':
3624 let saved_llist = getloclist(0)
3625 execute 'silent! lvimgrep /\\bibdata\s*{/j ' . fnameescape(auxfile)
3626 " Note: if the auxfile is not there it returns 0 but this is the best method for
3627 " looking if we have to use 'bibtex' as the bibliography might be not written in
3629 let bibtex = len(getloclist(0)) == 0 ? 0 : 1
3630 call setloclist(0, saved_llist)
3632 if g:MakeLatex_debug
3633 silent echo a:run . " references=" . references . " bibtex=" . bibtex . " a:did_bibtex=" . a:did_bibtex
3636 " Check cross-references:
3637 let cross_references = len(filter(copy(location_list), 'v:val["text"]=~"Rerun"'))==0?0:1
3639 if g:MakeLatex_debug
3640 silent echo a:run . " cross_references=" . cross_references
3647 " The index file is written iff
3648 " 1) package makeidx is declared
3649 " 2) the preambule contains \makeindex command, then log has a line: "Writing index file"
3650 " the 'index' variable is equal 1 iff the two conditions are met.
3652 let index = len(filter(copy(location_list), 'v:val["text"] =~ "Writing index file"')) == 0 ? 0 : 1
3654 let idx_cmd = " makeindex " . idxfile . " ; "
3660 if g:MakeLatex_debug
3661 silent echo a:run . " index=" . index . " makeidx=" . makeidx . " idx_cdm=" . idx_cmd . " a:did_index=" . a:did_index
3664 " Check table of contents:
3665 let saved_llist = getloclist(0)
3666 execute "silent! lvimgrep /\\\\openout\\d\\+/j " . fnameescape(logfile)
3668 let open_out = map(getloclist(0), "v:val['text']")
3669 call setloclist(0, saved_llist)
3671 if filereadable(logfile) && a:force == ""
3672 let toc = ( len(filter(deepcopy(open_out), "v:val =~ \"toc\'\"")) ? 1 : 0 )
3673 let lof = ( len(filter(deepcopy(open_out), "v:val =~ \"lof\'\"")) ? 1 : 0 )
3674 let lot = ( len(filter(deepcopy(open_out), "v:val =~ \"lot\'\"")) ? 1 : 0 )
3675 let thm = ( len(filter(deepcopy(open_out), "v:val =~ \"thm\'\"")) ? 1 : 0 )
3677 " This is not an efficient way and it is not good for long files with input
3678 " lines and lists in not common position.
3679 let save_pos = getpos(".")
3681 let toc = search('\\tableofcontents', 'nw')
3682 call cursor(line('$'), 1)
3683 call cursor(line('.'), col('$'))
3684 let lof = search('\\listoffigures', 'nbw')
3685 let lot = search('\\listoffigures', 'nbw')
3686 if atplib#SearchPackage('ntheorem')
3687 let thm = search('\\listheorems', 'nbw')
3691 keepjumps call setpos(".", save_pos)
3695 if g:MakeLatex_debug
3696 silent echo a:run." toc=".toc." lof=".lof." lot=".lot." open_out=".string(open_out)
3699 " Run tex compiler for the first time:
3700 let logfile_readable = filereadable(logfile)
3701 let auxfile_readable = filereadable(auxfile)
3702 let idxfile_readable = filereadable(idxfile)
3703 let tocfile_readable = filereadable(tocfile)
3704 let loffile_readable = filereadable(loffile)
3705 let lotfile_readable = filereadable(lotfile)
3706 let thmfile_readable = filereadable(thmfile)
3708 let condition = !logfile_readable || !auxfile_readable || !thmfile_readable && thm ||
3709 \ ( makeidx && !idxfile_readable ) ||
3710 \ !tocfile_readable && toc || !loffile_readable && lof || !lotfile_readable && lot ||
3713 if g:MakeLatex_debug
3714 silent echo a:run . " log_rea=" . logfile_readable . " aux_rea=" . auxfile_readable . " idx_rea&&mke=" . ( makeidx && idxfile_readable ) . " runtex_before=" . runtex_before
3715 silent echo a:run . " Run First " . condition
3720 " Do not write project script file while saving the file.
3721 let atp_ProjectScript = ( exists("g:atp_ProjectScript") ? g:atp_ProjectScript : -1 )
3722 let g:atp_ProjectScript = 0
3724 if atp_ProjectScript == -1
3725 unlet g:atp_ProjectScript
3727 let g:atp_ProjectScript = atp_ProjectScript
3731 let callback_cmd = v:progname . " --servername " . v:servername . " --remote-expr \"" . compiler_SID .
3732 \ "MakeLatex\(\'".texfile."\', ".did_bibtex.", 0, [".time[0].",".time[1]."], ".
3733 \ a:did_firstrun.", ".(a:run+1).", \'".a:force."\'\)\""
3734 let cmd = b:atp_TexCompiler . tex_options . texfile . " ; " . callback_cmd
3736 if g:MakeLatex_debug
3737 let g:ml_debug .= "First run. (make log|aux|idx file)" . " [" . b:atp_TexCompiler . tex_options . texfile . " ; " . callback_cmd . "]#"
3738 silent echo a:run . " Run First CMD=" . cmd
3743 echomsg "[MakeLatex] Updating files [".Compiler."]."
3744 call system("(" . b:atp_TexCompiler . tex_options . texfile . " ; " . callback_cmd . " )&")
3745 return "Making log file or aux file"
3749 if a:did_firstrun && !bibtex && a:run == 2
3750 "Note: in this place we should now correctly if bibtex is in use or not,
3751 "if not and we did first run we can count it. /the a:did_bibtex variable will
3753 let did_bibtex = a:did_bibtex + 1
3755 let did_bibtex = a:did_bibtex
3757 let bib_condition_force = ( (references && !bibtex) || bibtex ) && did_bibtex <= 1
3758 let bib_condition_noforce = ( references && did_bibtex <= 1 )
3759 let condition_force = bib_condition_force || cross_references || index && !a:did_index ||
3760 \ ( ( toc || lof || lot || thm ) && a:run < 2 )
3761 let condition_noforce = bib_condition_noforce || cross_references || index && !a:did_index ||
3762 \ ( ( toc || lof || lot || thm ) && a:run < 2 )
3764 if g:MakeLatex_debug
3765 silent echo a:run . " Run Second NoForce:" . ( condition_noforce && a:force == "" ) . " Force:" . ( condition_force && a:force == "!" )
3766 silent echo a:run . " BIBTEX: did_bibtex[updated]=" . did_bibtex . " references=" . references . " CROSSREF:" . cross_references . " INDEX:" . (index && !a:did_index)
3769 if ( condition_force && a:force == "!" ) || ( condition_noforce && a:force == "" )
3771 let bib_cmd = 'bibtex ' . auxfile . ' ; '
3772 let idx_cmd = 'makeindex ' . idxfile . ' ; '
3773 let message = "Making:"
3774 if ( bib_condition_force && a:force == "!" ) || ( bib_condition_noforce && a:force == "" )
3775 let bib_msg = ( bibtex ? ( did_bibtex == 0 ? " [bibtex,".Compiler."]" : " [".Compiler."]" ) : " [".Compiler."]" )
3776 let message .= " references".bib_msg.","
3777 let g:ml_debug .= "(make references)"
3779 if toc && a:run <= 2
3780 let message .= " toc,"
3782 if lof && a:run <= 2
3783 let message .= " lof,"
3785 if lot && a:run <= 2
3786 let message .= " lot,"
3788 if thm && a:run <= 2
3789 let message .= " theorem list,"
3792 let message .= " cross-references,"
3793 let g:ml_debug .= "(make cross-references)"
3795 if !a:did_index && index && idxfile_readable
3796 let message .= " index [makeindex]."
3797 let g:ml_debug .= "(make index)"
3799 let message = substitute(message, ',\s*$', '.', '')
3800 if !did_bibtex && auxfile_readable && bibtex
3801 let cmd .= bib_cmd . " "
3806 " If index was done:
3809 " If not and should be and the idx_file is readable
3810 elseif index && idxfile_readable
3811 let cmd .= idx_cmd . " "
3813 " If index should be done, wasn't but the idx_file is not readable (we need
3817 " If the index should not be done:
3821 let callback_cmd = v:progname . " --servername " . v:servername . " --remote-expr \"" . compiler_SID .
3822 \ "MakeLatex\(\'".texfile."\', ".did_bibtex." , ".did_index.", [".time[0].",".time[1]."], ".
3823 \ a:did_firstrun.", ".(a:run+1).", \'".a:force."\'\)\""
3824 let cmd .= b:atp_TexCompiler . tex_options . texfile . " ; " . callback_cmd
3826 if g:MakeLatex_debug
3827 silent echo a:run . " a:did_bibtex="a:did_bibtex . " did_bibtex=" . did_bibtex
3828 silent echo a:run . " Run Second CMD=" . cmd
3832 echomsg "[MakeLatex] " . message
3833 call system("(" . cmd . ")&")
3834 return "Making references|cross-references|index."
3837 " Post compeltion works:
3838 if g:MakeLatex_debug
3839 silent echo a:run . " END"
3846 if time != [] && len(time) == 2
3847 let show_time = matchstr(reltimestr(reltime(time)), '\d\+\.\d\d')
3850 if max([(a:run-1), 0]) == 1
3851 echomsg "[MakeLatex] " . max([(a:run-1), 0]) . " time in " . show_time . "sec."
3853 echomsg "[MakeLatex] " . max([(a:run-1), 0]) . " times in " . show_time . "sec."
3856 if b:atp_running >= 1
3857 let b:atp_running = b:atp_running - 1
3860 " THIS is a right place to call the viewer to reload the file
3861 " and the callback mechanism /debugging stuff/.
3862 if b:atp_Viewer == 'xpdf' && s:xpdfpid() != ""
3863 let pdffile = fnamemodify(a:texfile, ":r") . ".pdf"
3864 let Reload_Viewer = b:atp_Viewer." -remote ".shellescape(b:atp_XpdfServer)." -reload &"
3865 call system(Reload_Viewer)
3870 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
3871 if &l:filetype =~ 'tex$'
3872 call <SID>MakeLatex(atp_MainFile, 0,0, [],1,1,0,1)
3879 " THE MAIN COMPILER FUNCTION:
3881 " This is the MAIN FUNCTION which sets the command and calls it.
3882 " NOTE: the <filename> argument is not escaped!
3883 " a:verbose = silent/verbose/debug
3884 " debug -- switch to show errors after compilation.
3885 " verbose -- show compiling procedure.
3886 " silent -- compile silently (gives status information if fails)
3889 " 2 start viewer and make reverse search
3891 function! <SID>Compiler(bibtex, start, runs, verbose, command, filename, bang)
3893 if !has('gui') && a:verbose == 'verbose' && b:atp_running > 0
3895 echomsg "Please wait until compilation stops."
3899 if g:atp_debugCompiler
3900 redir! >> /tmp/ATP_CompilerLog
3901 silent echomsg "________ATP_COMPILER_LOG_________"
3902 silent echomsg "changedtick=" . b:changedtick . " atp_changedtick=" . b:atp_changedtick
3903 silent echomsg "a:bibtex=" . a:bibtex . " a:start=" . a:start . " a:runs=" . a:runs . " a:verbose=" . a:verbose . " a:command=" . a:command . " a:filename=" . a:filename . " a:bang=" . a:bang
3904 silent echomsg "1 b:changedtick=" . b:changedtick . " b:atp_changedtick" . b:atp_changedtick . " b:atp_running=" . b:atp_running
3907 if has('clientserver') && !empty(v:servername) && g:atp_callback && a:verbose != 'verbose'
3908 let b:atp_running+=1
3910 call atplib#outdir()
3911 " IF b:atp_TexCompiler is not compatible with the viewer
3912 " ToDo: (move this in a better place). (luatex can produce both pdf and dvi
3913 " files according to options so this is not the right approach.)
3914 if t:atp_DebugMode != "silent" && b:atp_TexCompiler !~ "luatex" &&
3915 \ (b:atp_TexCompiler =~ "^\s*\%(pdf\|xetex\)" && b:atp_Viewer == "xdvi" ? 1 :
3916 \ b:atp_TexCompiler !~ "^\s*pdf" && b:atp_TexCompiler !~ "xetex" && (b:atp_Viewer == "xpdf" || b:atp_Viewer == "epdfview" || b:atp_Viewer == "acroread" || b:atp_Viewer == "kpdf"))
3918 echohl WaningMsg | echomsg "Your ".b:atp_TexCompiler." and ".b:atp_Viewer." are not compatible:"
3919 echomsg "b:atp_TexCompiler=" . b:atp_TexCompiler
3920 echomsg "b:atp_Viewer=" . b:atp_Viewer
3923 " there is no need to run more than s:runlimit (=5) consecutive runs
3924 " this prevents from running tex as many times as the current line
3925 " what can be done by a mistake using the range for the command.
3926 if a:runs > s:runlimit
3927 let l:runs = s:runlimit
3932 let s:tmpdir=tempname()
3933 let s:tmpfile=atplib#append(s:tmpdir, "/") . fnamemodify(a:filename,":t:r")
3935 call mkdir(s:tmpdir, "p", 0700)
3937 echoerr 'Your vim doesn't have mkdir function, there is a workaround this though.
3938 \ Send an email to the author: mszamot@gmail.com '
3941 " SET THE NAME OF OUTPUT FILES
3942 " first set the extension pdf/dvi
3943 let ext = get(g:atp_CompilersDict, matchstr(b:atp_TexCompiler, '^\s*\zs\S\+\ze'), ".pdf")
3945 " check if the file is a symbolic link, if it is then use the target
3947 let l:link=system("readlink " . a:filename)
3949 let l:basename=fnamemodify(l:link,":r")
3951 let l:basename=a:filename
3954 " finally, set the output file names.
3955 let outfile = b:atp_OutDir . fnamemodify(l:basename,":t:r") . ext
3956 let outaux = b:atp_OutDir . fnamemodify(l:basename,":t:r") . ".aux"
3957 let tmpaux = fnamemodify(s:tmpfile, ":r") . ".aux"
3958 let tmptex = fnamemodify(s:tmpfile, ":r") . ".tex"
3959 let outlog = b:atp_OutDir . fnamemodify(l:basename,":t:r") . ".log"
3961 " COPY IMPORTANT FILES TO TEMP DIRECTORY WITH CORRECT NAME
3962 " except log and aux files.
3963 let l:list = copy(g:keep)
3964 call filter(l:list, 'v:val != "log" && v:val != "aux"')
3966 let l:ftc = b:atp_OutDir . fnamemodify(l:basename,":t:r") . "." . l:i
3967 if filereadable(l:ftc)
3968 call s:copy(l:ftc,s:tmpfile . "." . l:i)
3972 " HANDLE XPDF RELOAD
3973 if b:atp_Viewer =~ '^\s*xpdf\>'
3975 "if xpdf is not running and we want to run it.
3976 let Reload_Viewer = b:atp_Viewer . " -remote " . shellescape(b:atp_XpdfServer) . " " . shellescape(outfile) . " ; "
3978 " TIME: this take 1/3 of time! 0.039
3979 if <SID>xpdfpid() != ""
3980 "if xpdf is running (then we want to reload it).
3981 "This is where I use 'ps' command to check if xpdf is
3983 let Reload_Viewer = b:atp_Viewer . " -remote " . shellescape(b:atp_XpdfServer) . " -reload ; "
3985 "if xpdf is not running (but we do not want
3987 let Reload_Viewer = " "
3992 " if b:atp_Viewer is not running and we want to open it.
3993 let Reload_Viewer = b:atp_Viewer . " " . shellescape(outfile) . " ; "
3994 " If run through RevSearch command use source specials rather than
3996 if str2nr(a:start) == 2
3997 let callback_rs_cmd = " vim " . " --servername " . v:servername . " --remote-expr " . "'RevSearch()' ; "
3998 let Reload_Viewer = callback_rs_cmd
4001 " if b:atp_Viewer is not running then we do not want to
4003 let Reload_Viewer = " "
4007 " IF OPENING NON EXISTING OUTPUT FILE
4008 " only xpdf needs to be run before (we are going to reload it)
4009 if a:start && b:atp_Viewer == "xpdf"
4010 let xpdf_options = ( exists("g:atp_xpdfOptions") ? g:atp_xpdfOptions : "" )." ".getbufvar(0, "atp_xpdfOptions")
4011 let s:start = b:atp_Viewer . " -remote " . shellescape(b:atp_XpdfServer) . " " . xpdf_options . " & "
4017 let s:comp = b:atp_TexCompiler . " " . b:atp_TexOptions . " -interaction " . s:texinteraction . " -output-directory " . shellescape(s:tmpdir) . " " . shellescape(a:filename)
4018 let s:vcomp = b:atp_TexCompiler . " " . b:atp_TexOptions . " -interaction errorstopmode -output-directory " . shellescape(s:tmpdir) . " " . shellescape(a:filename)
4021 " let make = "vim --servername " . v:servername . " --remote-expr 'MakeLatex\(\"".tmptex."\",1,0\)'"
4023 if a:verbose == 'verbose'
4024 let s:texcomp=s:vcomp
4026 let s:texcomp=s:comp
4028 if l:runs >= 2 && a:bibtex != 1
4029 " how many times we want to call b:atp_TexCompiler
4031 while l:i < l:runs - 1
4033 let s:texcomp=s:texcomp . " ; " . s:comp
4035 if a:verbose != 'verbose'
4036 let s:texcomp=s:texcomp . " ; " . s:comp
4038 let s:texcomp=s:texcomp . " ; " . s:vcomp
4043 " this should be decided using the log file as well.
4044 if filereadable(outaux)
4045 call s:copy(outaux,s:tmpfile . ".aux")
4046 let s:texcomp="bibtex " . shellescape(s:tmpfile) . ".aux ; " . s:comp . " 1>/dev/null 2>&1 "
4048 let s:texcomp=s:comp . " ; clear ; bibtex " . shellescape(s:tmpfile) . ".aux ; " . s:comp . " 1>/dev/null 2>&1 "
4050 if a:verbose != 'verbose'
4051 let s:texcomp=s:texcomp . " ; " . s:comp
4053 let s:texcomp=s:texcomp . " ; " . s:vcomp
4058 if has('clientserver') && v:servername != "" && g:atp_callback == 1
4060 let catchstatus = s:SidWrap('CatchStatus')
4061 let catchstatus_cmd = 'vim ' . ' --servername ' . v:servername . ' --remote-expr ' .
4062 \ shellescape(catchstatus) . '\($?\) ; '
4065 let catchstatus_cmd = ''
4068 " copy output file (.pdf\|.ps\|.dvi)
4069 let s:cpoption="--remove-destination "
4070 let s:cpoutfile="cp " . s:cpoption . shellescape(atplib#append(s:tmpdir,"/")) . "*" . ext . " " . shellescape(atplib#append(b:atp_OutDir,"/")) . " ; "
4073 let s:command="(" . s:texcomp . " ; (" . catchstatus_cmd . " " . s:cpoutfile . " " . Reload_Viewer . " ) || ( ". catchstatus_cmd . " " . s:cpoutfile . ") ; "
4076 " for xpdf it copies the out file but does not reload the xpdf
4077 " server for other viewers it simply doesn't copy the out file.
4078 if b:atp_ReloadOnError || a:bang == "!"
4080 let s:command="( " . s:texcomp . " ; " . catchstatus_cmd . " cp --remove-destination " . shellescape(tmpaux) . " " . shellescape(b:atp_OutDir) . " ; " . s:cpoutfile . " " . Reload_Viewer
4082 let s:command="( (" . s:texcomp . " && cp --remove-destination " . shellescape(tmpaux) . " " . shellescape(b:atp_OutDir) . " ) ; " . catchstatus_cmd . " " . s:cpoutfile . " " . Reload_Viewer
4085 if b:atp_Viewer =~ '\<xpdf\>'
4086 let s:command="( " . s:texcomp . " && (" . catchstatus_cmd . s:cpoutfile . " " . Reload_Viewer . " cp --remove-destination ". shellescape(tmpaux) . " " . shellescape(b:atp_OutDir) . " ) || (" . catchstatus_cmd . " " . s:cpoutfile . ") ; "
4088 let s:command="(" . s:texcomp . " && (" . catchstatus_cmd . s:cpoutfile . " " . Reload_Viewer . " cp --remove-destination " . shellescape(tmpaux) . " " . shellescape(b:atp_OutDir) . " ) || (" . catchstatus_cmd . ") ; "
4093 if g:atp_debugCompiler
4094 silent echomsg "Reload_Viewer=" . Reload_Viewer
4095 let g:Reload_Viewer = Reload_Viewer
4096 let g:command = s:command
4097 elseif g:atp_debugCompiler >= 2
4098 silent echomsg "s:command=" . s:command
4101 " Preserve files with extension belonging to the g:keep list variable.
4104 for l:i in filter(copy(g:keep), 'v:val != "aux"')
4105 " ToDo: this can be done using internal vim functions.
4106 let s:copycmd=" cp " . s:cpoption . " " . shellescape(atplib#append(s:tmpdir,"/")) .
4107 \ "*." . l:i . " " . shellescape(atplib#append(b:atp_OutDir,"/"))
4109 let s:copy=s:copycmd
4111 let s:copy=s:copy . " ; " . s:copycmd
4115 let s:command=s:command . " " . s:copy . " ; "
4118 if has('clientserver') && v:servername != "" && g:atp_callback == 1
4120 let callback = s:SidWrap('CallBack')
4121 let callback_cmd = ' vim ' . ' --servername ' . v:servername . ' --remote-expr ' .
4122 \ shellescape(callback).'\(\"'.a:verbose.'\"\)'. " ; "
4124 let s:command = s:command . " " . callback_cmd
4128 if g:atp_debugCompiler
4129 silent echomsg "callback_cmd=" . callback_cmd
4132 let s:rmtmp="rm -r " . shellescape(s:tmpdir)
4133 let s:command=s:command . " " . s:rmtmp . ")&"
4135 if str2nr(a:start) != 0
4136 let s:command=s:start . s:command
4139 " Take care about backup and writebackup options.
4140 let s:backup=&backup
4141 let s:writebackup=&writebackup
4142 if a:command == "AU"
4143 if &backup || &writebackup | setlocal nobackup | setlocal nowritebackup | endif
4145 " This takes lots of time! 0.049s (more than 1/3)
4146 if g:atp_debugCompiler
4147 silent echomsg "BEFORE WRITING: b:changedtick=" . b:changedtick . " b:atp_changedtick=" . b:atp_changedtick . " b:atp_running=" . b:atp_running
4150 " let b:atp_changedtick += 1
4151 if g:atp_debugCompiler
4152 silent echomsg "AFTER WRITING: b:changedtick=" . b:changedtick . " b:atp_changedtick=" . b:atp_changedtick . " b:atp_running=" . b:atp_running
4154 if a:command == "AU"
4155 let &l:backup=s:backup
4156 let &l:writebackup=s:writebackup
4159 if a:verbose != 'verbose'
4160 call system(s:command)
4162 let s:command="!clear;" . s:texcomp . " " . s:cpoutfile . " " . s:copy
4166 unlockvar g:atp_TexCommand
4167 let g:atp_TexCommand=s:command
4168 lockvar g:atp_TexCommand
4171 if g:atp_debugCompiler
4172 silent echomsg "s:command=" . s:command
4178 " AUTOMATIC TEX PROCESSING:
4180 " This function calls the compilers in the background. It Needs to be a global
4181 " function (it is used in options.vim, there is a trick to put function into
4182 " a dictionary ... )
4183 augroup ATP_changedtick
4185 au BufEnter *.tex :let b:atp_changedtick = b:changedtick
4186 au BufWritePost *.tex :let b:atp_changedtick = b:changedtick
4189 function! <SID>auTeX()
4191 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
4193 " Using vcscommand plugin the diff window ends with .tex thus the autocommand
4194 " applies but the filetype is 'diff' thus we can switch tex processing by:
4195 if &l:filetype !~ "tex$"
4196 return "wrong file type"
4199 let mode = ( g:atp_DefaultDebugMode == 'verbose' ? 'debug' : g:atp_DefaultDebugMode )
4202 return "autex is off"
4205 " if the file (or input file is modified) compile the document
4206 if filereadable(expand("%"))
4207 if g:atp_Compare == "changedtick"
4208 let cond = ( b:changedtick != b:atp_changedtick )
4210 let cond = ( s:compare(readfile(expand("%"))) )
4213 " This is for changedtick only
4214 let b:atp_changedtick = b:changedtick + 1
4215 " +1 because s:Compiler saves the file what increases b:changedtick by 1.
4216 " this is still needed as I use not nesting BufWritePost autocommand to set
4217 " b:atp_changedtick (by default autocommands do not nest). Alternate solution is to
4218 " run s:AuTeX() with nested autocommand (|autocmd-nested|). But this seems
4219 " to be less user friendly, nested autocommands allows only 10 levels of
4220 " nesting (which seems to be high enough).
4224 call s:Compiler(0, 0, b:atp_auruns, mode, "AU", atp_MainFile, "")
4228 " if compiling for the first time
4231 " Do not write project script file while saving the file.
4232 let atp_ProjectScript = ( exists("g:atp_ProjectScript") ? g:atp_ProjectScript : -1 )
4233 let g:atp_ProjectScript = 0
4235 if atp_ProjectScript == -1
4236 unlet g:atp_ProjectScript
4238 let g:atp_ProjectScript = atp_ProjectScript
4242 echomsg expand("%") . "E212: Cannon open file for writing"
4246 " This option can be set by VCSCommand plugin using VCSVimDiff command
4249 call s:Compiler(0, 0, b:atp_auruns, mode, "AU", atp_MainFile, "")
4251 return "compile for the first time"
4253 return "files does not differ"
4256 " This is set by SetProjectName (options.vim) where it should not!
4259 au CursorHold *.tex call s:auTeX()
4260 au CursorHoldI *.tex if g:atp_insert_updatetime | call s:auTeX() | endif
4267 " a:runs = how many consecutive runs
4268 " a:1 = one of 'default','silent', 'debug', 'verbose'
4269 " if not specified uses 'default' mode
4270 " (g:atp_DefaultDebugMode).
4271 function! <SID>TeX(runs, bang, ...)
4273 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
4275 " echomsg "TEX_1 CHANGEDTICK=" . b:changedtick . " " . b:atp_running
4278 let mode = ( a:1 != 'default' ? a:1 : g:atp_DefaultDebugMode )
4280 let mode = g:atp_DefaultDebugMode
4283 for cmd in keys(g:CompilerMsg_Dict)
4284 if b:atp_TexCompiler =~ '^\s*' . cmd . '\s*$'
4285 let Compiler = g:CompilerMsg_Dict[cmd]
4288 let Compiler = b:atp_TexCompiler
4292 " echomsg "TEX_2 HANGEDTICK=" . b:changedtick . " " . b:atp_running
4294 if l:mode != 'silent'
4295 if a:runs > 2 && a:runs <= 5
4296 echomsg Compiler . " will run " . a:1 . " times."
4298 echomsg Compiler . " will run twice."
4300 echomsg Compiler . " will run once."
4302 echomsg Compiler . " will run " . s:runlimit . " times."
4305 " echomsg "TEX_3 HANGEDTICK=" . b:changedtick . " " . b:atp_running
4306 call s:Compiler(0,0, a:runs, mode, "COM", atp_MainFile, a:bang)
4307 " echomsg "TEX_4 HANGEDTICK=" . b:changedtick . " " . b:atp_running
4309 function! TEX_Comp(ArgLead, CmdLine, CursorPos)
4310 return filter(['silent', 'debug', 'verbose'], "v:val =~ '^' . a:ArgLead")
4312 " command! -buffer -count=1 VTEX :call <SID>TeX(<count>, 'verbose')
4313 noremap <silent> <Plug>ATP_TeXCurrent :<C-U>call <SID>TeX(v:count1, "", t:atp_DebugMode)<CR>
4314 noremap <silent> <Plug>ATP_TeXDefault :<C-U>call <SID>TeX(v:count1, "", 'default')<CR>
4315 noremap <silent> <Plug>ATP_TeXSilent :<C-U>call <SID>TeX(v:count1, "", 'silent')<CR>
4316 noremap <silent> <Plug>ATP_TeXDebug :<C-U>call <SID>TeX(v:count1, "", 'debug')<CR>
4317 noremap <silent> <Plug>ATP_TeXVerbose :<C-U>call <SID>TeX(v:count1, "", 'verbose')<CR>
4318 inoremap <silent> <Plug>iATP_TeXVerbose <Esc>:<C-U>call <SID>TeX(v:count1, "", 'verbose')<CR>
4321 function! <SID>SimpleBibtex()
4322 let bibcommand = "bibtex "
4323 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
4324 let auxfile = b:atp_OutDir . (fnamemodify(resolve(atp_MainFile),":t:r")) . ".aux"
4325 if filereadable(auxfile)
4326 let command = bibcommand . shellescape(l:auxfile)
4327 echo system(command)
4329 echomsg "aux file " . auxfile . " not readable."
4332 " command! -buffer SBibtex :call <SID>SimpleBibtex()
4333 nnoremap <silent> <Plug>SimpleBibtex :call <SID>SimpleBibtex()<CR>
4335 function! <SID>Bibtex(bang,...)
4337 call <SID>SimpleBibtex()
4341 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
4344 let mode = ( a:1 != 'default' ? a:1 : g:atp_DefaultDebugMode )
4346 let mode = g:atp_DefaultDebugMode
4349 call s:Compiler(1, 0, 0, mode, "COM", atp_MainFile, "")
4351 nnoremap <silent> <Plug>BibtexDefault :call <SID>Bibtex("", "")<CR>
4352 nnoremap <silent> <Plug>BibtexSilent :call <SID>Bibtex("", "silent")<CR>
4353 nnoremap <silent> <Plug>BibtexDebug :call <SID>Bibtex("", "debug")<CR>
4354 nnoremap <silent> <Plug>BibtexVerbose :call <SID>Bibtex("", "verbose")<CR>
4357 " Show Errors Function
4358 " (some error tools are in various.vim: ':ShowErrors o')
4361 " this functions sets errorformat according to the flag given in the argument,
4363 " e - errors (or empty flag)
4364 " w - all warning messages
4365 " c - citation warning messages
4366 " r - reference warning messages
4367 " f - font warning messages
4368 " fi - font warning and info messages
4370 " p - package info messages
4372 " {{{ s:SetErrorFormat
4373 " first argument is a word in flags
4374 " the default is a:1=e /show only error messages/
4375 function! <SID>SetErrorFormat(...)
4382 let &l:errorformat=""
4383 if a:0 == 0 || a:0 > 0 && a:1 =~ 'e'
4384 if &l:errorformat == ""
4385 let &l:errorformat= "%E!\ LaTeX\ %trror:\ %m,\%E!\ %m"
4387 let &l:errorformat= &l:errorformat . ",%E!\ LaTeX\ %trror:\ %m,\%E!\ %m"
4390 if a:0>0 && a:1 =~ 'w'
4391 if &l:errorformat == ""
4392 let &l:errorformat='%WLaTeX\ %tarning:\ %m\ on\ input\ line\ %l%.,
4393 \%WLaTeX\ %.%#Warning:\ %m,
4394 \%Z(Font) %m\ on\ input\ line\ %l%.,
4395 \%+W%.%#\ at\ lines\ %l--%*\\d'
4397 let &l:errorformat= &l:errorformat . ',%WLaTeX\ %tarning:\ %m\ on\ input\ line\ %l%.,
4398 \%WLaTeX\ %.%#Warning:\ %m,
4399 \%Z(Font) %m\ on\ input\ line\ %l%.,
4400 \%+W%.%#\ at\ lines\ %l--%*\\d'
4401 " let &l:errorformat= &l:errorformat . ',%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#,
4402 " \%WLaTeX\ %.%#Warning:\ %m,
4403 " \%+W%.%#\ at\ lines\ %l--%*\\d'
4406 if a:0>0 && a:1 =~ '\Cc'
4408 " I would like to include 'Reference/Citation' as an error message (into %m)
4409 " but not include the 'LaTeX Warning:'. I don't see how to do that actually.
4410 " The only solution, that I'm aware of, is to include the whole line using
4411 " '%+W' but then the error messages are long and thus not readable.
4412 if &l:errorformat == ""
4413 let &l:errorformat = "%WLaTeX\ Warning:\ Citation\ %m\ on\ input\ line\ %l%.%#"
4415 let &l:errorformat = &l:errorformat . ",%WLaTeX\ Warning:\ Citation\ %m\ on\ input\ line\ %l%.%#"
4418 if a:0>0 && a:1 =~ '\Cr'
4419 if &l:errorformat == ""
4420 let &l:errorformat = "%WLaTeX\ Warning:\ Reference %m on\ input\ line\ %l%.%#,%WLaTeX\ %.%#Warning:\ Reference %m,%C %m on input line %l%.%#"
4422 let &l:errorformat = &l:errorformat . ",%WLaTeX\ Warning:\ Reference %m on\ input\ line\ %l%.%#,%WLaTeX\ %.%#Warning:\ Reference %m,%C %m on input line %l%.%#"
4425 if a:0>0 && a:1 =~ '\Cf'
4426 if &l:errorformat == ""
4427 let &l:errorformat = "%WLaTeX\ Font\ Warning:\ %m,%Z(Font) %m on input line %l%.%#"
4429 let &l:errorformat = &l:errorformat . ",%WLaTeX\ Font\ Warning:\ %m,%Z(Font) %m on input line %l%.%#"
4432 if a:0>0 && a:1 =~ '\Cfi'
4433 if &l:errorformat == ""
4434 let &l:errorformat = '%ILatex\ Font\ Info:\ %m on input line %l%.%#,
4435 \%ILatex\ Font\ Info:\ %m,
4436 \%Z(Font) %m\ on input line %l%.%#,
4437 \%C\ %m on input line %l%.%#'
4439 let &l:errorformat = &l:errorformat . ',%ILatex\ Font\ Info:\ %m on input line %l%.%#,
4440 \%ILatex\ Font\ Info:\ %m,
4441 \%Z(Font) %m\ on input line %l%.%#,
4442 \%C\ %m on input line %l%.%#'
4445 if a:0>0 && a:1 =~ '\CF'
4446 if &l:errorformat == ""
4447 let &l:errorformat = 'File: %m'
4449 let &l:errorformat = &l:errorformat . ',File: %m'
4452 if a:0>0 && a:1 =~ '\Cp'
4453 if &l:errorformat == ""
4454 let &l:errorformat = 'Package: %m'
4456 let &l:errorformat = &l:errorformat . ',Package: %m'
4459 if &l:errorformat != ""
4461 let pm = ( g:atp_show_all_lines == 1 ? '+' : '-' )
4463 let l:dont_ignore = 0
4464 if a:0 >= 1 && a:1 =~ '\cALL'
4465 let l:dont_ignore = 1
4468 let b:dont_ignore=l:dont_ignore.a:0
4470 let &l:errorformat = &l:errorformat.",
4472 \%".pm."C\ \ %m%.%#,
4474 \%".pm."C%.%#[]%.%#,
4476 \%".pm."C%.%#%[{}\\]%.%#,
4477 \%".pm."C<%.%#>%.%#,
4479 \%".pm."GSee\ the\ LaTeX%m,
4480 \%".pm."GType\ \ H\ <return>%m,
4481 \%".pm."G%.%#\ (C)\ %.%#,
4482 \%".pm."G(see\ the\ transcript%.%#),
4484 if (g:atp_ignore_unmatched && !g:atp_show_all_lines)
4485 exec 'setlocal efm+=%-G%.%#'
4486 elseif l:dont_ignore
4487 exec 'setlocal efm+=%-G%.%#'
4489 let &l:errorformat = &l:errorformat.",
4490 \%".pm."O(%*[^()])%r,
4491 \%".pm."O%*[^()](%*[^()])%r,
4493 \%".pm."P\ %\\=(%f%r,
4494 \%".pm."P%*[^()](%f%r,
4495 \%".pm."P[%\\d%[^()]%#(%f%r"
4496 if g:atp_ignore_unmatched && !g:atp_show_all_lines
4497 exec 'setlocal efm+=%-P%*[^()]'
4498 elseif l:dont_ignore
4499 exec 'setlocal efm+=%-P%*[^()]'
4501 let &l:errorformat = &l:errorformat.",
4503 \%".pm."Q%*[^()])%r,
4504 \%".pm."Q[%\\d%*[^()])%r"
4505 if g:atp_ignore_unmatched && !g:atp_show_all_lines
4506 let &l:errorformat = &l:errorformat.",%-Q%*[^()]"
4507 elseif l:dont_ignore
4508 let &l:errorformat = &l:errorformat.",%-Q%*[^()]"
4511 " removed after GType
4517 " each argument can be a word in flags as for s:SetErrorFormat (except the
4518 " word 'whole') + two other flags: all (include all errors) and ALL (include
4519 " all errors and don't ignore any line - this overrides the variables
4520 " g:atp_ignore_unmatched and g:atp_show_all_lines.
4521 function! <SID>ShowErrors(...)
4523 let errorfile = &l:errorfile
4524 " read the log file and merge warning lines
4525 " filereadable doesn't like shellescaped file names not fnameescaped.
4526 " The same for readfile() and writefile() built in functions.
4527 if !filereadable( errorfile)
4529 echomsg "No error file: " . errorfile
4534 let l:log=readfile(errorfile)
4538 if l:line =~ "LaTeX Warning:" && l:log[l:nr] !~ "^$"
4539 let l:newline=l:line . l:log[l:nr]
4540 let l:log[l:nr-1]=l:newline
4541 call remove(l:log,l:nr)
4545 call writefile(l:log, errorfile)
4548 let l:arg = ( a:0 > 0 ? a:1 : "e" )
4553 call s:SetErrorFormat(l:arg)
4555 let l:show_message = ( a:0 >= 2 ? a:2 : 1 )
4561 if len(getqflist()) == 0
4572 if !exists("*ListErrorsFlags")
4573 function! ListErrorsFlags(A,L,P)
4574 return "e\nw\nc\nr\ncr\nf\nfi\nall\nF"
4581 command! -buffer -nargs=? ViewOutput :call <SID>ViewOutput(<f-args>)
4582 command! -buffer PID :call <SID>GetPID()
4583 command! -buffer -bang MakeLatex :call <SID>MakeLatex(( g:atp_RelativePath ? globpath(b:atp_ProjectDir, fnamemodify(b:atp_MainFile, ":t")) : b:atp_MainFile ), 0,0, [],1,1,<q-bang>,1)
4584 command! -buffer -nargs=? -bang -count=1 -complete=customlist,TEX_Comp TEX :call <SID>TeX(<count>, <q-bang>, <f-args>)
4585 command! -buffer -count=1 DTEX :call <SID>TeX(<count>, <q-bang>, 'debug')
4586 command! -buffer -bang -nargs=? Bibtex :call <SID>Bibtex(<q-bang>, <f-args>)
4587 command! -buffer -nargs=? SetErrorFormat :call <SID>SetErrorFormat(<f-args>)
4588 command! -buffer -nargs=? SetErrorFormat :call <SID>SetErrorFormat(<f-args>)
4589 command! -buffer -nargs=? -complete=custom,ListErrorsFlags ShowErrors :call <SID>ShowErrors(<f-args>)
4590 " vim:fdm=marker:tw=85:ff=unix:noet:ts=8:sw=4:fdc=1
4591 ftplugin/ATP_files/mappings.vim [[[1
4593 " Author: Marcin Szmotulski
4594 " Description: This file contains mappings defined by ATP.
4595 " Note: This file is a part of Automatic Tex Plugin for Vim.
4596 " URL: https://launchpad.net/automatictexplugin
4599 " Commands to library functions (autoload/atplib.vim)
4600 command! -buffer -bang -nargs=* FontSearch :call atplib#FontSearch(<q-bang>, <f-args>)
4601 command! -buffer -bang -nargs=* FontPreview :call atplib#FontPreview(<q-bang>,<f-args>)
4602 command! -buffer -nargs=1 -complete=customlist,atplib#Fd_completion OpenFdFile :call atplib#OpenFdFile(<f-args>)
4603 command! -buffer -nargs=* CloseLastEnvironment :call atplib#CloseLastEnvironment(<f-args>)
4604 command! -buffer CloseLastBracket :call atplib#CloseLastBracket()
4605 let g:atp_map_list = [
4606 \ [ g:atp_map_forward_motion_leader, 'i', ':NInput<CR>', 'nmap <buffer>' ],
4607 \ [ g:atp_map_backward_motion_leader, 'i', ':NPnput<CR>', 'nmap <buffer>' ],
4608 \ [ g:atp_map_forward_motion_leader, 'gf', ':NInput<CR>', 'nmap <buffer>' ],
4609 \ [ g:atp_map_backward_motion_leader, 'gf', ':NPnput<CR>', 'nmap <buffer>' ],
4610 \ [ g:atp_map_forward_motion_leader, 'S', '<Plug>GotoNextSubSection', 'nmap <buffer>' ],
4611 \ [ g:atp_map_backward_motion_leader, 'S', '<Plug>vGotoNextSubSection', 'nmap <buffer>' ],
4613 execute "nmap <buffer> ".g:atp_map_forward_motion_leader."i :NInput<CR>"
4614 execute "nmap <buffer> ".g:atp_map_backward_motion_leader."i :PInput<CR>"
4615 execute "nmap <buffer> ".g:atp_map_forward_motion_leader."gf :NInput<CR>"
4616 execute "nmap <buffer> ".g:atp_map_backward_motion_leader."gf :PInput<CR>"
4619 imap <C-j> <Plug>TexSyntaxMotionForward
4620 imap <C-k> <Plug>TexSyntaxMotionBackward
4621 nmap <C-j> <Plug>TexSyntaxMotionForward
4622 nmap <C-k> <Plug>TexSyntaxMotionBackward
4624 " Add maps, unless the user didn't want them.
4625 if ( !exists("g:no_plugin_maps") || exists("g:no_plugin_maps") && g:no_plugin_maps == 0 ) &&
4626 \ ( !exists("g:no_atp_maps") || exists("g:no_plugin_maps") && g:no_atp_maps == 0 )
4628 " ToDo to doc. + vmaps!
4629 execute "nmap <buffer> ".g:atp_map_forward_motion_leader."S <Plug>GotoNextSubSection"
4630 execute "vmap <buffer> ".g:atp_map_forward_motion_leader."S <Plug>vGotoNextSubSection"
4631 execute "nmap <buffer> ".g:atp_map_backward_motion_leader."S <Plug>GotoPreviousSubSection"
4632 execute "vmap <buffer> ".g:atp_map_backward_motion_leader."S <Plug>vGotoPreviousSubSection"
4633 " Toggle this maps on/off!
4634 execute "nmap <buffer> ".g:atp_map_forward_motion_leader."s <Plug>GotoNextSection"
4635 execute "vmap <buffer> ".g:atp_map_forward_motion_leader."s <Plug>vGotoNextSection"
4636 execute "nmap <buffer> ".g:atp_map_backward_motion_leader."s <Plug>GotoPreviousSection"
4637 execute "vmap <buffer> ".g:atp_map_backward_motion_leader."s <Plug>vGotoPreviousSection"
4638 if !( g:atp_map_forward_motion_leader == "]" && &l:diff )
4639 execute "nmap <buffer> ".g:atp_map_forward_motion_leader."c <Plug>GotoNextChapter"
4640 execute "vmap <buffer> ".g:atp_map_forward_motion_leader."c <Plug>vGotoNextChapter"
4642 if !( g:atp_map_backward_motion_leader == "]" && &l:diff )
4643 execute "nmap <buffer> ".g:atp_map_backward_motion_leader."c <Plug>GotoPreviousChapter"
4644 execute "vmap <buffer> ".g:atp_map_backward_motion_leader."c <Plug>vGotoPreviousChapter"
4646 execute "nmap <buffer> ".g:atp_map_forward_motion_leader."p <Plug>GotoNextPart"
4647 execute "vmap <buffer> ".g:atp_map_forward_motion_leader."p <Plug>vGotoNextPart"
4648 execute "nmap <buffer> ".g:atp_map_backward_motion_leader."p <Plug>GotoPreviousPart"
4649 execute "vmap <buffer> ".g:atp_map_backward_motion_leader."p <Plug>vGotoPreviousPart"
4651 execute "map <buffer> ".g:atp_map_forward_motion_leader."e <Plug>GotoNextEnvironment"
4652 execute "map <buffer> ".g:atp_map_backward_motion_leader."e <Plug>GotoPreviousEnvironment"
4653 " exe "map <buffer> ".g:atp_map_forward_motion_leader." <Plug>GotoNextEnvironment"
4654 " exe "map <buffer> ".g:atp_map_backward_motion_leader." <Plug>GotoPreviousEnvironment"
4655 " map <buffer> ]m <Plug>GotoNextInlineMath
4656 " map <buffer> [m <Plug>GotoPreviousInlineMath
4657 execute "map <buffer> ".g:atp_map_forward_motion_leader."m <Plug>GotoNextMath"
4658 execute "map <buffer> ".g:atp_map_backward_motion_leader."m <Plug>GotoPreviousMath"
4659 execute "map <buffer> ".g:atp_map_forward_motion_leader."M <Plug>GotoNextDisplayedMath"
4660 execute "map <buffer> ".g:atp_map_backward_motion_leader."M <Plug>GotoPreviousDisplayedMath"
4663 if has("path_extra")
4664 nnoremap <buffer> <silent> gf :call GotoFile("")<CR>
4667 if exists("g:atp_no_tab_map") && g:atp_no_tab_map == 1
4668 imap <silent> <buffer> <F7> <C-R>=atplib#TabCompletion(1)<CR>
4669 nnoremap <silent> <buffer> <F7> :call atplib#TabCompletion(1,1)<CR>
4670 imap <silent> <buffer> <S-F7> <C-R>=atplib#TabCompletion(0)<CR>
4671 nnoremap <silent> <buffer> <S-F7> :call atplib#TabCompletion(0,1)<CR>
4674 imap <silent> <buffer> <Tab> <C-R>=atplib#TabCompletion(1)<CR>
4675 imap <silent> <buffer> <S-Tab> <C-R>=atplib#TabCompletion(0)<CR>
4676 " HOW TO: do this with <tab>? Streightforward solution interacts with
4677 " other maps (e.g. after \l this map is called).
4678 " when this is set it also runs after the \l map: ?!?
4679 " nmap <silent> <buffer> <Tab> :call atplib#TabCompletion(1,1)<CR>
4680 nnoremap <silent> <buffer> <S-Tab> :call atplib#TabCompletion(0,1)<CR>
4681 vnoremap <buffer> <silent> <F7> :WrapSelection '\{','}','begin'<CR>
4685 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."f :WrapSelection '{\\usefont{".g:atp_font_encoding."}{}{}{}\\selectfont ', '}', '".(len(g:atp_font_encoding)+11)."'<CR>"
4688 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."rm :<C-U>InteligentWrapSelection ['\\textrm{'],['\\mathrm{']<CR>"
4689 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."em :<C-U>InteligentWrapSelection ['\\emph{'],['\\mathit{']<CR>"
4691 " execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."tx :<C-U>InteligentWrapSelection [''],['\\text{']<CR>"
4692 " execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."in :<C-U>InteligentWrapSelection [''],['\\intertext{']<CR>"
4693 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."it :<C-U>InteligentWrapSelection ['\\textit{'],['\\mathit{']<CR>"
4694 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."sf :<C-U>InteligentWrapSelection ['\\textsf{'],['\\mathsf{']<CR>"
4695 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."tt :<C-U>InteligentWrapSelection ['\\texttt{'],['\\mathtt{']<CR>"
4696 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."bf :<C-U>InteligentWrapSelection ['\\textbf{'],['\\mathbf{']<CR>"
4697 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."bb :<C-U>InteligentWrapSelection ['\\textbf{'],['\\mathbb{']<CR>"
4698 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."sl :<C-U>WrapSelection '\\textsl{'<CR>"
4699 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."sc :<C-U>WrapSelection '\\textsc{'<CR>"
4700 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."up :<C-U>WrapSelection '\\textup{'<CR>"
4701 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."md :<C-U>WrapSelection '\\textmd{'<CR>"
4702 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."un :<C-U>WrapSelection '\\underline{'<CR>"
4703 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."ov :<C-U>WrapSelection '\\overline{'<CR>"
4704 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."no :<C-U>InteligentWrapSelection ['\\textnormal{'],['\\mathnormal{']<CR>"
4705 execute "vnoremap <buffer> ".g:atp_vmap_text_font_leader."cal :<C-U>InteligentWrapSelection [''],['\\mathcal{']<CR>"
4708 execute "vnoremap <buffer> ".g:atp_vmap_environment_leader."C :WrapSelection '"."\\"."begin{center}','"."\\"."end{center}','0','1'<CR>"
4709 execute "vnoremap <buffer> ".g:atp_vmap_environment_leader."R :WrapSelection '"."\\"."begin{flushright}','"."\\"."end{flushright}','0','1'<CR>"
4710 execute "vnoremap <buffer> ".g:atp_vmap_environment_leader."L :WrapSelection '"."\\"."begin{flushleft}','"."\\"."end{flushleft}','0','1'<CR>"
4713 vmap <buffer> m :<C-U>WrapSelection '\(', '\)'<CR>
4714 vmap <buffer> M :<C-U>WrapSelection '\[', '\]'<CR>
4717 execute "vnoremap <buffer> ".g:atp_vmap_bracket_leader."( :WrapSelection '(', ')', 'begin'<CR>"
4718 execute "vnoremap <buffer> ".g:atp_vmap_bracket_leader."[ :WrapSelection '[', ']', 'begin'<CR>"
4719 execute "vnoremap <buffer> ".g:atp_vmap_bracket_leader."\\{ :WrapSelection '\\{', '\\}', 'begin'<CR>"
4720 execute "vnoremap <buffer> ".g:atp_vmap_bracket_leader."{ :WrapSelection '{', '}', 'begin'<CR>"
4721 " execute "vnoremap <buffer> ".g:atp_vmap_bracket_leader."{ :<C-U>InteligentWrapSelection ['{', '}'],['\\{', '\\}']<CR>"
4722 execute "vnoremap <buffer> ".g:atp_vmap_bracket_leader.") :WrapSelection '(', ')', 'end'<CR>"
4723 execute "vnoremap <buffer> ".g:atp_vmap_bracket_leader."] :WrapSelection '[', ']', 'end'<CR>"
4724 execute "vnoremap <buffer> ".g:atp_vmap_bracket_leader."\\} :WrapSelection '\\{', '\\}', 'end'<CR>"
4725 execute "vnoremap <buffer> ".g:atp_vmap_bracket_leader."} :WrapSelection '{', '}', 'end'<CR>"
4727 execute "vnoremap <buffer> ".g:atp_vmap_big_bracket_leader."( :WrapSelection '\\left(', '\\right)', 'begin'<CR>"
4728 execute "vnoremap <buffer> ".g:atp_vmap_big_bracket_leader."[ :WrapSelection '\\left[', '\\right]', 'begin'<CR>"
4729 execute "vnoremap <buffer> ".g:atp_vmap_big_bracket_leader."{ :WrapSelection '\\left\\{','\\right\\}', 'begin'<CR>"
4730 " for compatibility:
4731 execute "vnoremap <buffer> ".g:atp_vmap_big_bracket_leader."\\{ :WrapSelection '\\left\\{','\\right\\}', 'begin'<CR>"
4732 execute "vnoremap <buffer> ".g:atp_vmap_big_bracket_leader.") :WrapSelection '\\left(', '\\right)', 'end'<CR>"
4733 execute "vnoremap <buffer> ".g:atp_vmap_big_bracket_leader."] :WrapSelection '\\left[', '\\right]', 'end'<CR>"
4734 execute "vnoremap <buffer> ".g:atp_vmap_big_bracket_leader."} :WrapSelection '\\left\\{', '\\right\\}', 'end'<CR>"
4735 " for compatibility:
4736 execute "vnoremap <buffer> ".g:atp_vmap_big_bracket_leader."\\} :WrapSelection '\\left\\{', '\\right\\}', 'end'<CR>"
4739 nmap <Localleader>a :TexAlign<CR>
4740 " Paragraph Selecting:
4741 vmap <silent> <buffer> ip <Plug>ATP_SelectCurrentParagraphInner
4742 vmap <silent> <buffer> ap <Plug>ATP_SelectCurrentParagraphOuter
4743 omap <buffer> ip :normal vip<CR>
4744 omap <buffer> ap :normal vap<CR>
4747 nmap <buffer> gw m`vipgq``
4749 nmap <buffer> g> m`vip>``
4750 nmap <buffer> g< m`vip<``
4751 nmap <buffer> 2g> m`vip2>``
4752 nmap <buffer> 2g< m`vip2<``
4753 nmap <buffer> 3g> m`vip3>``
4754 nmap <buffer> 3g< m`vip3<``
4755 nmap <buffer> 4g> m`vip4>``
4756 nmap <buffer> 4g< m`vip4<``
4757 nmap <buffer> 5g> m`vip5>``
4758 nmap <buffer> 5g< m`vip5<``
4759 nmap <buffer> 6g> m`vip6>``
4760 nmap <buffer> 6g< m`vip6<``
4762 vmap <buffer> <silent> aS <Plug>SelectOuterSyntax
4763 vmap <buffer> <silent> iS <Plug>SelectInnerSyntax
4765 " From vim.vim plugin (by Bram Mooleaner)
4766 " Move around functions.
4767 nnoremap <silent><buffer> [[ m':call search('\\begin\s*{', "bW")<CR>
4768 vnoremap <silent><buffer> [[ m':<C-U>exe "normal! gv"<Bar>call search('\\begin\s*{', "bW")<CR>
4769 nnoremap <silent><buffer> ]] m':call search('\\begin\s*{', "W")<CR>
4770 vnoremap <silent><buffer> ]] m':<C-U>exe "normal! gv"<Bar>call search('\\begin\s*{', "W")<CR>
4771 nnoremap <silent><buffer> [] m':call search('\\end\s*{', "bW")<CR>
4772 vnoremap <silent><buffer> [] m':<C-U>exe "normal! gv"<Bar>call search('\\end\s*{', "bW")<CR>
4773 nnoremap <silent><buffer> ][ m':call search('\\end\s*{', "W")<CR>
4774 vnoremap <silent><buffer> ][ m':<C-U>exe "normal! gv"<Bar>call search('\\end\s*{', "W")<CR>
4776 " Move around comments
4777 nnoremap <silent><buffer> ]% :call search('^\(\s*%.*\n\)\@<!\(\s*%\)', "W")<CR>
4778 vnoremap <silent><buffer> ]% :<C-U>exe "normal! gv"<Bar>call search('^\(\s*%.*\n\)\@<!\(\s*%\)', "W")<CR>
4779 nnoremap <silent><buffer> [% :call search('\%(^\s*%.*\n\)\%(^\s*%\)\@!', "bW")<CR>
4780 vnoremap <silent><buffer> [% :<C-U>exe "normal! gv"<Bar>call search('\%(^\s*%.*\n\)\%(^\s*%\)\@!', "bW")<CR>
4783 vmap <silent><buffer> c <Plug>vSelectComment
4785 " Normal mode maps (mostly)
4786 nmap <buffer> <LocalLeader>v <Plug>ATP_ViewOutput
4787 nmap <buffer> <F2> <Plug>ToggleSpace
4788 nmap <buffer> <LocalLeader>s <Plug>ToggleStar
4790 nmap <buffer> <LocalLeader>D <Plug>ToggleDebugMode
4791 nmap <buffer> <F4> <Plug>ChangeEnv
4792 nmap <buffer> <S-F4> <Plug>ToggleEnvForward
4793 " nmap <buffer> <S-F4> <Plug>ToggleEnvBackward
4794 nmap <buffer> <C-S-F4> <Plug>LatexEnvPrompt
4797 " nmap <buffer> <F3> :call <Sid>ChangeEnv()<CR>
4799 nmap <buffer> <F3> <Plug>ATP_ViewOutput
4800 imap <buffer> <F3> <Esc><Plug>ATP_ViewOutput
4801 nmap <buffer> <LocalLeader>g <Plug>Getpid
4802 nmap <buffer> <LocalLeader>t <Plug>ATP_TOC
4803 nmap <buffer> <LocalLeader>L <Plug>ATP_Labels
4804 nmap <buffer> <LocalLeader>l <Plug>ATP_TeXCurrent
4805 nmap <buffer> <LocalLeader>d <Plug>ATP_TeXDebug
4807 nmap <buffer> <F5> <Plug>ATP_TeXVerbose
4808 nmap <buffer> <s-F5> <Plug>ToggleAuTeX
4809 imap <buffer> <s-F5> <Esc><Plug>ToggleAuTeXa
4810 nmap <buffer> `<Tab> <Plug>ToggleTab
4811 imap <buffer> `<Tab> <Plug>ToggleTab
4812 nmap <buffer> <LocalLeader>B <Plug>SimpleBibtex
4813 nmap <buffer> <LocalLeader>b <Plug>BibtexDefault
4814 nmap <buffer> <F6>d <Plug>Delete
4815 imap <buffer> <F6>d <Esc><Plug>Deletea
4816 nmap <buffer> <silent> <F6>l <Plug>OpenLog
4817 imap <buffer> <silent> <F6>l <Esc><Plug>OpenLog
4818 " nmap <buffer<LocalLeader>e :cf<CR>
4819 nnoremap <buffer> <F6> :ShowErrors e<CR>
4820 inoremap <buffer> <F6>e :ShowErrors e<CR>
4821 nnoremap <buffer> <F6>w :ShowErrors w<CR>
4822 inoremap <buffer> <F6>w :ShowErrors w<CR>
4823 nnoremap <buffer> <F6>r :ShowErrors rc<CR>
4824 nnoremap <buffer> <F6>r :ShowErrors rc<CR>
4825 nnoremap <buffer> <F6>f :ShowErrors f<CR>
4826 inoremap <buffer> <F6>f :ShowErrors f<CR>
4827 nnoremap <buffer> <F6>g <Plug>PdfFonts
4828 nnoremap <buffer> <F1> :TexDoc<space>
4829 inoremap <buffer> <F1> <esc> :TexDoc<space>
4830 " nmap <buffer> <LocalLeader>pr <Plug>SshPrint
4833 " execute 'imap <buffer> '.g:atp_imap_second_leader.'rm \textrm{}<Left>'
4834 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'rm <Esc>:call Insert("\\textrm{", "\\mathrm{")<Cr>a'
4835 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'up \textup{}<Left>'
4836 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'md \textmd{}<Left>'
4837 " execute 'inoremap <buffer>' .g:atp_imap_second_leader.'it \textit{}<Left>'
4838 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'it <Esc>:call Insert("\\textit{", "\\mathit{")<Cr>a'
4839 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'sl \textsl{}<Left>'
4840 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'sc \textsc{}<Left>'
4841 " execute 'inoremap <buffer>' .g:atp_imap_second_leader.'sf \textsf{}<Left>'
4842 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'sf <Esc>:call Insert("\\textsf{", "\\mathsf{")<Cr>a'
4843 " execute 'inoremap <buffer>' .g:atp_imap_second_leader.'bf \textbf{}<Left>'
4844 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'bf <Esc>:call Insert("\\textbf{", "\\mathbf{")<Cr>a'
4845 " execute 'inoremap <buffer>' .g:atp_imap_second_leader.'tt \texttt{}<Left>'
4846 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'tt <Esc>:call Insert("\\texttt{", "\\mathtt{")<Cr>a'
4847 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'em \emph{}<Left>'
4848 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'no <Esc>:call Insert("\\textnormal{", "\\mathnormal{")<Cr>a'
4850 " execute 'inoremap <buffer>' .g:atp_imap_second_leader.'mit \mathit{}<Left>'
4851 " execute 'inoremap <buffer>' .g:atp_imap_second_leader.'mrm \mathrm{}<Left>'
4852 " execute 'inoremap <buffer>' .g:atp_imap_second_leader.'msf \mathsf{}<Left>'
4853 " execute 'inoremap <buffer>' .g:atp_imap_second_leader.'mbf \mathbf{}<Left>'
4854 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'bb \mathbb{}<Left>'
4855 " execute 'imap <buffer>' .g:atp_imap_second_leader.'mtt \mathtt{}<Left>'
4856 execute 'inoremap <buffer>' .g:atp_imap_second_leader.'cal \mathcal{}<Left>'
4859 execute 'imap <buffer> '.g:atp_imap_first_leader.'a \alpha'
4860 execute 'imap <buffer> '.g:atp_imap_first_leader.'b \beta'
4861 execute 'imap <buffer> '.g:atp_imap_first_leader.'c \chi'
4862 execute 'imap <buffer> '.g:atp_imap_first_leader.'d \delta'
4863 execute 'imap <buffer> '.g:atp_imap_first_leader.'e \epsilon'
4864 execute 'imap <buffer> '.g:atp_imap_first_leader.'ve \varepsilon'
4865 execute 'imap <buffer> '.g:atp_imap_first_leader.'f \phi'
4866 execute 'imap <buffer> '.g:atp_imap_first_leader.'y \psi'
4867 execute 'imap <buffer> '.g:atp_imap_first_leader.'g \gamma'
4868 execute 'imap <buffer> '.g:atp_imap_first_leader.'h \eta'
4869 execute 'imap <buffer> '.g:atp_imap_first_leader.'k \kappa'
4870 execute 'imap <buffer> '.g:atp_imap_first_leader.'l \lambda'
4871 execute 'imap <buffer> '.g:atp_imap_first_leader.'i \iota'
4872 execute 'imap <buffer> '.g:atp_imap_first_leader.'m \mu'
4873 execute 'imap <buffer> '.g:atp_imap_first_leader.'n \nu'
4874 execute 'imap <buffer> '.g:atp_imap_first_leader.'p \pi'
4875 execute 'imap <buffer> '.g:atp_imap_first_leader.'o \theta'
4876 execute 'imap <buffer> '.g:atp_imap_first_leader.'r \rho'
4877 execute 'imap <buffer> '.g:atp_imap_first_leader.'s \sigma'
4878 execute 'imap <buffer> '.g:atp_imap_first_leader.'t \tau'
4879 execute 'imap <buffer> '.g:atp_imap_first_leader.'u \upsilon'
4880 execute 'imap <buffer> '.g:atp_imap_first_leader.'vs \varsigma'
4881 execute 'imap <buffer> '.g:atp_imap_first_leader.'vo \vartheta'
4882 execute 'imap <buffer> '.g:atp_imap_first_leader.'w \omega'
4883 execute 'imap <buffer> '.g:atp_imap_first_leader.'x \xi'
4884 execute 'imap <buffer> '.g:atp_imap_first_leader.'z \zeta'
4886 execute 'imap <buffer> '.g:atp_imap_first_leader.'D \Delta'
4887 execute 'imap <buffer> '.g:atp_imap_first_leader.'Y \Psi'
4888 execute 'imap <buffer> '.g:atp_imap_first_leader.'F \Phi'
4889 execute 'imap <buffer> '.g:atp_imap_first_leader.'G \Gamma'
4890 execute 'imap <buffer> '.g:atp_imap_first_leader.'L \Lambda'
4891 execute 'imap <buffer> '.g:atp_imap_first_leader.'M \Mu'
4892 execute 'imap <buffer> '.g:atp_imap_first_leader.'N \Nu'
4893 execute 'imap <buffer> '.g:atp_imap_first_leader.'P \Pi'
4894 execute 'imap <buffer> '.g:atp_imap_first_leader.'O \Theta'
4895 execute 'imap <buffer> '.g:atp_imap_first_leader.'S \Sigma'
4896 execute 'imap <buffer> '.g:atp_imap_first_leader.'T \Tau'
4897 execute 'imap <buffer> '.g:atp_imap_first_leader.'U \Upsilon'
4898 execute 'imap <buffer> '.g:atp_imap_first_leader.'W \Omega'
4899 execute 'imap <buffer> '.g:atp_imap_first_leader.'Z \mathrm{Z}'
4901 let infty_leader = (g:atp_imap_first_leader == "#" ? "\\" : g:atp_imap_first_leader )
4902 execute 'imap <buffer> '.infty_leader.'8 \infty'
4903 execute 'imap <buffer> '.g:atp_imap_first_leader.'& \wedge'
4904 execute 'imap <buffer> '.g:atp_imap_first_leader.'+ \bigcup'
4905 execute 'imap <buffer> '.g:atp_imap_first_leader.'- \setminus'
4907 if g:atp_no_env_maps != 1
4908 if g:atp_env_maps_old == 1
4909 execute 'imap <buffer> '.g:atp_imap_third_leader.'b \begin{}<Left>'
4910 execute 'imap <buffer> '.g:atp_imap_third_leader.'e \end{}<Left>'
4912 execute 'imap <buffer> '.g:atp_imap_third_leader.'c \begin{center}<CR>\end{center}<Esc>O'
4913 execute 'imap <buffer> '.g:atp_imap_fourth_leader.'c \begin{corollary}<CR>\end{corollary}<Esc>O'
4914 execute 'imap <buffer> '.g:atp_imap_third_leader.'d \begin{definition}<CR>\end{definition}<Esc>O'
4915 execute 'imap <buffer> '.g:atp_imap_fourth_leader.'u \begin{enumerate}<CR>\end{enumerate}<Esc>O'
4916 execute 'imap <buffer> '.g:atp_imap_third_leader.'a \begin{align}<CR>\end{align}<Esc>O'
4917 execute 'imap <buffer> '.g:atp_imap_third_leader.'i \item'
4918 execute 'imap <buffer> '.g:atp_imap_fourth_leader.'i \begin{itemize}<CR>\end{itemize}<Esc>O'
4919 execute 'imap <buffer> '.g:atp_imap_third_leader.'l \begin{lemma}<CR>\end{lemma}<Esc>O'
4920 execute 'imap <buffer> '.g:atp_imap_fourth_leader.'p \begin{proof}<CR>\end{proof}<Esc>O'
4921 execute 'imap <buffer> '.g:atp_imap_third_leader.'p \begin{proposition}<CR>\end{proposition}<Esc>O'
4922 execute 'imap <buffer> '.g:atp_imap_third_leader.'t \begin{theorem}<CR>\end{theorem}<Esc>O'
4923 execute 'imap <buffer> '.g:atp_imap_fourth_leader.'t \begin{center}<CR>\begin{tikzpicture}<CR><CR>\end{tikzpicture}<CR>\end{center}<Up><Up>'
4925 if g:atp_extra_env_maps == 1
4926 execute 'imap <buffer> '.g:atp_imap_third_leader.'r \begin{remark}<CR>\end{remark}<Esc>O'
4927 execute 'imap <buffer> '.g:atp_imap_fourth_leader.'l \begin{flushleft}<CR>\end{flushleft}<Esc>O'
4928 execute 'imap <buffer> '.g:atp_imap_third_leader.'r \begin{flushright}<CR>\end{flushright}<Esc>O'
4929 execute 'imap <buffer> '.g:atp_imap_third_leader.'f \begin{frame}<CR>\end{frame}<Esc>O'
4930 execute 'imap <buffer> '.g:atp_imap_fourth_leader.'q \begin{equation}<CR>\end{equation}<Esc>O'
4931 execute 'imap <buffer> '.g:atp_imap_third_leader.'n \begin{note}<CR>\end{note}<Esc>O'
4932 execute 'imap <buffer> '.g:atp_imap_third_leader.'o \begin{observation}<CR>\end{observation}<Esc>O'
4933 execute 'imap <buffer> '.g:atp_imap_third_leader.'x \begin{example}<CR>\end{example}<Esc>O'
4936 " New mapping for the insert mode.
4937 execute 'imap <buffer> '.g:atp_imap_third_leader.'b \begin{}<Left>'
4938 execute 'imap <buffer> '.g:atp_imap_third_leader.'e \end{}<Left>'
4940 execute 'imap <buffer> '.g:atp_imap_third_leader.'t \begin{theorem}<CR>\end{theorem}<Esc>O'
4941 execute 'imap <buffer> '.g:atp_imap_third_leader.'d \begin{definition}<CR>\end{definition}<Esc>O'
4942 execute 'imap <buffer> '.g:atp_imap_third_leader.'P \begin{proposition}<CR>\end{proposition}<Esc>O'
4943 execute 'imap <buffer> '.g:atp_imap_third_leader.'l \begin{lemma}<CR>\end{lemma}<Esc>O'
4944 execute 'imap <buffer> '.g:atp_imap_third_leader.'r \begin{remark}<CR>\end{remark}<Esc>O'
4945 execute 'imap <buffer> '.g:atp_imap_third_leader.'C \begin{corollary}<CR>\end{corollary}<Esc>O'
4946 execute 'imap <buffer> '.g:atp_imap_third_leader.'p \begin{proof}<CR>\end{proof}<Esc>O'
4947 execute 'imap <buffer> '.g:atp_imap_third_leader.'x \begin{example}<CR>\end{example}<Esc>O'
4948 execute 'imap <buffer> '.g:atp_imap_third_leader.'n \begin{note}<CR>\end{note}<Esc>O'
4950 execute 'imap <buffer> '.g:atp_imap_third_leader.'E \begin{enumerate}<CR>\end{enumerate}<Esc>O'
4951 execute 'imap <buffer> '.g:atp_imap_third_leader.'I \begin{itemize}<CR>\end{itemize}<Esc>O'
4952 execute 'imap <buffer> '.g:atp_imap_third_leader.'i <Esc>:call InsertItem()<CR>a'
4955 execute 'imap <buffer> '.g:atp_imap_third_leader.'a \begin{align}<CR>\end{align}<Esc>O'
4956 execute 'imap <buffer> '.g:atp_imap_third_leader.'q \begin{equation}<CR>\end{equation}<Esc>O'
4958 execute 'imap <buffer> '.g:atp_imap_third_leader.'c \begin{center}<CR>\end{center}<Esc>O'
4959 execute 'imap <buffer> '.g:atp_imap_third_leader.'L \begin{flushleft}<CR>\end{flushleft}<Esc>O'
4960 execute 'imap <buffer> '.g:atp_imap_third_leader.'R \begin{flushright}<CR>\end{flushright}<Esc>O'
4962 execute 'imap <buffer> '.g:atp_imap_third_leader.'T \begin{center}<CR>\begin{tikzpicture}<CR><CR>\end{tikzpicture}<CR>\end{center}<Up><Up>'
4963 execute 'imap <buffer> '.g:atp_imap_third_leader.'f \begin{frame}<CR>\end{frame}<Esc>O'
4966 " imap {c \begin{corollary*}<CR>\end{corollary*}<Esc>O
4967 " imap {d \begin{definition*}<CR>\end{definition*}<Esc>O
4968 " imap {x \begin{example*}\normalfont<CR>\end{example*}<Esc>O
4969 " imap {l \begin{lemma*}<CR>\end{lemma*}<Esc>O
4970 " imap {n \begin{note*}<CR>\end{note*}<Esc>O
4971 " imap {o \begin{observation*}<CR>\end{observation*}<Esc>O
4972 " imap {p \begin{proposition*}<CR>\end{proposition*}<Esc>O
4973 " imap {r \begin{remark*}<CR>\end{remark*}<Esc>O
4974 " imap {t \begin{theorem*}<CR>\end{theorem*}<Esc>O
4978 " Taken from AucTex:
4979 " Typing __ results in _{}
4980 function! <SID>SubBracket()
4982 let s:left = getline(line("."))[col(".")-2]
4984 let s:insert = "{}\<Left>"
4988 inoremap <silent> <buffer> _ <C-R>=<SID>SubBracket()<CR>
4989 " imap <buffer> __ _{}<Left>
4991 " Taken from AucTex:
4992 " Typing ^^ results in ^{}
4993 function! <SID>SuperBracket()
4995 let s:left = getline(line("."))[col(".")-2]
4997 let s:insert = "{}\<Left>"
5001 inoremap <silent> <buffer> ^ <C-R>=<SID>SuperBracket()<CR>
5002 " imap <buffer> ^^ ^{}<Left>
5004 " function! <SID>Infty()
5005 " let g:insert = g:atp_imap_first_leader
5006 " let g:left = getline(line("."))[col(".")-2]
5007 " if g:left == g:atp_imap_first_leader
5008 " let g:insert = "\\infty"
5009 " let g:new_line = strpart(getline("."),0 ,col(".")) . g:insert . strpart(getline("."), col("."))
5010 " call setline(line("."), g:new_line)
5011 " echomsg "new_line:" . g:new_line
5015 " echomsg "col:" . col(".") . " insert:" . g:insert . " left:" . g:left
5018 " execute "inoremap <buffer> 8 <ESC>:call <SID>Infty()<CR>"
5020 execute "imap <buffer> ".g:atp_imap_third_leader."m \\(\\)<Left><Left>"
5021 execute "imap <buffer> ".g:atp_imap_third_leader."M \\[\\]<Left><Left>"
5024 " vim:fdm=marker:tw=85:ff=unix:noet:ts=8:sw=4:fdc=1
5025 ftplugin/ATP_files/menu.vim [[[1
5027 " Author: Marcin Szamotulski
5028 " Description: This file sets up the menu.
5029 " Note: This file is a part of Automatic Tex Plugin for Vim.
5030 " URL: https://launchpad.net/automatictexplugin
5033 let s:sourced = ( !exists("s:sourced") ? 0 : 1 )
5038 let Compiler = get(g:CompilerMsg_Dict, matchstr(b:atp_TexCompiler, '^\s*\zs\S*'), 'Compile')
5040 let Viewer = get(g:ViewerMsg_Dict, matchstr(b:atp_Viewer, '^\s*\zs\S*'), "")
5042 if !exists("no_plugin_menu") && !exists("no_atp_menu")
5043 execute "menu 550.5 LaTe&X.&".Compiler."<Tab>:TEX :<C-U>TEX<CR>"
5044 execute "cmenu 550.5 LaTe&X.&".Compiler."<Tab>:TEX <C-U>TEX<CR>"
5045 execute "imenu 550.5 LaTe&X.&".Compiler."<Tab>:TEX <Esc>:TEX<CR>a"
5046 execute "menu 550.6 LaTe&X.".Compiler."\\ debug<Tab>:TEX\\ debug :<C-U>DTEX<CR>"
5047 execute "cmenu 550.6 LaTe&X.".Compiler."\\ debug<Tab>:TEX\\ debug <C-U>DTEX<CR>"
5048 execute "imenu 550.6 LaTe&X.".Compiler."\\ debug<Tab>:TEX\\ debug <Esc>:DTEX<CR>a"
5049 execute "menu 550.7 LaTe&X.".Compiler."\\ &twice<Tab>:2TEX :<C-U>2TEX<CR>"
5050 execute "cmenu 550.7 LaTe&X.".Compiler."\\ &twice<Tab>:2TEX <C-U>2TEX<CR>"
5051 execute "imenu 550.7 LaTe&X.".Compiler."\\ &twice<Tab>:2TEX <Esc>:2TEX<CR>a"
5052 menu 550.8 LaTe&X.&MakeLatex<Tab>:MakeLatex :<C-U>MakeLatex<CR>
5053 cmenu 550.8 LaTe&X.&MakeLatex<Tab>:MakeLatex <C-U>MakeLatex<CR>
5054 menu 550.8 LaTe&X.&MakeLatex<Tab>:MakeLatex <C-U>MakeLatex<CR>
5055 imenu 550.8 LaTe&X.&MakeLatex<Tab>:MakeLatex <Esc>:MakeLatex<CR>a
5056 menu 550.9 LaTe&X.&Bibtex<Tab>:Bibtex :<C-U>Bibtex<CR>
5057 cmenu 550.9 LaTe&X.&Bibtex<Tab>:Bibtex <C-U>Bibtex<CR>
5058 imenu 550.9 LaTe&X.&Bibtex<Tab>:Bibtex <Esc>:Bibtex<CR>a
5060 execute "menu 550.10 LaTe&X.&View\\ with\\ ".Viewer."<Tab>:ViewOutput :<C-U>ViewOutput<CR>"
5061 execute "cmenu 550.10 LaTe&X.&View\\ with\\ ".Viewer."<Tab>:ViewOutput <C-U>ViewOutput<CR>"
5062 execute "imenu 550.10 LaTe&X.&View\\ with\\ ".Viewer."<Tab>:ViewOutput <Esc>:ViewOutput<CR>a"
5064 execute "menu 550.10 LaTe&X.&View\\ Output<Tab>:ViewOutput :<C-U>ViewOutput<CR>"
5065 execute "cmenu 550.10 LaTe&X.&View\\ Output<Tab>:ViewOutput <C-U>ViewOutput<CR>"
5066 execute "imenu 550.10 LaTe&X.&View\\ Output<Tab>:ViewOutput <Esc>:ViewOutput<CR>a"
5069 menu 550.20.1 LaTe&X.&Errors<Tab>:ShowErrors :<C-U>ShowErrors<CR>
5070 cmenu 550.20.1 LaTe&X.&Errors<Tab>:ShowErrors <C-U>ShowErrors<CR>
5071 imenu 550.20.1 LaTe&X.&Errors<Tab>:ShowErrors <Esc>:ShowErrors<CR>
5072 menu 550.20.1 LaTe&X.&Log.&Open\ Log\ File<Tab>:ShowErrors\ o :<C-U>ShowErrors\ o<CR>
5073 cmenu 550.20.1 LaTe&X.&Log.&Open\ Log\ File<Tab>:ShowErrors\ o <C-U>ShowErrors\ o<CR>
5074 imenu 550.20.1 LaTe&X.&Log.&Open\ Log\ File<Tab>:ShowErrors\ o <Esc>:ShowErrors\ o<CR>
5075 if t:atp_DebugMode == "debug"
5076 menu 550.20.5 LaTe&X.&Log.Toggle\ &Debug\ Mode\ [on] :<C-U>ToggleDebugMode<CR>
5077 cmenu 550.20.5 LaTe&X.&Log.Toggle\ &Debug\ Mode\ [on] <C-U>ToggleDebugMode<CR>
5078 imenu 550.20.5 LaTe&X.&Log.Toggle\ &Debug\ Mode\ [on] <Esc>:ToggleDebugMode<CR>a
5080 menu 550.20.5 LaTe&X.&Log.Toggle\ &Debug\ Mode\ [off] :<C-U>ToggleDebugMode<CR>
5081 cmenu 550.20.5 LaTe&X.&Log.Toggle\ &Debug\ Mode\ [off] <C-U>ToggleDebugMode<CR>
5082 imenu 550.20.5 LaTe&X.&Log.Toggle\ &Debug\ Mode\ [off] <Esc>:ToggleDebugMode<CR>a
5084 menu 550.20.20 LaTe&X.&Log.-ShowErrors- :
5085 menu 550.20.20 LaTe&X.&Log.&Warnings<Tab>:ShowErrors\ w :<C-U>ShowErrors w<CR>
5086 cmenu 550.20.20 LaTe&X.&Log.&Warnings<Tab>:ShowErrors\ w <C-U>ShowErrors w<CR>
5087 imenu 550.20.20 LaTe&X.&Log.&Warnings<Tab>:ShowErrors\ w <Esc>:ShowErrors w<CR>
5088 menu 550.20.20 LaTe&X.&Log.&Citation\ Warnings<Tab>:ShowErrors\ c :<C-U>ShowErrors c<CR>
5089 cmenu 550.20.20 LaTe&X.&Log.&Citation\ Warnings<Tab>:ShowErrors\ c <C-U>ShowErrors c<CR>
5090 imenu 550.20.20 LaTe&X.&Log.&Citation\ Warnings<Tab>:ShowErrors\ c <Esc>:ShowErrors c<CR>
5091 menu 550.20.20 LaTe&X.&Log.&Reference\ Warnings<Tab>:ShowErrors\ r :<C-U>ShowErrors r<CR>
5092 cmenu 550.20.20 LaTe&X.&Log.&Reference\ Warnings<Tab>:ShowErrors\ r <C-U>ShowErrors r<CR>
5093 imenu 550.20.20 LaTe&X.&Log.&Reference\ Warnings<Tab>:ShowErrors\ r <Esc>:ShowErrors r<CR>
5094 menu 550.20.20 LaTe&X.&Log.&Font\ Warnings<Tab>ShowErrors\ f :<C-U>ShowErrors f<CR>
5095 cmenu 550.20.20 LaTe&X.&Log.&Font\ Warnings<Tab>ShowErrors\ f <C-U>ShowErrors f<CR>
5096 imenu 550.20.20 LaTe&X.&Log.&Font\ Warnings<Tab>ShowErrors\ f <Esc>:ShowErrors f<CR>
5097 menu 550.20.20 LaTe&X.&Log.Font\ Warnings\ &&\ Info<Tab>:ShowErrors\ fi :<C-U>ShowErrors fi<CR>
5098 cmenu 550.20.20 LaTe&X.&Log.Font\ Warnings\ &&\ Info<Tab>:ShowErrors\ fi <C-U>ShowErrors fi<CR>
5099 imenu 550.20.20 LaTe&X.&Log.Font\ Warnings\ &&\ Info<Tab>:ShowErrors\ fi <Esc>:ShowErrors fi<CR>
5100 menu 550.20.20 LaTe&X.&Log.&Show\ Files<Tab>:ShowErrors\ F :<C-U>ShowErrors F<CR>
5101 cmenu 550.20.20 LaTe&X.&Log.&Show\ Files<Tab>:ShowErrors\ F <C-U>ShowErrors F<CR>
5102 imenu 550.20.20 LaTe&X.&Log.&Show\ Files<Tab>:ShowErrors\ F <Esc>:ShowErrors F<CR>
5104 menu 550.20.20 LaTe&X.&Log.-PdfFotns- :
5105 menu 550.20.20 LaTe&X.&Log.&Pdf\ Fonts<Tab>:PdfFonts :<C-U>PdfFonts<CR>
5106 cmenu 550.20.20 LaTe&X.&Log.&Pdf\ Fonts<Tab>:PdfFonts <C-U>PdfFonts<CR>
5107 imenu 550.20.20 LaTe&X.&Log.&Pdf\ Fonts<Tab>:PdfFonts <Esc>:PdfFonts<CR>
5109 menu 550.20.20 LaTe&X.&Log.-Delete- :
5110 menu 550.20.20 LaTe&X.&Log.&Delete\ Tex\ Output\ Files<Tab>:Delete :<C-U>Delete<CR>
5111 cmenu 550.20.20 LaTe&X.&Log.&Delete\ Tex\ Output\ Files<Tab>:Delete <C-U>Delete<CR>
5112 imenu 550.20.20 LaTe&X.&Log.&Delete\ Tex\ Output\ Files<Tab>:Delete <Esc>:Delete<CR>
5113 menu 550.20.20 LaTe&X.&Log.Set\ Error\ File<Tab>:SetErrorFile :<C-U>SetErrorFile<CR>
5114 cmenu 550.20.20 LaTe&X.&Log.Set\ Error\ File<Tab>:SetErrorFile <C-U>SetErrorFile<CR>
5115 imenu 550.20.20 LaTe&X.&Log.Set\ Error\ File<Tab>:SetErrorFile <Esc>:SetErrorFile<CR>a
5117 menu 550.25 LaTe&X.-Print- :
5118 menu 550.26 LaTe&X.&SshPrint<Tab>:SshPrint :<C-U>SshPrint
5119 cmenu 550.26 LaTe&X.&SshPrint<Tab>:SshPrint <C-U>SshPrint
5120 imenu 550.26 LaTe&X.&SshPrint<Tab>:SshPrint <Esc>:SshPrinta
5122 menu 550.30 LaTe&X.-TOC- :
5123 menu 550.30 LaTe&X.&Table\ of\ Contents<Tab>:TOC :<C-U>TOC<CR>
5124 cmenu 550.30 LaTe&X.&Table\ of\ Contents<Tab>:TOC <C-U>TOC<CR>
5125 imenu 550.30 LaTe&X.&Table\ of\ Contents<Tab>:TOC <Esc>:TOC<CR>
5126 menu 550.30 LaTe&X.L&abels<Tab>:Labels :<C-U>Labels<CR>
5127 cmenu 550.30 LaTe&X.L&abels<Tab>:Labels <C-U>Labels<CR>
5128 imenu 550.30 LaTe&X.L&abels<Tab>:Labels <Esc>:Labels<CR>
5130 menu 550.40 LaTe&X.&Go\ to.&GotoFile<Tab>:GotoFile :GotoFile<CR>
5131 cmenu 550.40 LaTe&X.&Go\ to.&GotoFile<Tab>:GotoFile GotoFile<CR>
5132 imenu 550.40 LaTe&X.&Go\ to.&GotoFile<Tab>:GotoFile <Esc>:GotoFile<CR>
5134 menu 550.40 LaTe&X.&Go\ to.-Environment- :
5135 menu 550.40 LaTe&X.&Go\ to.Next\ Definition<Tab>:NEnv\ definition :<C-U>NEnv definition<CR>
5136 cmenu 550.40 LaTe&X.&Go\ to.Next\ Definition<Tab>:NEnv\ definition <C-U>NEnv definition<CR>
5137 imenu 550.40 LaTe&X.&Go\ to.Next\ Definition<Tab>:NEnv\ definition <Esc>:NEnv definition<CR>
5138 menu 550.40 LaTe&X.&Go\ to.Previuos\ Definition<Tab>:PEnv\ definition :<C-U>PEnv definition<CR>
5139 cmenu 550.40 LaTe&X.&Go\ to.Previuos\ Definition<Tab>:PEnv\ definition <C-U>PEnv definition<CR>
5140 imenu 550.40 LaTe&X.&Go\ to.Previuos\ Definition<Tab>:PEnv\ definition <Esc>:PEnv definition<CR>
5141 menu 550.40 LaTe&X.&Go\ to.Next\ Environment<Tab>:NEnv\ [pattern] :<C-U>NEnv
5142 cmenu 550.40 LaTe&X.&Go\ to.Next\ Environment<Tab>:NEnv\ [pattern] <C-U>NEnv
5143 imenu 550.40 LaTe&X.&Go\ to.Next\ Environment<Tab>:NEnv\ [pattern] <Esc>:NEnv
5144 menu 550.40 LaTe&X.&Go\ to.Previuos\ Environment<Tab>:PEnv\ [pattern] :<C-U>PEnv
5145 cmenu 550.40 LaTe&X.&Go\ to.Previuos\ Environment<Tab>:PEnv\ [pattern] <C-U>PEnv
5146 imenu 550.40 LaTe&X.&Go\ to.Previuos\ Environment<Tab>:PEnv\ [pattern] <Esc>:PEnv
5148 menu 550.40 LaTe&X.&Go\ to.-Section- :
5149 menu 550.40 LaTe&X.&Go\ to.&Next\ Section<Tab>:NSec :NSec<CR>
5150 cmenu 550.40 LaTe&X.&Go\ to.&Next\ Section<Tab>:NSec NSec<CR>
5151 imenu 550.40 LaTe&X.&Go\ to.&Next\ Section<Tab>:NSec <Esc>:NSec<CR>
5152 menu 550.40 LaTe&X.&Go\ to.&Previuos\ Section<Tab>:PSec :<C-U>PSec<CR>
5153 cmenu 550.40 LaTe&X.&Go\ to.&Previuos\ Section<Tab>:PSec <C-U>PSec<CR>
5154 imenu 550.40 LaTe&X.&Go\ to.&Previuos\ Section<Tab>:PSec <Esc>:PSec<CR>
5155 menu 550.40 LaTe&X.&Go\ to.Next\ Chapter<Tab>:NChap :<C-U>NChap<CR>
5156 cmenu 550.40 LaTe&X.&Go\ to.Next\ Chapter<Tab>:NChap <C-U>NChap<CR>
5157 imenu 550.40 LaTe&X.&Go\ to.Next\ Chapter<Tab>:NChap <Esc>:NChap<CR>
5158 menu 550.40 LaTe&X.&Go\ to.Previous\ Chapter<Tab>:PChap :<C-U>PChap<CR>
5159 cmenu 550.40 LaTe&X.&Go\ to.Previous\ Chapter<Tab>:PChap <C-U>PChap<CR>
5160 imenu 550.40 LaTe&X.&Go\ to.Previous\ Chapter<Tab>:PChap <Esc>:PChap<CR>
5161 menu 550.40 LaTe&X.&Go\ to.Next\ Part<Tab>:NPart :<C-U>NPart<CR>
5162 cmenu 550.40 LaTe&X.&Go\ to.Next\ Part<Tab>:NPart <C-U>NPart<CR>
5163 imenu 550.40 LaTe&X.&Go\ to.Next\ Part<Tab>:NPart <Esc>:NPart<CR>
5164 menu 550.40 LaTe&X.&Go\ to.Previuos\ Part<Tab>:PPart :<C-U>PPart<CR>
5165 cmenu 550.40 LaTe&X.&Go\ to.Previuos\ Part<Tab>:PPart <C-U>PPart<CR>
5166 imenu 550.40 LaTe&X.&Go\ to.Previuos\ Part<Tab>:PPart <Esc>:PPart<CR>
5168 menu 550.50 LaTe&X.-Bib- :
5169 menu 550.50 LaTe&X.Bib\ Search<Tab>:Bibsearch\ [pattern] :<C-U>BibSearch
5170 cmenu 550.50 LaTe&X.Bib\ Search<Tab>:Bibsearch\ [pattern] <C-U>BibSearch
5171 imenu 550.50 LaTe&X.Bib\ Search<Tab>:Bibsearch\ [pattern] <Esc>:BibSearch
5172 menu 550.50 LaTe&X.Input\ Files<Tab>:InputFiles :<C-U>InputFiles<CR>
5173 cmenu 550.50 LaTe&X.Input\ Files<Tab>:InputFiles <C-U>InputFiles<CR>
5174 imenu 550.50 LaTe&X.Input\ Files<Tab>:InputFiles <Esc>:InputFiles<CR>
5176 menu 550.60 LaTe&X.-Viewer- :
5177 menu 550.60 LaTe&X.Set\ &XPdf<Tab>:SetXpdf :<C-U>SetXpdf<CR>
5178 cmenu 550.60 LaTe&X.Set\ &XPdf<Tab>:SetXpdf <C-U>SetXpdf<CR>
5179 imenu 550.60 LaTe&X.Set\ &XPdf<Tab>:SetXpdf <Esc>:SetXpdf<CR>
5180 menu 550.60 LaTe&X.Set\ X&Dvi\ (inverse\/reverse\ search)<Tab>:SetXdvi :<C-U>SetXdvi<CR>
5181 cmenu 550.60 LaTe&X.Set\ X&Dvi\ (inverse\/reverse\ search)<Tab>:SetXdvi <C-U>SetXdvi<CR>
5182 imenu 550.60 LaTe&X.Set\ X&Dvi\ (inverse\/reverse\ search)<Tab>:SetXdvi <Esc>:SetXdvi<CR>
5184 menu 550.70 LaTe&X.-Editting- :
5186 " ToDo: show options doesn't work from the menu (it disappears immediately, but at
5187 " some point I might change it completely)
5188 menu 550.70 LaTe&X.&Options.&Show\ Options<Tab>:ShowOptions[!] :<C-U>ShowOptions
5189 cmenu 550.70 LaTe&X.&Options.&Show\ Options<Tab>:ShowOptions[!] <C-U>ShowOptions
5190 imenu 550.70 LaTe&X.&Options.&Show\ Options<Tab>:ShowOptions[!] <Esc>:ShowOptions
5192 menu 550.70 LaTe&X.&Options.Toggle\ &Call\ Back\ [on]<Tab>g:atp_callback :<C-U>ToggleCallBack<CR>
5193 cmenu 550.70 LaTe&X.&Options.Toggle\ &Call\ Back\ [on]<Tab>g:atp_callback <C-U>ToggleCallBack<CR>
5194 imenu 550.70 LaTe&X.&Options.Toggle\ &Call\ Back\ [on]<Tab>g:atp_callback <Esc>:ToggleCallBack<CR>a
5196 menu 550.70 LaTe&X.&Options.Toggle\ &Call\ Back\ [off]<Tab>g:atp_callback :<C-U>ToggleCallBack<CR>
5197 cmenu 550.70 LaTe&X.&Options.Toggle\ &Call\ Back\ [off]<Tab>g:atp_callback <C-U>ToggleCallBack<CR>
5198 imenu 550.70 LaTe&X.&Options.Toggle\ &Call\ Back\ [off]<Tab>g:atp_callback <Esc>:ToggleCallBack<CR>a
5200 menu 550.70 LaTe&X.&Options.-set\ options- :
5201 " There is menu for ToggleAuTeX
5202 " menu 550.70 LaTe&X.&Options.Automatic\ TeX\ Processing<Tab>b:atp_autex :<C-U>let b:atp_autex=
5203 " imenu 550.70 LaTe&X.&Options.Automatic\ TeX\ Processing<Tab>b:atp_autex <Esc>:let b:atp_autex=
5204 menu 550.70 LaTe&X.&Options.Set\ TeX\ Compiler<Tab>:Compiler :<C-U>Compiler
5205 cmenu 550.70 LaTe&X.&Options.Set\ TeX\ Compiler<Tab>:Compiler <C-U>Compiler
5206 imenu 550.70 LaTe&X.&Options.Set\ TeX\ Compiler<Tab>:Compiler <Esc>:Compiler
5207 menu 550.70 LaTe&X.&Options.Set\ Debug\ Mode<Tab>:DebugMode\ {mode} :<C-U>DebugMode
5208 cmenu 550.70 LaTe&X.&Options.Set\ Debug\ Mode<Tab>:DebugMode\ {mode} <C-U>DebugMode
5209 imenu 550.70 LaTe&X.&Options.Set\ Debug\ Mode<Tab>:Compiler\ {compiler} <Esc>:DebugMode
5210 menu 550.70 LaTe&X.&Options.Set\ Runs<Tab>b:atp_auruns :<C-U>let b:atp_auruns=
5211 cmenu 550.70 LaTe&X.&Options.Set\ Runs<Tab>b:atp_auruns <C-U>let b:atp_auruns=
5212 imenu 550.70 LaTe&X.&Options.Set\ Runs<Tab>b:atp_auruns <Esc>:let b:atp_auruns=
5213 menu 550.70 LaTe&X.&Options.Set\ Viewer<Tab>:Viewer\ {viewer} :<C-U>Viewer
5214 cmenu 550.70 LaTe&X.&Options.Set\ Viewer<Tab>:Viewer\ {viewer} <C-U>Viewer
5215 imenu 550.70 LaTe&X.&Options.Set\ Viewer<Tab>:Viewer\ {viewer} <Esc>:Viewer
5216 menu 550.70 LaTe&X.&Options.Set\ Output\ Directory<Tab>b:atp_OutDir :<C-U>let b:atp_ViewerOptions="
5217 cmenu 550.70 LaTe&X.&Options.Set\ Output\ Directory<Tab>b:atp_OutDir <C-U>let b:atp_ViewerOptions="
5218 imenu 550.70 LaTe&X.&Options.Set\ Output\ Directory<Tab>b:atp_OutDir <Esc>:let b:atp_ViewerOptions="
5219 menu 550.70 LaTe&X.&Options.Set\ Output\ Directory\ to\ the\ default\ value<Tab>:SetOutDir :<C-U>SetOutDir<CR>
5220 cmenu 550.70 LaTe&X.&Options.Set\ Output\ Directory\ to\ the\ default\ value<Tab>:SetOutDir <C-U>SetOutDir<CR>
5221 imenu 550.70 LaTe&X.&Options.Set\ Output\ Directory\ to\ the\ default\ value<Tab>:SetOutDir <Esc>:SetOutDir<CR>
5222 " The title is misleading! I think it is not needed here.
5223 " menu 550.70 LaTe&X.&Options.Ask\ for\ the\ Output\ Directory<Tab>g:askfortheoutdir :<C-U>let g:askfortheoutdir="
5224 " imenu 550.70 LaTe&X.&Options.Ask\ for\ the\ Output\ Directory<Tab>g:askfortheoutdir <Esc>:let g:askfortheoutdir="
5225 menu 550.70 LaTe&X.&Options.Set\ Error\ File<Tab>:SetErrorFile :<C-U>SetErrorFile<CR>
5226 cmenu 550.70 LaTe&X.&Options.Set\ Error\ File<Tab>:SetErrorFile <C-U>SetErrorFile<CR>
5227 imenu 550.70 LaTe&X.&Options.Set\ Error\ File<Tab>:SetErrorFile <Esc>:SetErrorFile<CR>
5228 menu 550.70 LaTe&X.&Options.Which\ TeX\ files\ to\ copy<Tab>g:keep :<C-U>let g:keep="
5229 cmenu 550.70 LaTe&X.&Options.Which\ TeX\ files\ to\ copy<Tab>g:keep <C-U>let g:keep="
5230 imenu 550.70 LaTe&X.&Options.Which\ TeX\ files\ to\ copy<Tab>g:keep <Esc>:let g:keep="
5231 menu 550.70 LaTe&X.&Options.Tex\ extensions<Tab>g:atp_tex_extensions :<C-U>let g:atp_tex_extensions="
5232 cmenu 550.70 LaTe&X.&Options.Tex\ extensions<Tab>g:atp_tex_extensions <C-U>let g:atp_tex_extensions="
5233 imenu 550.70 LaTe&X.&Options.Tex\ extensions<Tab>g:atp_tex_extensions <Esc>:let g:atp_tex_extensions="
5234 menu 550.70 LaTe&X.&Options.Remove\ Command<Tab>g:rmcommand :<C-U>let g:rmcommand="
5235 cmenu 550.70 LaTe&X.&Options.Remove\ Command<Tab>g:rmcommand <C-U>let g:rmcommand="
5236 imenu 550.70 LaTe&X.&Options.Remove\ Command<Tab>g:rmcommand <Esc>:let g:rmcommand="
5237 menu 550.70 LaTe&X.&Options.Default\ Bib\ Flags<Tab>g:defaultbibflags :<C-U>let g:defaultbibflags="
5238 cmenu 550.70 LaTe&X.&Options.Default\ Bib\ Flags<Tab>g:defaultbibflags <C-U>let g:defaultbibflags="
5239 imenu 550.70 LaTe&X.&Options.Default\ Bib\ Flags<Tab>g:defaultbibflags <Esc>:let g:defaultbibflags="
5242 menu 550.75 &LaTeX.&Toggle\ AuTeX\ [on]<Tab>b:atp_autex :<C-U>ToggleAuTeX<CR>
5243 cmenu 550.75 &LaTeX.&Toggle\ AuTeX\ [on]<Tab>b:atp_autex <C-U>ToggleAuTeX<CR>
5244 imenu 550.75 &LaTeX.&Toggle\ AuTeX\ [on]<Tab>b:atp_autex <ESC>:ToggleAuTeX<CR>a
5246 menu 550.75 &LaTeX.&Toggle\ AuTeX\ [off]<Tab>b:atp_autex :<C-U>ToggleAuTeX<CR>
5247 cmenu 550.75 &LaTeX.&Toggle\ AuTeX\ [off]<Tab>b:atp_autex <C-U>ToggleAuTeX<CR>
5248 imenu 550.75 &LaTeX.&Toggle\ AuTeX\ [off]<Tab>b:atp_autex <ESC>:ToggleAuTeX<CR>a
5250 menu 550.78 LaTe&X.&Toggle\ Space\ [off]<Tab>cmap\ <space>\ \\_s\\+ :<C-U>ToggleSpace<CR>
5251 cmenu 550.78 LaTe&X.&Toggle\ Space\ [off]<Tab>cmap\ <space>\ \\_s\\+ <C-U>ToggleSpace<CR>
5252 imenu 550.78 LaTe&X.&Toggle\ Space\ [off]<Tab>cmap\ <space>\ \\_s\\+ <Esc>:ToggleSpace<CR>a
5253 tmenu LaTe&X.&Toggle\ Space\ [off] cmap <space> \_s\+ is curently off
5254 " ToggleNn menu is made by s:LoadHistory
5256 menu 550.79 LaTe&X.Toggle\ &Nn\ [on]<Tab>:ToggleNn :<C-U>ToggleNn<CR>
5257 cmenu 550.79 LaTe&X.Toggle\ &Nn\ [on]<Tab>:ToggleNn <C-U>ToggleNn<CR>
5258 imenu 550.79 LaTe&X.Toggle\ &Nn\ [on]<Tab>:ToggleNn <Esc>:ToggleNn<CR>a
5259 tmenu LaTeX.Toggle\ Nn\ [on] n,N vim normal commands.
5261 menu 550.79 LaTe&X.Toggle\ &Nn\ [off]<Tab>:ToggleNn :<C-U>ToggleNn<CR>
5262 cmenu 550.79 LaTe&X.Toggle\ &Nn\ [off]<Tab>:ToggleNn <C-U>ToggleNn<CR>
5263 imenu 550.79 LaTe&X.Toggle\ &Nn\ [off]<Tab>:ToggleNn <Esc>:ToggleNn<CR>a
5264 tmenu LaTeX.Toggle\ Nn\ [off] atp maps to n,N.
5267 menu 550.80 LaTe&X.Toggle\ &Check\ if\ in\ Math\ [on]<Tab>g:atp_MathOpened :<C-U>ToggleCheckMathOpened<CR>
5268 cmenu 550.80 LaTe&X.Toggle\ &Check\ if\ in\ Math\ [on]<Tab>g:atp_MathOpened <C-U>ToggleCheckMathOpened<CR>
5269 imenu 550.80 LaTe&X.Toggle\ &Check\ if\ in\ Math\ [on]<Tab>g:atp_MathOpened <Esc>:ToggleCheckMathOpened<CR>a
5271 menu 550.80 LaTe&X.Toggle\ &Check\ if\ in\ Math\ [off]<Tab>g:atp_MathOpened :<C-U>ToggleCheckMathOpened<CR>
5272 cmenu 550.80 LaTe&X.Toggle\ &Check\ if\ in\ Math\ [off]<Tab>g:atp_MathOpened <C-U>ToggleCheckMathOpened<CR>
5273 imenu 550.80 LaTe&X.Toggle\ &Check\ if\ in\ Math\ [off]<Tab>g:atp_MathOpened <Esc>:ToggleCheckMathOpened<CR>a
5277 " vim:fdm=marker:tw=85:ff=unix:noet:ts=8:sw=4:fdc=1
5278 ftplugin/ATP_files/motion.vim [[[1
5280 " Author: Marcin Szamotulski
5281 " Description: This file contains motion and highlight functions of ATP.
5282 " Note: This file is a part of Automatic Tex Plugin for Vim.
5283 " URL: https://launchpad.net/automatictexplugin
5286 let s:sourced = ( !exists("s:sourced") ? 0 : 1 )
5288 " Functions: (source once)
5290 " All table of contents stuff: variables, functions and commands.
5291 " {{{ Table Of Contents
5293 let g:atp_sections={
5294 \ 'chapter' : [ '\m^\s*\(\\chapter\*\?\s*{\)', '\m\\chapter\*'],
5295 \ 'section' : [ '\m^\s*\(\\section\*\?\s*{\)', '\m\\section\*'],
5296 \ 'subsection' : [ '\m^\s*\(\\subsection\*\?\s*{\)', '\m\\subsection\*'],
5297 \ 'subsubsection' : [ '\m^\s*\(\\subsubsection\*\?\s*{\)', '\m\\subsubsection\*'],
5298 \ 'bibliography' : ['\m^\s*\(\\begin\s*{\s*thebibliography\s*}\|\\bibliography\s*{\)' , 'nopattern'],
5299 \ 'abstract' : ['\m^\s*\(\\begin\s*{abstract}\|\\abstract\s*{\)', 'nopattern'],
5300 \ 'part' : [ '\m^\s*\(\\part\*\?\s*{\)', '\m\\part\*']}
5302 "--Make TOC -----------------------------
5303 " This makes sense only for latex documents.
5305 " Notes: Makeing toc from aux file:
5307 " + one gets correct numbers
5308 " - one doesn't get line numbers
5309 " / the title might be modified thus one can not make a pattern
5310 " which works in all situations, while this is important for
5311 " :DeleteSection command /
5313 " {{{2 s:find_toc_lines
5314 function! s:find_toc_lines()
5318 let pos_saved=getpos(".")
5320 keepjumps call setpos(".",pos)
5324 for section in keys(g:atp_sections)
5326 let pattern=g:atp_sections[section][0] . ''
5328 let pattern=pattern . '\|' . g:atp_sections[section][0]
5334 let line=search(pattern, 'W')
5336 call add(toc_lines_nr, line)
5337 let line=search(pattern, 'W')
5339 keepjumps call setpos(".", pos_saved)
5340 for line in toc_lines_nr
5341 call add(toc_lines, getline(line))
5346 " this will store information:
5347 " { 'linenumber' : ['chapter/section/..', 'sectionnumber', 'section title', '0/1=not starred/starred'] }
5348 function! s:maketoc(filename)
5351 " if the dictinary with labels is not defined, define it
5352 if !exists("t:atp_labels")
5353 let t:atp_labels = {}
5357 " getbufline reads only loaded buffers, unloaded can be read from file.
5358 let bufname = fnamemodify(a:filename,":t")
5360 let texfile = ( bufexists(bufname) ? getbufline("^" . bufname . "$","1","$") : readfile(a:filename) )
5363 echo "File " . a:filename . " not readable."
5365 let texfile_copy = deepcopy(texfile)
5368 let bline = 0 " We are not removing the preambule any more.
5370 " set variables for chapter/section numbers
5371 for section in keys(g:atp_sections)
5372 let ind{section} = 0
5376 for section in keys(g:atp_sections)
5377 let filter = ( j == 0 ? g:atp_sections[section][0] . '' : filter . '\|' . g:atp_sections[section][0] )
5380 " ToDo: HOW TO MAKE THIS FAST?
5381 let s:filtered = filter(deepcopy(texfile), 'v:val =~ filter')
5382 for line in s:filtered
5383 for section in keys(g:atp_sections)
5384 if line =~ g:atp_sections[section][0]
5385 if line !~ '^\s*\\\@<!%'
5386 " THIS DO NOT WORKS WITH \abstract{ --> empty set, but with
5387 " \chapter{title} --> title, solution: the name of
5388 " 'Abstract' will be plased, as we know what we have
5392 " test if it is a starred version.
5394 if g:atp_sections[section][1] != 'nopattern' && line =~ g:atp_sections[section][1]
5400 " Problem: If there are two sections with the same title, this
5402 let idx = index(texfile,line)
5403 call remove(texfile, idx)
5405 let tline = i+bline+1
5409 let start = stridx(title,'{')+1
5410 let title = strpart(title,start)
5411 " we are looking for the maching '}'
5416 if strpart(title,i,1) == '{'
5418 elseif strpart(title,i,1) == '}'
5425 let title = strpart(title,0,i)
5428 " if it is not starred version add one to the section number
5429 " or it is not an abstract
5431 if !(section == 'chapter' && title =~ '^\cabstract$')
5436 if section == 'part'
5439 let indsubsection = 0
5440 let indsubsubsection = 0
5441 elseif section == 'chapter'
5443 let indsubsection = 0
5444 let indsubsubsection = 0
5445 elseif section == 'section'
5446 let indsubsection = 0
5447 let indsubsubsection = 0
5448 elseif section == 'subsection'
5449 let indsubsubsection = 0
5454 let start=stridx(shorttitle,'[')+1
5458 let shorttitle=strpart(shorttitle,start)
5459 " we are looking for the maching ']'
5462 while i<=len(shorttitle)
5464 if strpart(shorttitle,i,1) == '['
5466 elseif strpart(shorttitle,i,1) == ']'
5473 let shorttitle = strpart(shorttitle,0,i)
5476 "ToDo: if section is bibliography (using bib) then find the first
5478 if section == "bibliography" && line !~ '\\begin\s*{\s*thebibliography\s*}'
5480 while texfile_copy[idx] !~ '^\s*$'
5483 " " We add 1 as we want the first non blank line, and one more
5484 " " 1 as we want to know the line number not the list index
5489 " Add results to the dictionary:
5490 call extend(toc, { tline : [ section, ind{section}, title, star, shorttitle] })
5496 if exists("t:atp_toc")
5497 call extend(t:atp_toc, { a:filename : toc }, "force")
5499 let t:atp_toc = { a:filename : toc }
5504 if !exists("t:buflist")
5507 function! s:buflist()
5508 " this names are used in TOC and passed to s:maketoc, which
5509 " makes a dictionary whose keys are the values of name defined
5511 let name=resolve(fnamemodify(bufname("%"),":p"))
5512 " add an entry to the list t:buflist if it is not there.
5513 if bufname("") =~ ".tex" && index(t:buflist,name) == -1
5514 call add(t:buflist,name)
5519 " {{{2 RemoveFromBufList
5520 if !exists("*RemoveFromBufList")
5521 function RemoveFromBufList()
5524 echo "(" . i . ") " . f
5527 let which=input("Which file to remove (press <Enter> for none)")
5528 if which != "" && which =~ '\d\+'
5529 call remove(t:buflist,f-1)
5534 function! s:showtoc(toc)
5536 " let new = a:0 >= 1 ? a:1 : 0
5538 " this is a dictionary of line numbers where a new file begins.
5540 " " Open new window or jump to the existing one.
5541 " " Remember the place from which we are coming:
5542 " let t:atp_bufname=bufname("")
5543 " let t:atp_winnr=winnr() these are already set by TOC()
5545 let tocwinnr=bufwinnr("^" . bname . "$")
5546 " echomsg "DEBUG a " . tocwinnr
5548 " Jump to the existing window.
5549 exe tocwinnr . " wincmd w"
5550 silent exe "%delete"
5552 " Open new window if its width is defined (if it is not the code below
5553 " will put toc in the current buffer so it is better to return.
5554 if !exists("t:toc_window_width")
5555 echoerr "t:toc_window_width not set"
5558 let openbuffer=t:toc_window_width . "vsplit +setl\\ wiw=15\\ buftype=nofile\\ tabstop=1\\ filetype=toc_atp\\ nowrap __ToC__"
5559 keepalt silent exe openbuffer
5560 " We are setting the address from which we have come.
5561 silent call atplib#setwindow()
5564 " this is the line number in ToC.
5565 " number is a line number relative to the file listed in ToC.
5566 " the current line number is linenumber+number
5567 " there are two loops: one over linenumber and the second over number.
5571 " this variable will be used to set the cursor position in ToC.
5572 for openfile in keys(a:toc)
5573 call extend(numberdict, { openfile : number })
5580 let path=fnamemodify(bufname(""),":p:h")
5581 for line in keys(a:toc[openfile])
5582 if a:toc[openfile][line][0] == 'chapter'
5585 elseif a:toc[openfile][line][0] == 'part'
5589 let sorted = sort(keys(a:toc[openfile]), "atplib#CompareNumbers")
5590 let len = len(sorted)
5591 " write the file name in ToC (with a full path in paranthesis)
5592 call setline(number,fnamemodify(openfile,":t") . " (" . fnamemodify(openfile,":p:h") . ")")
5593 call extend(b:atp_Toc, { number : [ openfile, 1 ]})
5596 call extend(b:atp_Toc, { number : [ openfile, line ] })
5597 let lineidx=index(sorted,line)
5598 let nlineidx=lineidx+1
5599 if nlineidx< len(sorted)
5600 let nline=sorted[nlineidx]
5604 let lenght=len(line)
5608 let showline=" " . line
5610 let showline=" " . line
5612 let showline=" " . line
5614 let showline=" " . line
5619 if a:toc[openfile][line][0] == 'abstract' || a:toc[openfile][line][2] =~ '^\cabstract$'
5620 call setline(number, showline . "\t" . " " . "Abstract" )
5621 elseif a:toc[openfile][line][0] =~ 'bibliography\|references'
5622 call setline (number, showline . "\t" . " " . a:toc[openfile][line][2])
5623 elseif a:toc[openfile][line][0] == 'part'
5624 let partnr=a:toc[openfile][line][1]
5626 if a:toc[openfile][line][3]
5627 "if it is stared version
5628 let nr=substitute(nr,'.',' ','')
5630 if a:toc[openfile][line][4] != ''
5631 " call setline (number, showline . "\t" . nr . " " . a:toc[openfile][line][4])
5632 call setline (number, showline . "\t" . " " . a:toc[openfile][line][4])
5634 " call setline (number, showline . "\t" . nr . " " . a:toc[openfile][line][2])
5635 call setline (number, showline . "\t" . " " . a:toc[openfile][line][2])
5637 elseif a:toc[openfile][line][0] == 'chapter'
5638 let chnr=a:toc[openfile][line][1]
5640 if a:toc[openfile][line][3]
5641 "if it is stared version
5642 let nr=substitute(nr,'.',' ','')
5644 if a:toc[openfile][line][4] != ''
5645 call setline (number, showline . "\t" . nr . " " . a:toc[openfile][line][4])
5647 call setline (number, showline . "\t" . nr . " " . a:toc[openfile][line][2])
5649 elseif a:toc[openfile][line][0] == 'section'
5650 let secnr=a:toc[openfile][line][1]
5652 let nr=chnr . "." . secnr
5653 if a:toc[openfile][line][3]
5654 "if it is stared version
5655 let nr=substitute(nr,'.',' ','g')
5657 if a:toc[openfile][line][4] != ''
5658 call setline (number, showline . "\t\t" . nr . " " . a:toc[openfile][line][4])
5660 call setline (number, showline . "\t\t" . nr . " " . a:toc[openfile][line][2])
5664 if a:toc[openfile][line][3]
5665 "if it is stared version
5666 let nr=substitute(nr,'.',' ','g')
5668 if a:toc[openfile][line][4] != ''
5669 call setline (number, showline . "\t" . nr . " " . a:toc[openfile][line][4])
5671 call setline (number, showline . "\t" . nr . " " . a:toc[openfile][line][2])
5674 elseif a:toc[openfile][line][0] == 'subsection'
5675 let ssecnr=a:toc[openfile][line][1]
5677 let nr=chnr . "." . secnr . "." . ssecnr
5678 if a:toc[openfile][line][3]
5679 "if it is stared version
5680 let nr=substitute(nr,'.',' ','g')
5682 if a:toc[openfile][line][4] != ''
5683 call setline (number, showline . "\t\t\t" . nr . " " . a:toc[openfile][line][4])
5685 call setline (number, showline . "\t\t\t" . nr . " " . a:toc[openfile][line][2])
5688 let nr=secnr . "." . ssecnr
5689 if a:toc[openfile][line][3]
5690 "if it is stared version
5691 let nr=substitute(nr,'.',' ','g')
5693 if a:toc[openfile][line][4] != ''
5694 call setline (number, showline . "\t\t" . nr . " " . a:toc[openfile][line][4])
5696 call setline (number, showline . "\t\t" . nr . " " . a:toc[openfile][line][2])
5699 elseif a:toc[openfile][line][0] == 'subsubsection'
5700 let sssecnr=a:toc[openfile][line][1]
5702 let nr=chnr . "." . secnr . "." . sssecnr
5703 if a:toc[openfile][line][3]
5704 "if it is stared version
5705 let nr=substitute(nr,'.',' ','g')
5707 if a:toc[openfile][line][4] != ''
5708 call setline(number, a:toc[openfile][line][0] . "\t\t\t" . nr . " " . a:toc[openfile][line][4])
5710 call setline(number, a:toc[openfile][line][0] . "\t\t\t" . nr . " " . a:toc[openfile][line][2])
5713 let nr=secnr . "." . ssecnr . "." . sssecnr
5714 if a:toc[openfile][line][3]
5715 "if it is stared version
5716 let nr=substitute(nr,'.',' ','g')
5718 if a:toc[openfile][line][4] != ''
5719 call setline (number, showline . "\t\t" . nr . " " . a:toc[openfile][line][4])
5721 call setline (number, showline . "\t\t" . nr . " " . a:toc[openfile][line][2])
5730 " set the cursor position on the correct line number.
5731 " first get the line number of the begging of the ToC of t:atp_bufname
5733 " let t:numberdict=numberdict "DEBUG
5734 " t:atp_bufname is the full path to the current buffer.
5735 let num = get(numberdict, t:atp_bufname, 'no_number')
5736 if num == 'no_number'
5740 let sorted = sort(keys(a:toc[t:atp_bufname]), "atplib#CompareNumbers")
5741 let t:sorted = sorted
5746 keepjumps call setpos('.',[bufnr(""),num,1,0])
5750 if search('<Enter> jump and close', 'nW') == 0
5751 call append('$', [ '',
5753 \ '<Enter> jump and close',
5754 \ 's jump and split',
5755 \ 'y or c yank label',
5767 " This is User Front End Function
5769 function! <SID>TOC(bang)
5770 " skip generating t:atp_toc list if it exists and if a:0 != 0
5771 if &l:filetype != 'tex'
5772 echoerr "Wrong 'filetype'. This command works only for latex documents."
5775 " for each buffer in t:buflist (set by s:buflist)
5776 if ( a:bang == "!" || !exists("t:atp_toc") )
5777 for buffer in t:buflist
5778 let t:atp_toc=s:maketoc(buffer)
5781 call s:showtoc(t:atp_toc)
5783 nnoremap <Plug>ATP_TOC :call <SID>TOC(1)<CR>
5786 " This finds the name of currently eddited section/chapter units.
5788 " ToDo: make this faster!
5789 " {{{ s:NearestSection
5790 " This function finds the section name of the current section unit with
5791 " respect to the dictionary a:section={ 'line number' : 'section name', ... }
5792 " it returns the [ section_name, section line, next section line ]
5793 function! <SID>NearestSection(section)
5796 let sorted=sort(keys(a:section), "atplib#CompareNumbers")
5798 while x<len(sorted) && sorted[x]<=cline
5801 if x>=1 && x < len(sorted)
5802 let section_name=a:section[sorted[x-1]]
5803 return [section_name, sorted[x-1], sorted[x]]
5804 elseif x>=1 && x >= len(sorted)
5805 let section_name=a:section[sorted[x-1]]
5806 return [section_name,sorted[x-1], line('$')]
5807 elseif x<1 && x < len(sorted)
5808 " if we are before the first section return the empty string
5809 return ['','0', sorted[x]]
5810 elseif x<1 && x >= len(sorted)
5811 return ['','0', line('$')]
5817 if &l:filetype != 'tex'
5819 " if exists(g:tex_flavor)
5820 " if g:tex_flavor != "latex"
5821 " echomsg "CTOC: Wrong 'filetype'. This function works only for latex documents."
5824 " Set the status line once more, to remove the CTOC() function.
5828 " resolve the full path:
5829 let t:atp_bufname=resolve(fnamemodify(bufname("%"),":p"))
5831 " if t:atp_toc(t:atp_bufname) exists use it otherwise make it
5832 if !exists("t:atp_toc") || !has_key(t:atp_toc,t:atp_bufname)
5833 silent let t:atp_toc=s:maketoc(t:atp_bufname)
5836 " l:count where the preambule ends
5837 let buffer=getbufline(bufname("%"),"1","$")
5840 while line !~ '\\begin\s*{document}' && i < len(buffer)
5842 if line !~ '\\begin\s*{document}'
5847 " if we are before the '\\begin{document}' line:
5849 let return=['Preambule']
5857 for key in keys(t:atp_toc[t:atp_bufname])
5858 if t:atp_toc[t:atp_bufname][key][0] == 'chapter'
5859 " return the short title if it is provided
5860 if t:atp_toc[t:atp_bufname][key][4] != ''
5861 call extend(chapter, {key : t:atp_toc[t:atp_bufname][key][4]},'force')
5863 call extend(chapter, {key : t:atp_toc[t:atp_bufname][key][2]},'force')
5865 elseif t:atp_toc[t:atp_bufname][key][0] == 'section'
5866 " return the short title if it is provided
5867 if t:atp_toc[t:atp_bufname][key][4] != ''
5868 call extend(section, {key : t:atp_toc[t:atp_bufname][key][4]},'force')
5870 call extend(section, {key : t:atp_toc[t:atp_bufname][key][2]},'force')
5872 elseif t:atp_toc[t:atp_bufname][key][0] == 'subsection'
5873 " return the short title if it is provided
5874 if t:atp_toc[t:atp_bufname][key][4] != ''
5875 call extend(subsection, {key : t:atp_toc[t:atp_bufname][key][4]},'force')
5877 call extend(subsection, {key : t:atp_toc[t:atp_bufname][key][2]},'force')
5882 " Remove $ from chapter/section/subsection names to save the space.
5883 let chapter_name=substitute(s:NearestSection(chapter)[0],'\$','','g')
5884 let chapter_line=s:NearestSection(chapter)[1]
5885 let chapter_nline=s:NearestSection(chapter)[2]
5887 let section_name=substitute(s:NearestSection(section)[0],'\$','','g')
5888 let section_line=s:NearestSection(section)[1]
5889 let section_nline=s:NearestSection(section)[2]
5890 " let b:section=s:NearestSection(section) " DEBUG
5892 let subsection_name=substitute(s:NearestSection(subsection)[0],'\$','','g')
5893 let subsection_line=s:NearestSection(subsection)[1]
5894 let subsection_nline=s:NearestSection(subsection)[2]
5895 " let b:ssection=s:NearestSection(subsection) " DEBUG
5897 let names = [ chapter_name ]
5898 if (section_line+0 >= chapter_line+0 && section_line+0 <= chapter_nline+0) || chapter_name == ''
5899 call add(names, section_name)
5900 elseif subsection_line+0 >= section_line+0 && subsection_line+0 <= section_nline+0
5901 call add(names, subsection_name)
5908 " if there is any argument given, then the function returns the value
5909 " (used by ATPStatus()), otherwise it echoes the section/subsection
5910 " title. It returns only the first b:atp_TruncateStatusSection
5911 " characters of the the whole titles.
5913 let chapter_name = get(names, 0, '')
5914 let section_name = get(names, 1, '')
5915 let subsection_name = get(names, 2, '')
5917 if chapter_name == "" && section_name == "" && subsection_name == ""
5925 elseif chapter_name != ""
5926 if section_name != ""
5928 return substitute(strpart(chapter_name,0,b:atp_TruncateStatusSection/2), '\_s*$', '','') . "/" . substitute(strpart(section_name,0,b:atp_TruncateStatusSection/2), '\_s*$', '','')
5932 return substitute(strpart(chapter_name,0,b:atp_TruncateStatusSection), '\_s*$', '','')
5935 elseif chapter_name == "" && section_name != ""
5936 if subsection_name != ""
5938 return substitute(strpart(section_name,0,b:atp_TruncateStatusSection/2), '\_s*$', '','') . "/" . substitute(strpart(subsection_name,0,b:atp_TruncateStatusSection/2), '\_s*$', '','')
5942 return substitute(strpart(section_name,0,b:atp_TruncateStatusSection), '\_s*$', '','')
5945 elseif chapter_name == "" && section_name == "" && subsection_name != ""
5947 return substitute(strpart(subsection_name,0,b:atp_TruncateStatusSection), '\_s*$', '','')
5954 " Labels Front End Finction. The search engine/show function are in autoload/atplib.vim script
5957 function! <SID>Labels(bang)
5958 let t:atp_bufname = bufname("%")
5959 let error = len(getqflist())
5960 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
5962 " Generate the dictionary with labels
5963 if a:bang == "" || ( a:bang == "!" && !exists("t:atp_labels") )
5964 let [ t:atp_labels, b:ListOfFiles ] = atplib#generatelabels(atp_MainFile, 1)
5967 " Show the labels in seprate window
5968 call atplib#showlabels([ t:atp_labels, map(copy(b:ListOfFiles), 'atplib#FullPath(v:val)')] )
5973 echomsg "The compelation contains errors, aux file might be not appriopriate for labels window."
5977 nnoremap <Plug>ATP_Labels :call <SID>Labels("")<CR>
5981 " Motion functions through environments and sections.
5982 " {{{ Motion functions
5983 " Go to next environment "{{{
5984 " which name is given as the argument. Do not wrap
5985 " around the end of the file.
5986 function! <SID>GotoEnvironment(flag,...)
5989 let env_name = ( a:0 >= 1 && a:1 != "" ? a:1 : '[^}]*' )
5991 let g:env_name = env_name
5993 " Set the search tool :
5995 let search_cmd = "S /"
5996 let search_cmd_e= "/ " . a:flag
5998 let search_cmd = "call search('"
5999 let search_cmd_e= "','" . a:flag . "')"
6002 if env_name == 'math'
6003 let pattern = '\m\%(\(\\@<!\\\)\@<!%.*\)\@<!\%(\%(\\begin\s*{\s*\%(\(displayed\)\?math\|\%(fl\)\?align\|eqnarray\|equation\|gather\|multline\|subequations\|xalignat\|xxalignat\)\s*}\)\|\\\@<!\\\[\|\\@<!\\(\|\\\@<!\$\$\=\)'
6004 elseif env_name == 'displayedmath'
6005 let pattern = '\m\%(\(\\\@<!\\\)\@<!%.*\)\@<!\%(\%(\\begin\s*{\s*\%(displayedmath\|\%(fl\)\?align\*\=\|eqnarray\*\=\|equation\*\=\|gather\*\=\|multline\*\=\|xalignat\*\=\|xxalignat\*\=\)\s*}\)\|\\\@<!\\\[\|\\\@!\$\$\)'
6006 elseif env_name == 'inlinemath'
6007 let pattern = '\m\%(\(\\\@<!\\\)\@<!%.*\)\@<!\%(\\begin\s*{\s*math\s*}\|\\\@<!\\(\|\$\@<!\\\@<!\$\$\@!\)'
6009 let pattern = '\m\%(\(\\\@<!\\\)\@<!%.*\)\@<!\\begin\s*{\s*' . env_name . '\s*}'
6012 " Search (twise if needed)
6013 silent execute search_cmd . pattern . search_cmd_e
6015 if getline(".")[col(".")-1] == "$"
6016 if ( get(split(getline("."), '\zs'), col(".")-1, '') == "$" && get(split(getline("."), '\zs'), col("."), '') == "$" )
6018 let rerun = !atplib#CheckSyntaxGroups(['texMathZoneY'], line("."), col(".")+1 )
6019 elseif get(split(getline("."), '\zs'), col(".")-1, '') == "$"
6021 let rerun = !atplib#CheckSyntaxGroups(['texMathZoneX', 'texMathZoneY'], line("."), col(".") )
6024 silent execute search_cmd . pattern . search_cmd_e
6027 else " a:flag =~# 'b'
6028 if getline(".")[col(".")-1] == "$"
6029 if ( get(split(getline("."), '\zs'), col(".")-1, '') == "$" && get(split(getline("."), '\zs'), col(".")-2, '') == "$" )
6031 let rerun = atplib#CheckSyntaxGroups(['texMathZoneY'], line("."), col(".")-3 )
6032 elseif get(split(getline("."), '\zs'), col(".")-1, '') == "$"
6034 let rerun = atplib#CheckSyntaxGroups(['texMathZoneX', 'texMathZoneY'], line("."), col(".")-2 )
6037 silent execute search_cmd . pattern . search_cmd_e
6042 let g:cmd=search_cmd . pattern . search_cmd_e
6043 call histadd("search", pattern)
6045 " if env_name == "math" && getline(".")[col(".")-1] == '$' && col(".") > 1 &&
6046 " \ ( count(map(synstack(line("."),col(".")-1), 'synIDattr(v:val, "name")'), 'texMathZoneX') == 0 ||
6047 " \ count(map(synstack(line("."),col(".")-1), 'synIDattr(v:val, "name")'), 'texMathZoneY') == 0 )
6048 " silent call search(pattern, a:flag)
6052 " Go to next section {{{
6053 " The extra argument is a pattern to match for the
6054 " section title. The first, obsolete argument stands for:
6055 " part,chapter,section,subsection,etc.
6056 " This commands wrap around the end of the file.
6057 " with a:3 = 'vim' it uses vim search() function
6060 " if g:atp_mapNn then use 'atp'
6062 function! <SID>GotoSection(bang, flag, secname, ...)
6063 let search_tool = ( a:0 >= 1 ? a:1 : ( g:atp_mapNn ? 'atp' : 'vim' ) )
6064 let mode = ( a:0 >= 2 ? a:2 : 'n' )
6065 let title_pattern = ( a:0 >= 3 ? a:3 : '' )
6066 let pattern = ( empty(a:bang) ? '^\([^%]\|\\\@<!\\%\)*' . a:secname . title_pattern : a:secname . title_pattern )
6068 " This is not working ?:/
6069 " just because it goes back to the mark '< and searches again:
6070 " if mode == 'v' | call cursor(getpos("'<")[1], getpos("'<")[2]) | endif
6071 " if mode == 'v' && visualmode() ==# 'V'
6073 " elseif mode == 'v'
6076 " let bpat = ( mode == 'v' ? "\\n\\s*" : "" )
6078 if search_tool == 'vim'
6079 let epos = searchpos(bpat . pattern, a:flag)
6081 execute "S /". bpat . pattern . "/ " . a:flag
6083 let g:pattern = bpat.pattern
6085 call histadd("search", pattern)
6088 function! Env_compl(A,P,L)
6089 let envlist=sort(['algorithm', 'algorithmic', 'abstract', 'definition', 'equation', 'proposition',
6090 \ 'theorem', 'lemma', 'array', 'tikzpicture',
6091 \ 'tabular', 'table', 'align\*\?', 'alignat\*\?', 'proof',
6092 \ 'corollary', 'enumerate', 'examples\=', 'itemize', 'remark',
6093 \ 'notation', 'center', 'quotation', 'quote', 'tabbing',
6094 \ 'picture', 'math', 'displaymath', 'minipage', 'list', 'flushright', 'flushleft',
6095 \ 'figure', 'eqnarray', 'thebibliography', 'titlepage',
6096 \ 'verbatim', 'verse', 'inlinemath', 'displayedmath', 'subequations' ])
6100 call add(returnlist,env)
6106 " {{{ NInput(), PInput functions
6107 function! <SID>Input(flag)
6108 let pat = ( &l:filetype == "plaintex" ? '\\input\s*{' : '\%(\\input\>\|\\include\s*{\)' )
6109 let @/ = '^\([^%]\|\\\@<!\\%\)*' . pat
6111 exe ':S /^\([^%]\|\\\@<!\\%\)*' . pat . '/ ' . a:flag
6113 call search('^\([^%]\|\\\@<!\\%\)*' . pat, a:flag)
6115 " This pattern is quite simple and it might be not neccesary to add it to
6117 " call histadd("search", pat)
6122 " This function also sets filetype vim option.
6123 " It is useing '\f' pattern thus it depends on the 'isfname' vim option.
6125 " NOTE: if the filetype is wrong the path will not be recognized
6126 " it is better to make it syntax independet!
6128 " It let choose if there are multiple files only when this is fast
6129 " (\input{,\input ) methods. However, then the file name should be unique!
6131 " It correctly sets b:atp_MainFile, and TreeOfFiles, ... variables in the new
6133 function! GotoFile(bang,...)
6136 exe "lcd " . b:atp_ProjectDir
6137 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
6139 " The default value is to check line if not stending on a comment.
6140 let check_line = a:0 >= 1 ? a:1 : strpart(getline("."), 0, col(".")) !~ '\(\\\@<!\\\)\@<!%'
6142 if !has("path_extra")
6143 echoerr "Needs +path_extra vim feature."
6148 let filetype = &l:filetype
6150 if a:bang == "!" || !exists("b:TreeOfFiles") || !exists("b:ListOfFiles") || !exists("b:TypeDict") || !exists("b:LevelDict")
6151 let [tree_d, file_l, type_d, level_d ] = TreeOfFiles(atp_MainFile)
6153 let [tree_d, file_l, type_d, level_d ] = deepcopy([ b:TreeOfFiles, b:ListOfFiles, b:TypeDict, b:LevelDict ])
6156 " This is passed to the newly opened buffer.
6157 let projectVarDict = SaveProjectVariables()
6159 let file_l_orig = deepcopy(file_l)
6161 " Note: line is set to "" if check_line == 0 => method = "all" is used.
6162 let line = check_line ? getline(".") : ""
6164 let beg_line = strpart(line, 0,col(".")-1)
6165 " Find the begining columnt of the file name:
6166 let bcol = searchpos('\%({\|,\)', 'bn', line("."))[1]
6168 let bcol = searchpos('{', 'n', line("."))[1]
6171 " Find the end column of the file name
6172 let col = searchpos(',\|}', 'cn', line("."))[1]
6174 let cur_col = col(".")
6182 " \usepackege{...,<package_name>,...}
6183 if line =~ '\\usepackage' && g:atp_developer
6184 let method = "usepackage"
6187 let fname = atplib#append_ext(strpart(getline("."), bcol, col-bcol-1), ext)
6188 let file = atplib#KpsewhichFindFile('tex', fname, g:atp_texinputs, 1)
6189 let file_l = [ file ]
6190 " let file = get(file_l, 0, "file_missing")
6192 let message = "Pacakge: "
6195 " \input{...}, \include{...}
6196 elseif line =~ '\\\(input\|include\)\s*{'
6197 let method = "input{"
6200 " \input{} doesn't allow for {...,...} many file path.
6201 let fname = atplib#append_ext(strpart(getline("."), bcol, col-bcol-1), '.tex')
6203 " The 'file . ext' might be already a full path.
6204 if fnamemodify(fname, ":p") != fname
6205 let file_l = atplib#KpsewhichFindFile('tex', fname, g:atp_texinputs, -1, ':p', '^\(\/home\|\.\)', '\%(^\/usr\|kpsewhich\|texlive\|miktex\)')
6206 let file = get(file_l, 0, 'file_missing')
6208 let file_l = [ fname ]
6212 let message = "File: "
6215 " \input /without {/
6216 elseif line =~ '\\input\s*{\@!'
6217 let method = "input"
6218 let fname = atplib#append_ext(matchstr(getline(line(".")), '\\input\s*\zs\f*\ze'), '.tex')
6219 let file_l = atplib#KpsewhichFindFile('tex', fname, g:atp_texinputs, -1, ':p', '^\(\/home\|\.\)', '\%(^\/usr\|kpsewhich\|texlive\)')
6220 let file = get(file_l, 0, "file_missing")
6221 let options = ' +setl\ ft=' . &l:filetype
6222 let g:File_l = file_l
6225 " \documentclass{...}
6226 elseif line =~ '\\documentclass' && g:atp_developer
6227 let method = "documentclass"
6228 let saved_pos = getpos(".")
6229 call cursor(line("."), 1)
6230 call search('\\documentclass\zs', 'cb', line("."))
6231 let bcol = searchpos('{', 'c', line("."))[1]
6234 call cursor(saved_pos[0], saved_pos[1])
6235 let classname = strpart(getline("."), bcol, ecol-bcol-1)
6237 let fname = atplib#append_ext(classname, '.cls')
6238 let file = atplib#KpsewhichFindFile('tex', fname, g:atp_texinputs, ':p')
6239 let file_l = [ file ]
6242 " If not over any above give a list of input files to open, like
6246 call extend(file_l, [ atp_MainFile ], 0)
6247 call extend(level_d, { atp_MainFile : 0 })
6248 " call filter(file_l, "v:val !~ expand('%') . '$'")
6252 let g:method = method
6253 let g:file_l = file_l
6257 let msg = "Which file to edit?"
6259 let msg = "Found many files. Which file to use?"
6261 let mods = method == 'all' ? ":t" : ":p"
6262 " It is better to start numbering from 0,
6263 " then 0 - is the main file
6264 " 1 - is the first chapter, and so on.
6268 if exists("level_d")
6270 if g:atp_RelativePath
6272 exe "lcd " . b:atp_ProjectDir
6273 let level = get(level_d,fnamemodify(f, ':.'), get(level_d, f, 1))
6277 exe "lcd " . b:atp_ProjectDir
6278 let level = get(level_d,f, get(level_d,fnamemodify(f, ':.'), 1))
6281 for j in range(level)
6287 call add(input_l, "(" . i . ") " . space . fnamemodify(f, mods))
6290 " Ask the user which file to edit:
6292 if len([ msg ] + input_l) < &l:lines
6293 for f in [ msg ] + input_l
6294 " echo highlighted message
6295 if matchstr(f, '(\d\+)\s*\zs.*$') == expand("%:t")
6301 if matchstr(f, '(\d\+)\s*\zs.*$') == expand("%:t") || f == msg
6305 let choice = input("Type number and <Enter> (empty cancels): ")
6310 for line in [ msg ] + input_l
6318 let choice = input("Type number and <Enter> (empty cancels): ")
6324 " Remember: 0 == "" returns 1!
6331 if choice < 1 || choice > len(file_l)
6332 if choice < 1 || choice > len(file_l)
6334 echoerr "Choice out of range."
6339 let file = file_l[choice-1]
6344 " let g:fname = fname
6346 " let g:file_l = file_l
6347 " let g:choice = choice
6354 if file != "file_missing" && filereadable(file) && ( !exists("choice") || exists("choice") && choice != 0 )
6356 " Inherit tex flavour.
6357 " So that bib, cls, sty files will have their file type (bib/plaintex).
6358 let filetype = &l:filetype
6359 let old_file = expand("%:p")
6360 execute "edit " . file
6361 if &l:filetype =~ 'tex$' && file =~ '\.tex$' && &l:filetype != filetype
6362 let &l:filetype = filetype
6365 " Set the main file variable and pass the TreeOfFiles variables to the new
6367 call RestoreProjectVariables(projectVarDict)
6368 let [ b:TreeOfFiles, b:ListOfFiles, b:TypeDict, b:LevelDict ] = deepcopy([tree_d, file_l_orig, type_d, level_d ])
6376 if file != "file_missing"
6377 echo "File \'".fname."\' not found."
6379 echo "Missing file."
6392 " {{{ TexSyntaxMotion
6393 function! TexSyntaxMotion(forward, how, ...)
6395 " If the function is used in imap.
6396 let in_imap = ( a:0 >= 1 ? a:1 : 0 )
6397 let g:imap = in_imap
6399 let whichwrap = split(&l:whichwrap, ',')
6400 if !count(whichwrap, 'l')
6403 if !count(whichwrap, 'h')
6407 " echomsg "________"
6408 " before we use <Esc>
6410 if in_imap && len(getline(".")) > col(".")
6411 let col = col(".")+1
6415 let g:pos = [ line(".") , col(".")]
6416 let g:pos0 = [ line , col]
6417 " execute "normal l"
6418 let step = ( a:forward > 0 ? "l" : "h" )
6419 let synstack = map(synstack(line, col), 'synIDattr( v:val, "name")')
6420 let synstackh = map(synstack(line, max([1, col-1])), 'synIDattr( v:val, "name")')
6421 let g:isynstack = deepcopy(synstack)
6422 while count(synstack, "Delimiter")
6423 execute "normal " . step
6424 let synstack = map(synstack(line("."), col(".")), 'synIDattr( v:val, "name")')
6426 let g:pos1 = [ line(".") , col(".")]
6428 let g:synstack = deepcopy(synstack)
6429 " let g:pos = getpos(".")
6430 " let DelimiterCount = count(synstack, 'Delimiter')
6431 " let g:DelimiterCount = DelimiterCount
6432 let ScriptCount = count(synstack, 'texSuperscript') + count(synstack, 'texSubscript')
6433 let ScriptsCount = count(synstack, 'texSuperscripts') + count(synstack, 'texSubscripts')
6434 let StatementCount = count(synstack, 'texStatement')
6435 let StatementCounth = count(synstackh, 'texStatement') && col(".") > 1
6436 let SectionCount = count(synstack, 'texSection')
6438 let TypeStyleCount = count(synstack, 'texTypeStyle')
6439 let TypeStyleCounth = count(synstackh, 'texTypeStyle') && col(".") > 1
6440 let MathTextCount = count(synstack, 'texMathText')
6441 let MathTextCounth = count(synstackh, 'texMathText') && col(".") > 1
6442 let RefZoneCount = count(synstack, 'texRefZone')
6443 let RefZoneCounth = count(synstackh, 'texRefZone') && col(".") > 1
6444 let RefOptionCount = count(synstack, 'texRefOption')
6445 let RefOptionCounth = count(synstackh, 'texRefOption') && !count(synstackh, 'Delimiter') && col(".") > 1
6446 let CiteCount = count(synstack, 'texCite')
6447 let CiteCounth = count(synstackh, 'texCite') && !count(synstackh, 'Delimiter') && col(".") > 1
6448 let MatcherCount = count(synstack, 'texMatcher')
6449 let MatcherCounth = count(synstackh, 'texMatcher') && !count(synstackh, 'Delimiter') && col(".") > 1
6450 let g:MatcherCount = MatcherCount
6451 let g:MatcherCounth = MatcherCounth
6452 let MathMatcherCount = count(synstack, 'texMathMatcher')
6453 let MathMatcherCounth = count(synstackh, 'texMathMatcher') && !count(synstackh, 'Delimiter') && col(".") > 1
6454 let g:MathMatcherCount = MathMatcherCount
6455 let g:MathMatcherCounth = MathMatcherCounth
6456 let SectionNameCount = count(synstack, 'texSectionName')
6457 let SectionNameCounth = count(synstackh, 'texSectionName') && !count(synstackh, 'Delimiter') && col(".") > 1
6458 let SectionMarkerCount = count(synstack, 'texSectionMarker')
6460 let SectionModifierCount = count(synstack, 'texSectionModifier')
6461 let SectionModifierCounth = count(synstackh, 'texSectionModifier') && !count(synstackh, 'Delimiter') && col(".") > 1
6462 " let MathZonesCount = len(filter(copy(synstack), 'v:val =~ ''^texMathZone[A-Z]'''))
6464 " let g:col = col(".")
6465 " let g:line = line(".")
6467 if StatementCount && StatementCounth && step == "h"
6468 let syntax = [ 'texStatement' ]
6469 elseif StatementCount && step != "h"
6470 let syntax = [ 'texStatement' ]
6472 let syntax = [ 'texSection' ]
6475 let syntax = [ 'texSuperscript', 'texSubscript']
6477 let syntax = [ 'texSuperscripts', 'texSubscripts']
6479 elseif TypeStyleCount && TypeStyleCounth && step == "h"
6480 let syntax = [ 'texTypeStyle' ]
6481 elseif TypeStyleCount && step != "h"
6482 let syntax = [ 'texTypeStyle' ]
6483 elseif RefZoneCount && RefZoneCounth && step == "h"
6484 let syntax = [ 'texRefZone' ]
6485 elseif RefZoneCount && step != "h"
6486 let syntax = [ 'texRefZone' ]
6487 elseif RefOptionCount && RefOptionCounth && step == "h"
6488 let syntax = [ 'texRefOption' ]
6489 elseif RefOptionCount && step != "h"
6490 let syntax = [ 'texRefOption' ]
6491 elseif CiteCount && CiteCounth && step == "h"
6492 let syntax = [ 'texCite' ]
6493 elseif CiteCount && step != "h"
6494 let syntax = [ 'texCite' ]
6495 elseif MatcherCount && MatcherCounth && step == "h"
6496 let syntax = [ 'texMatcher' ]
6497 elseif MatcherCount && step != "h"
6498 let syntax = [ 'texMatcher' ]
6499 elseif MathMatcherCount && MathMatcherCounth && step == "h"
6500 let syntax = [ 'texMathMatcher' ]
6501 elseif MathMatcherCount && step != "h"
6502 let syntax = [ 'texMathMatcher' ]
6503 elseif SectionNameCount && SectionNameCounth && step == "h"
6504 let syntax = [ 'texSectionName' ]
6505 elseif SectionNameCount && step != "h"
6506 let syntax = [ 'texSectionName' ]
6507 elseif SectionMarkerCount
6508 let syntax = [ 'texSectionMarker' ]
6509 elseif SectionModifierCount && SectionModifierCounth && step == "h"
6510 let syntax = [ 'texSectionModifier' ]
6511 elseif SectionModifierCount && step != "h"
6512 let syntax = [ 'texSectionModifier' ]
6513 elseif MathTextCount && MathTextCounth && step == "h"
6514 let syntax = [ 'texMathText' ]
6515 elseif MathTextCount && step != "h"
6516 let syntax = [ 'texMathText' ]
6517 " elseif MathZonesCount
6518 " This might be slow
6519 " but we might change 'normal l' to 'normal w'
6520 " let syntax = [ 'texMathZoneA', 'texMathZoneB', 'texMathZoneC', 'texMathZoneD', 'texMathZoneE', 'texMathZoneF', 'texMathZoneG', 'texMathZoneH', 'texMathZoneI', 'texMathZoneJ', 'texMathZoneK', 'texMathZoneL', 'texMathZoneT', 'texMathZoneV', 'texMathZoneW', 'texMathZoneX', 'texMathZoneY' ]
6522 " Go after first Delimiter
6523 let g:syntax = [ 'Delimiter motion' ]
6525 let DelimiterCount = count(synstack, 'Delimiter')
6526 while !DelimiterCount
6527 exe "normal " . step
6528 " echomsg step . " " . line(".") . " " . col(".")
6529 let synstack = map(synstack(line("."), col(".")), 'synIDattr( v:val, "name")')
6530 let DelimiterCount = count(synstack, 'Delimiter')
6532 let DelimiterCount = 0
6541 return "Delimiter motion"
6544 let g:syntax = deepcopy(syntax)
6548 let true += count(synstack, syn)
6550 let initial_count = true
6552 while true >= initial_count
6554 execute "normal " . step
6555 let synstack = map(synstack(line("."), col(".")), 'synIDattr( v:val, "name")')
6557 let true += count(synstack, syn)
6559 " echomsg string(synstack) . " " . string(syntax) . " " . true
6561 while getline(".")[col(".")] =~ '^{\|}\|(\|)\|\[\|\]$'
6564 if getline(".")[col(".")-2] == "{"
6567 let &l:whichwrap = join(whichwrap, ',')
6576 imap <Plug>TexSyntaxMotionForward <Esc>:call TexSyntaxMotion(1,1,1)<CR>a
6577 imap <Plug>TexSyntaxMotionBackward <Esc>:call TexSyntaxMotion(0,1,1)<CR>a
6578 nmap <Plug>TexSyntaxMotionForward :call TexSyntaxMotion(1,1)<CR>
6579 nmap <Plug>TexSyntaxMotionBackward :call TexSyntaxMotion(0,1)<CR>
6581 " Commands And Maps:
6582 command! -buffer -nargs=1 -complete=buffer MakeToc :echo s:maketoc(fnamemodify(<f-args>, ":p"))[fnamemodify(<f-args>, ":p")]
6583 command! -buffer -bang -nargs=? TOC :call <SID>TOC(<q-bang>)
6584 command! -buffer CTOC :call CTOC()
6585 command! -buffer -bang Labels :call <SID>Labels(<q-bang>)
6586 command! -buffer -count=1 -nargs=? -complete=customlist,Env_compl NEnv :call <SID>GotoEnvironment('W',<q-args>) | let v:searchforward=1
6587 command! -buffer -count=1 -nargs=? -complete=customlist,Env_compl PEnv :call <SID>GotoEnvironment('bW',<q-args>) | let v:searchforward=0
6589 nnoremap <silent> <buffer> <Plug>GotoNextEnvironment :NEnv <CR>
6590 nnoremap <silent> <buffer> <Plug>GotoPreviousEnvironment :PEnv <CR>
6592 nnoremap <silent> <buffer> <Plug>GotoNextMath :NEnv math<CR>
6593 nnoremap <silent> <buffer> <Plug>GotoPreviousMath :PEnv math<CR>
6595 nnoremap <silent> <buffer> <Plug>GotoNextInlineMath :Nenv inlinemath<CR>
6596 nnoremap <silent> <buffer> <Plug>GotoPreviousInlineMath :PEnv inlinemath<CR>
6598 nnoremap <silent> <buffer> <Plug>GotoNextDisplayedMath :NEnv displayedmath<CR>
6599 nnoremap <silent> <buffer> <Plug>GotoPreviousDisplayedMath :PEnv displayedmath<CR>
6600 nnoremap <silent> <Plug>GotoNextSubSection :call <SID>GotoSection("", "", '"\\\\\\%(subsection\\\\|section\\\\|chapter\\\\|part\\)\\s*{", ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', '')<CR>
6601 onoremap <silent> <Plug>GotoNextSubSection :call <SID>GotoSection("", "","\\\\\\%(subsection\\\\|section\\\\|chapter\\\\|part\\)\\s*{", 'vim')<CR>
6602 vnoremap <silent> <Plug>vGotoNextSubSection m':<C-U>exe "normal! gv"<Bar>exe "normal! w"<Bar>call search('^\([^%]\|\\\@<!\\%\)*\\\%(subsection\\|section\\|chapter\\|part\)\s*{\\|\\end\s*{\s*document\s*}', 'W')<Bar>exe "normal! b"<CR>
6604 nnoremap <silent> <Plug>GotoNextSection :call <SID>GotoSection("", "", "\\\\\\%(section\\\\|chapter\\\\|part\\)\\s*{", ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', '')<CR>
6605 onoremap <silent> <Plug>GotoNextSection :call <SID>GotoSection("", "", "\\\\\\%(section\\\\|chapter\\\\|part\\)\\s*{", 'vim')<CR>
6606 vnoremap <silent> <Plug>vGotoNextSection m':<C-U>exe "normal! gv"<Bar>exe "normal! w"<Bar>call search('^\([^%]\|\\\@<!\\%\)*\\\%(section\\|chapter\\|part\)\s*{\\|\\end\s*{\s*document\s*}', 'W')<Bar>exe "normal! b"<CR>
6608 nnoremap <silent> <Plug>GotoNextChapter :call <SID>GotoSection("", "", "\\\\\\%(chapter\\\\|part\\)\\s*{", ( g:atp_mapNn ? 'atp' : 'vim' ))<CR>
6609 onoremap <silent> <Plug>GotoNextChapter :call <SID>GotoSection("", "", "\\\\\\%(chapter\\\\|part\\)\\s*{", 'vim')<CR>
6610 vnoremap <silent> <Plug>vGotoNextChapter m':<C-U>exe "normal! gv"<Bar>exe "normal! w"<Bar>call search('^\([^%]\|\\\@<!\\%\)*\\\%(chapter\\|part\)\s*{\\|\\end\s*{\s*document\s*}', 'W')<Bar>exe "normal! b"<CR>
6612 nnoremap <silent> <Plug>GotoNextPart :call <SID>GotoSection("", "", "\\\\part\\s*{", ( g:atp_mapNn ? 'atp' : 'vim' ), 'n')<CR>
6613 onoremap <silent> <Plug>GotoNextPart :call <SID>GotoSection("", "", "\\\\part\\s*{", 'vim', 'n')<CR>
6614 vnoremap <silent> <Plug>vGotoNextPart m':<C-U>exe "normal! gv"<Bar>exe "normal! w"<Bar>call search('^\([^%]\|\\\@<!\\%\)*\\\%(part\\|end\s*{\s*document\s*}\)\s*{', 'W')<Bar>exe "normal! b"<CR>
6616 command! -buffer -bang -count=1 -nargs=? -complete=customlist,Env_compl NSSSec :call <SID>GotoSection(<q-bang>, "", '\\\%(subsubsection\|subsection\|section\|chapter\|part\)\s*{', ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', <q-args>)
6617 command! -buffer -bang -count=1 -nargs=? -complete=customlist,Env_compl NSSec :call <SID>GotoSection(<q-bang>, "", '\\\%(subsection\|section\|chapter\|part\)\s*{', ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', <q-args>)
6618 command! -buffer -bang -count=1 -nargs=? -complete=customlist,Env_compl NSec :call <SID>GotoSection(<q-bang>, "", '\\\%(section\|chapter\|part\)\s*{', ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', <q-args>)
6619 command! -buffer -bang -count=1 -nargs=? -complete=customlist,Env_compl NChap :call <SID>GotoSection(<q-bang>, "", '\\\%(chapter\|part\)\s*{', ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', <q-args>)
6620 command! -buffer -bang -count=1 -nargs=? -complete=customlist,Env_compl NPart :call <SID>GotoSection(<q-bang>, "", '\\part\s*{', ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', <q-args>)
6621 nnoremap <silent> <Plug>GotoPreviousSubSection :call <SID>GotoSection("", "b", "\\\\\\%(subsection\\\\|section\\\\|chapter\\\\|part\\)\\s*{", ( g:atp_mapNn ? 'atp' : 'vim' ), 'n')<CR>
6622 onoremap <silent> <Plug>GotoPreviousSubSection :call <SID>GotoSection("", "b", "\\\\\\%(subsection\\\\|section\\\\|chapter\\\\|part\\)\\s*{", 'vim')<CR>
6623 vnoremap <silent> <Plug>vGotoPreviousSubSection m':<C-U>exe "normal! gv"<Bar>call search('\\\%(subsection\\\\|section\\|chapter\\|part\)\s*{\\|\\begin\s*{\s*document\s*}', 'bW')<CR>
6625 nnoremap <silent> <Plug>GotoPreviousSection :call <SID>GotoSection("", "b", "\\\\\\%(section\\\\|chapter\\\\|part\\)\\s*{", ( g:atp_mapNn ? 'atp' : 'vim' ), 'n')<CR>
6626 onoremap <silent> <Plug>GotoPreviousSection :call <SID>GotoSection("", "b", "\\\\\\%(section\\\\|chapter\\\\|part\\)\\s*{", 'vim')<CR>
6627 vnoremap <silent> <Plug>vGotoPreviousSection m':<C-U>exe "normal! gv"<Bar>call search('\\\%(section\\|chapter\\|part\)\s*{\\|\\begin\s*{\s*document\s*}', 'bW')<CR>
6629 nnoremap <silent> <Plug>GotoPreviousChapter :call <SID>GotoSection("", "b", "\\\\\\%(chapter\\\\|part\\)\\s*{", ( g:atp_mapNn ? 'atp' : 'vim' ))<CR>
6630 onoremap <silent> <Plug>GotoPreviousChapter :call <SID>GotoSection("", "b", "\\\\\\%(chapter\\\\|part\\)\\s*{", 'vim')<CR
6631 vnoremap <silent> <Plug>vGotoPreviousChapter m':<C-U>exe "normal! gv"<Bar>call search('\\\%(chapter\\|part\)\s*{\\|\\begin\s*{\s*document\s*}', 'bW')<CR>
6633 nnoremap <silent> <Plug>GotoPreviousPart :call <SID>GotoSection("", "b", "\\\\part\\s*{", ( g:atp_mapNn ? 'atp' : 'vim' ))<CR>
6634 onoremap <silent> <Plug>GotoPreviousPart :call <SID>GotoSection("", "b", "\\\\part\\s*{", 'vim')<CR>
6635 vnoremap <silent> <Plug>vGotoPreviousPart m':<C-U>exe "normal! gv"<Bar>call search('\\\%(part\)\s*{', 'bW')<CR>
6637 command! -buffer -bang -count=1 -nargs=? -complete=customlist,Env_compl PSSSec :call <SID>PreviousSection('\\\%(subsubsection\|subsection\|section\|chapter\|part\)', ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', <q-args>)
6638 command! -buffer -bang -count=1 -nargs=? -complete=customlist,Env_compl PSSec :call <SID>GotoSection(<q-bang>, 'b', '\\\%(subsection\|section\|chapter\|part\)', ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', <q-args>)
6639 command! -buffer -bang -count=1 -nargs=? -complete=customlist,Env_compl PSec :call <SID>GotoSection(<q-bang>, 'b', '\\\%(section\|chapter\|part\)', ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', <q-args>)
6640 command! -buffer -bang -count=1 -nargs=? -complete=customlist,Env_compl PChap :call <SID>GotoSection(<q-bang>, 'b', '\\\%(chapter\|part\)', ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', <q-args>)
6641 command! -buffer -bang -count=1 -nargs=? -complete=customlist,Env_compl PPart :call <SID>GotoSection(<q-bang>, 'b', '\\part\s*{', ( g:atp_mapNn ? 'atp' : 'vim' ), 'n', <q-args>)
6642 command! -buffer NInput :call <SID>Input("w") | let v:searchforward = 1
6643 command! -buffer PInput :call <SID>Input("bw") | let v:searchforward = 0
6644 command! -buffer -bang GotoFile :call GotoFile(<q-bang>, 0)
6645 command! -buffer -bang EditInputFile :call GotoFile(<q-bang>, 0)
6646 " vim:fdm=marker:tw=85:ff=unix:noet:ts=8:sw=4:fdc=1
6647 ftplugin/ATP_files/options.vim [[[1
6649 " Author: Marcin Szamotulski
6650 " Description: This file contains all the options defined on startup of ATP
6651 " Note: This file is a part of Automatic Tex Plugin for Vim.
6652 " URL: https://launchpad.net/automatictexplugin
6655 " NOTE: you can add your local settings to ~/.atprc.vim or
6656 " ftplugin/ATP_files/atprc.vim file
6658 " Some options (functions) should be set once:
6659 let s:did_options = exists("s:did_options") ? 1 : 0
6661 "{{{ tab-local variables
6662 " We need to know bufnumber and bufname in a tabpage.
6663 " ToDo: we can set them with s: and call them using <SID> stack
6664 " (how to make the <SID> stack invisible to the user!
6666 let t:atp_bufname = bufname("")
6667 let t:atp_bufnr = bufnr("")
6668 let t:atp_winnr = winnr()
6671 " autocommands for buf/win numbers
6672 " These autocommands are used to remember the last opened buffer number and its
6675 augroup ATP_TabLocalVariables
6677 au BufLeave *.tex let t:atp_bufname = resolve(fnamemodify(bufname(""),":p"))
6678 au BufLeave *.tex let t:atp_bufnr = bufnr("")
6679 " t:atp_winnr the last window used by tex, ToC or Labels buffers:
6680 au WinEnter *.tex let t:atp_winnr = winnr("#")
6681 au WinEnter __ToC__ let t:atp_winnr = winnr("#")
6682 au WinEnter __Labels__ let t:atp_winnr = winnr("#")
6683 au TabEnter *.tex let t:atp_SectionStack = ( exists("t:atp_SectionStack") ? t:atp_SectionStack : [] )
6688 " ATP Debug Variables: (to debug atp behaviour)
6689 " {{{ debug variables
6690 if !exists("g:atp_debugSIT")
6691 " debug <SID>SearchInTree (search.vim)
6692 let g:atp_debugSIT = 0
6694 if !exists("g:atp_debugRS")
6695 " debug <SID>RecursiveSearch() (search.vim)
6696 let g:atp_debugRS = 0
6698 if !exists("g:atp_debugV")
6699 " debug ViewOutput() (compiler.vim)
6700 let g:atp_debugV = 0
6702 if !exists("g:atp_debugLPS")
6703 " Debug s:LoadProjectFile() (history.vim)
6704 " (currently it gives just the loading time info)
6705 let g:atp_debugLPS = 0
6707 if !exists("g:atp_debugCompiler")
6708 " Debug s:Compiler() function (compiler.vim)
6709 " when equal 2 output is more verbose.
6710 let g:atp_debugCompiler = 0
6712 if !exists("g:atp_debugST")
6713 " Debug <SID>CallBack() function (compiler.vim)
6714 let g:atp_debugCallBack = 0
6716 if !exists("g:atp_debugST")
6717 " Debug SyncTex() (various.vim) function
6718 let g:atp_debugST = 0
6720 if !exists("g:atp_debugCLE")
6721 " Debug atplib#CloseLastEnvironment()
6722 let g:atp_debugCLE = 0
6724 if !exists("g:atp_debugMainScript")
6725 " loading times of scripts sources by main script file: ftpluing/tex_atp.vim
6726 " NOTE: it is listed here for completeness, it can only be set in
6727 " ftplugin/tex_atp.vim script file.
6728 let g:atp_debugMainScript = 0
6731 if !exists("g:atp_debugProject")
6732 " <SID>LoadScript(), <SID>LoadProjectScript(), <SID>WriteProject()
6733 " The value that is set in history file matters!
6734 let g:atp_debugProject = 0
6736 if !exists("g:atp_debugCB")
6737 " atplib#CheckBracket()
6738 let g:atp_debugCB = 0
6740 if !exists("g:atp_debugCLB")
6741 " atplib#CloseLastBracket()
6742 let g:atp_debugCLB = 0
6744 if !exists("g:atp_debugTC")
6745 " atplib#TabCompletion()
6746 let g:atp_debugTC = 0
6748 if !exists("g:atp_debugBS")
6749 " atplib#searchbib()
6750 " atplib#showresults()
6751 " BibSearch() in ATP_files/search.vim
6752 " log file: /tmp/ATP_log
6753 let g:atp_debugBS = 0
6755 if !exists("g:atp_debugToF")
6756 " TreeOfFiles() ATP_files/common.vim
6757 let g:atp_debugToF = 0
6759 if !exists("g:atp_debgTOF")
6760 " TreeOfFiles() redirect only the output to
6762 let g:atp_debugTOF = 0
6764 if !exists("g:atp_debugBabel")
6765 " echo msg if babel language is not supported.
6766 let g:atp_debugBabel = 0
6770 " vim options + indentation
6774 if !exists("g:atp_indentation")
6775 let g:atp_indentation=1
6777 " if !exists("g:atp_tex_indent_paragraphs")
6778 " let g:atp_tex_indent_paragraphs=1
6780 if g:atp_indentation
6781 " setl indentexpr=GetTeXIndent()
6783 " setl nosmartindent
6785 " setl indentkeys+=},=\\item,=\\bibitem,=\\[,=\\],=<CR>
6786 " let prefix = expand('<sfile>:p:h:h')
6787 " exe 'so '.prefix.'/indent/tex_atp.vim'
6788 let prefix = expand('<sfile>:p:h')
6789 exe 'so '.prefix.'/LatexBox_indent.vim'
6793 setl keywordprg=texdoc\ -m
6794 " Borrowed from tex.vim written by Benji Fisher:
6795 " Set 'comments' to format dashed lists in comments
6796 setlocal com=sO:%\ -,mO:%\ \ ,eO:%%,:%
6798 " Set 'commentstring' to recognize the % comment character:
6799 " (Thanks to Ajit Thakkar.)
6802 " Allow "[d" to be used to find a macro definition:
6803 " Recognize plain TeX \def as well as LaTeX \newcommand and \renewcommand .
6804 " I may as well add the AMS-LaTeX DeclareMathOperator as well.
6805 let &l:define='\\\([egx]\|char\|mathchar\|count\|dimen\|muskip\|skip\|toks\)\='
6806 \ . 'def\|\\font\|\\\(future\)\=let'
6807 \ . '\|\\new\(count\|dimen\|skip\|muskip\|box\|toks\|read\|write'
6808 \ . '\|fam\|insert\)'
6809 \ . '\|\\\(re\)\=new\(boolean\|command\|counter\|environment\|font'
6810 \ . '\|if\|length\|savebox\|theorem\(style\)\=\)\s*\*\=\s*{\='
6811 \ . '\|DeclareMathOperator\s*{\=\s*'
6812 let g:filetype = &l:filetype
6813 if &l:filetype != "plaintex"
6814 setlocal include=\\\\input\\(\\s*{\\)\\=\\\\|\\\\include\\s*{
6816 setlocal include=\\\\input
6818 setlocal suffixesadd=.tex
6820 setlocal includeexpr=substitute(v:fname,'\\%(.tex\\)\\?$','.tex','')
6821 " TODO set define and work on the above settings, these settings work with [i
6822 " command but not with [d, [D and [+CTRL D (jump to first macro definition)
6824 " This was throwing all autocommand groups to the command line on startup.
6825 " Anyway this is not very good.
6826 " augroup ATP_makeprg
6827 " au VimEnter *.tex let &l:makeprg="vim --servername " . v:servername . " --remote-expr 'Make()'"
6832 " Buffer Local Variables:
6833 " {{{ buffer variables
6834 let b:atp_running = 0
6836 " these are all buffer related variables:
6837 let s:optionsDict= { "atp_TexOptions" : "",
6838 \ "atp_ReloadOnError" : "1",
6839 \ "atp_OpenViewer" : "1",
6840 \ "atp_autex" : !&l:diff,
6841 \ "atp_ProjectScript" : "1",
6842 \ "atp_Viewer" : has("win26") || has("win32") || has("win64") || has("win95") || has("win32unix") ? "AcroRd32.exe" : "xpdf" ,
6843 \ "atp_TexFlavor" : &l:filetype,
6844 \ "atp_XpdfServer" : fnamemodify(b:atp_MainFile,":t:r"),
6845 \ "atp_OutDir" : substitute(fnameescape(fnamemodify(resolve(expand("%:p")),":h")) . "/", '\\\s', ' ' , 'g'),
6846 \ "atp_TexCompiler" : &filetype == "plaintex" ? "pdftex" : "pdflatex",
6847 \ "atp_auruns" : "1",
6848 \ "atp_TruncateStatusSection" : "40",
6849 \ "atp_LastBibPattern" : "" }
6851 " the above atp_OutDir is not used! the function s:SetOutDir() is used, it is just to
6852 " remember what is the default used by s:SetOutDir().
6854 " This function sets options (values of buffer related variables) which were
6855 " not already set by the user.
6857 let s:ask = { "ask" : "0" }
6858 function! s:SetOptions()
6860 let s:optionsKeys = keys(s:optionsDict)
6861 let s:optionsinuseDict = getbufvar(bufname("%"),"")
6863 "for each key in s:optionsKeys set the corresponding variable to its default
6864 "value unless it was already set in .vimrc file.
6865 for l:key in s:optionsKeys
6866 if string(get(s:optionsinuseDict,l:key, "optionnotset")) == string("optionnotset") && l:key != "atp_OutDir" && l:key != "atp_autex"
6867 " echomsg l:key . " " . s:optionsDict[l:key]
6868 call setbufvar(bufname("%"),l:key,s:optionsDict[l:key])
6869 elseif l:key == "atp_OutDir"
6871 " set b:atp_OutDir and the value of errorfile option
6872 if !exists("b:atp_OutDir")
6875 let s:ask["ask"] = 1
6878 " Do not run tex on tex files which are in texmf tree
6879 " Exception: if it is opened using the command ':EditInputFile'
6880 " which sets this itself.
6881 if string(get(s:optionsinuseDict,"atp_autex", 'optionnotset')) == string('optionnotset')
6882 let atp_texinputs=split(substitute(substitute(system("kpsewhich -show-path tex"),'\/\/\+','\/','g'),'!\|\n','','g'),':')
6883 call remove(atp_texinputs, '.')
6884 call filter(atp_texinputs, 'v:val =~ b:atp_OutDir')
6885 if len(l:atp_texinputs) == 0
6892 if !exists("b:TreeOfFiles") || !exists("b:ListOfFiles") || !exists("b:TypeDict") || !exists("b:LevelDict")
6893 if exists("b:atp_MainFile")
6894 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
6895 call TreeOfFiles(atp_MainFile)
6897 echomsg "b:atp_MainFile " . "doesn't exists."
6906 " Global Variables: (almost all)
6907 " {{{ global variables
6908 if !exists("g:atp_vmap_text_font_leader")
6909 let g:atp_vmap_text_font_leader="<LocalLeader>"
6911 if !exists("g:atp_vmap_environment_leader")
6912 let g:atp_vmap_environment_leader=""
6914 if !exists("g:atp_vmap_bracket_leader")
6915 let g:atp_vmap_bracket_leader="<LocalLeader>"
6917 if !exists("g:atp_vmap_big_bracket_leader")
6918 let g:atp_vmap_big_bracket_leader='<LocalLeader>b'
6920 if !exists("g:atp_map_forward_motion_leader")
6921 let g:atp_map_forward_motion_leader='}'
6923 if !exists("g:atp_map_backward_motion_leader")
6924 let g:atp_map_backward_motion_leader='{'
6926 if !exists("g:atp_RelativePath")
6927 " This is here only for completness, the default value is set in project.vim
6928 let g:atp_RelativePath = 1
6930 if !exists("g:atp_SyncXpdfLog")
6931 let g:atp_SyncXpdfLog = 0
6933 if !exists("g:atp_SyncLog")
6934 let g:atp_SyncLog = 0
6937 function! s:Sync(...)
6938 let arg = ( a:0 >=1 ? a:1 : "" )
6940 let g:atp_SyncLog = 1
6942 let g:atp_SyncLog = 0
6944 let g:atp_SyncLog = !g:atp_SyncLog
6946 echomsg "g:atp_SyncLog = " . g:atp_SyncLog
6948 command! -nargs=? -complete=customlist,s:SyncComp Sync :call s:Sync(<f-args>)
6949 function! s:SyncComp(ArgLead, CmdLine, CursorPos)
6950 return filter(['on', 'off'], "v:val =~ a:ArgLead")
6953 if !exists("g:atp_Compare")
6954 " Use b:changedtick variable to run s:Compiler automatically.
6955 let g:atp_Compare = "changedtick"
6957 if !exists("g:atp_babel")
6960 " if !exists("g:atp_closebracket_checkenv")
6961 " This is a list of environment names. They will be checked by
6962 " atplib#CloseLastBracket() function (if they are opened/closed:
6963 " ( \begin{array} ... <Tab> will then close first \begin{array} and then ')'
6965 let g:atp_closebracket_checkenv = [ 'array' ]
6966 " Changing this variable is not yet supported *see ToDo: in
6967 " atplib#CloseLastBracket() (autoload/atplib.vim)
6968 lockvar g:atp_closebracket_checkenv
6970 " echomsg "Changing this variable is not supported"
6973 " if !exists("g:atp_ProjectScript")
6974 " let g:atp_ProjectScript = 1
6976 if !exists("g:atp_OpenTypeDict")
6977 let g:atp_OpenTypeDict = {
6978 \ "pdf" : "xpdf", "ps" : "evince",
6979 \ "djvu" : "djview", "txt" : "split" ,
6980 \ "tex" : "edit", "dvi" : "xdvi -s 5" }
6981 " for txt type files supported viewers: cat, gvim = vim = tabe, split, edit
6983 if !exists("g:atp_LibraryPath")
6984 let g:atp_LibraryPath = 0
6986 if !exists("g:atp_statusOutDir")
6987 let g:atp_statusOutDir = 1
6989 if !exists("g:atp_developer")
6990 let g:atp_developer = 0
6992 if !exists("g:atp_mapNn")
6993 let g:atp_mapNn = 0 " This value is used only on startup, then :LoadHistory sets the default value.
6994 endif " user cannot change the value set by :LoadHistory on startup in atprc file.
6996 " au VimEnter *.tex let b:atp_mapNn = 0
6997 " " Recently I changed this: in project files it is
6998 " better to start with atp_mapNn = 0 and let the
7000 if !exists("g:atp_TeXdocDefault")
7001 let g:atp_TeXdocDefault = '-a lshort'
7004 "ToDo: luatex! (can produce both!)
7005 if !exists("g:atp_CompilersDict")
7006 let g:atp_CompilersDict = {
7007 \ "pdflatex" : ".pdf", "pdftex" : ".pdf",
7008 \ "xetex" : ".pdf", "latex" : ".dvi",
7009 \ "tex" : ".dvi", "elatex" : ".dvi",
7010 \ "etex" : ".dvi", "luatex" : ".pdf"}
7013 if !exists("g:CompilerMsg_Dict")
7014 let g:CompilerMsg_Dict = {
7017 \ 'pdftex' : 'pdfTeX',
7018 \ 'latex' : 'LaTeX',
7019 \ 'elatex' : 'eLaTeX',
7020 \ 'pdflatex' : 'pdfLaTeX',
7021 \ 'context' : 'ConTeXt',
7022 \ 'luatex' : 'LuaTeX',
7023 \ 'xetex' : 'XeTeX'}
7026 if !exists("g:ViewerMsg_Dict")
7027 let g:ViewerMsg_Dict = {
7031 \ 'okular' : 'Okular',
7032 \ 'evince' : 'Evince',
7033 \ 'acroread' : 'AcroRead',
7034 \ 'epdfview' : 'epdfView' }
7038 if !exists("g:atp_insert_updatetime")
7039 let g:atp_insert_updatetime = max([ 2000, &l:updatetime])
7041 if !exists("g:atp_DefaultDebugMode")
7042 " recognised values: silent, debug.
7043 let g:atp_DefaultDebugMode = "silent"
7045 if !exists("g:atp_show_all_lines")
7047 let g:atp_show_all_lines = 0
7049 if !exists("g:atp_ignore_unmatched")
7051 let g:atp_ignore_unmatched = 1
7053 if !exists("g:atp_imap_first_leader")
7054 let g:atp_imap_first_leader = "#"
7056 if !exists("g:atp_imap_second_leader")
7057 let g:atp_imap_second_leader= "##"
7059 if !exists("g:atp_imap_third_leader")
7060 let g:atp_imap_third_leader = "]"
7062 if !exists("g:atp_imap_fourth_leader")
7063 let g:atp_imap_fourth_leader= "["
7066 if !exists("g:atp_completion_font_encodings")
7067 let g:atp_completion_font_encodings = ['T1', 'T2', 'T3', 'T5', 'OT1', 'OT2', 'OT4', 'UT1']
7070 if !exists("g:atp_font_encoding")
7071 let s:line=atplib#SearchPackage('fontenc')
7073 " the last enconding is the default one for fontenc, this we will
7075 let s:enc=matchstr(getline(s:line),'\\usepackage\s*\[\%([^,]*,\)*\zs[^]]*\ze\]\s*{fontenc}')
7079 let g:atp_font_encoding=s:enc
7083 if !exists("g:atp_no_star_environments")
7084 let g:atp_no_star_environments=['document', 'flushright', 'flushleft', 'center',
7085 \ 'enumerate', 'itemize', 'tikzpicture', 'scope',
7086 \ 'picture', 'array', 'proof', 'tabular', 'table' ]
7088 if !exists("g:atp_sizes_of_brackets")
7089 let g:atp_sizes_of_brackets={'\left': '\right',
7090 \ '\bigl' : '\bigr',
7091 \ '\Bigl' : '\Bigr',
7092 \ '\biggl' : '\biggr' ,
7093 \ '\Biggl' : '\Biggr',
7096 \ '\bigg' : '\bigg',
7097 \ '\Bigg' : '\Bigg',
7100 " the last one is not a size of a bracket is to a hack to close \(:\), \[:\] and
7103 if !exists("g:atp_algorithmic_dict")
7104 let g:atp_algorithmic_dict = { 'IF' : 'ENDIF', 'FOR' : 'ENDFOR', 'WHILE' : 'ENDWHILE' }
7106 if !exists("g:atp_bracket_dict")
7107 let g:atp_bracket_dict = { '(' : ')', '{' : '}', '[' : ']', '\lceil' : '\rceil', '\lfloor' : '\rfloor', '\langle' : '\rangle', '\lgroup' : '\rgroup' }
7110 if !exists("g:atp_LatexBox")
7111 let g:atp_LatexBox = 1
7113 if !exists("g:atp_check_if_LatexBox")
7114 let g:atp_check_if_LatexBox = 1
7116 if !exists("g:atp_autex_check_if_closed")
7117 let g:atp_autex_check_if_closed = 1
7119 if !exists("g:rmcommand") && executable("perltrash")
7120 let g:rmcommand="perltrash"
7121 elseif !exists("g:rmcommand")
7122 let g:rmcommand = "rm"
7124 if !exists("g:atp_env_maps_old")
7125 let g:atp_env_maps_old = 0
7127 if !exists("g:atp_amsmath")
7128 let g:atp_amsmath=atplib#SearchPackage('ams')
7130 if !exists("g:atp_no_math_command_completion")
7131 let g:atp_no_math_command_completion = 0
7133 if !exists("g:atp_tex_extensions")
7134 let g:atp_tex_extensions = ["tex.project.vim", "aux", "log", "bbl", "blg", "spl", "snm", "nav", "thm", "brf", "out", "toc", "mpx", "idx", "ind", "ilg", "maf", "blg", "glo", "mtc[0-9]", "mtc1[0-9]", "pdfsync"]
7136 if !exists("g:atp_delete_output")
7137 let g:atp_delete_output = 0
7139 if !exists("g:keep")
7140 let g:keep=[ "log", "aux", "toc", "bbl", "ind", "pdfsync" ]
7142 if !exists("g:printingoptions")
7143 let g:printingoptions = ''
7145 if !exists("g:atp_ssh")
7146 let g:atp_ssh=substitute(system("whoami"),'\n','','') . "@localhost"
7148 " opens bibsearch results in vertically split window.
7149 if !exists("g:vertical")
7152 if !exists("g:matchpair")
7153 let g:matchpair="(:),[:],{:}"
7155 if !exists("g:texmf")
7156 let g:texmf = $HOME . "/texmf"
7158 if !exists("g:atp_compare_embedded_comments") || g:atp_compare_embedded_comments != 1
7159 let g:atp_compare_embedded_comments = 0
7161 if !exists("g:atp_compare_double_empty_lines") || g:atp_compare_double_empty_lines != 0
7162 let g:atp_compare_double_empty_lines = 1
7164 "TODO: put toc_window_with and labels_window_width into DOC file
7165 if !exists("t:toc_window_width")
7166 if exists("g:toc_window_width")
7167 let t:toc_window_width = g:toc_window_width
7169 let t:toc_window_width = 30
7172 if !exists("t:atp_labels_window_width")
7173 if exists("g:labels_window_width")
7174 let t:atp_labels_window_width=g:labels_window_width
7176 let t:atp_labels_window_width = 30
7179 if !exists("g:atp_completion_limits")
7180 let g:atp_completion_limits = [40,60,80,120]
7182 if !exists("g:atp_long_environments")
7183 let g:atp_long_environments = []
7185 if !exists("g:atp_no_complete")
7186 let g:atp_no_complete = ['document']
7188 " if !exists("g:atp_close_after_last_closed")
7189 " let g:atp_close_after_last_closed=1
7191 if !exists("g:atp_no_env_maps")
7192 let g:atp_no_env_maps = 0
7194 if !exists("g:atp_extra_env_maps")
7195 let g:atp_extra_env_maps = 0
7197 " todo: to doc. Now they go first.
7198 " if !exists("g:atp_math_commands_first")
7199 " let g:atp_math_commands_first=1
7201 if !exists("g:atp_completion_truncate")
7202 let g:atp_completion_truncate = 4
7205 " add server call back (then automatically reads errorfiles)
7206 if !exists("g:atp_statusNotif")
7207 if has('clientserver') && !empty(v:servername)
7208 let g:atp_statusNotif = 1
7210 let g:atp_statusNotif = 0
7213 if !exists("g:atp_statusNotifHi")
7214 let g:atp_statusNotifHi = 0
7216 if !exists("g:atp_callback")
7217 if exists("g:atp_status_notification") && g:atp_status_notification == 1
7218 let g:atp_callback = 1
7219 elseif has('clientserver') && !empty(v:servername)
7220 let g:atp_callback = 1
7222 let g:atp_callback = 0
7226 " I switched this off.
7227 " if !exists("g:atp_complete_math_env_first")
7228 " let g:atp_complete_math_env_first=0
7234 if !exists("g:atp_ProjectLocalVariables")
7235 " This is a list of variable names which will be preserved in project files
7236 let g:atp_ProjectLocalVariables = [
7237 \ "b:atp_MainFile", "g:atp_mapNn", "b:atp_autex",
7238 \ "b:atp_TexCompiler", "b:atp_TexFlavor", "b:atp_OutDir" ,
7239 \ "b:atp_auruns", "b:atp_ReloadOnErr", "b:atp_OpenViewer",
7240 \ "b:atp_XpdfServer", "b:atp_ProjectDir", "b:atp_Viewer"
7243 " the variable a:1 is the name of the variable which stores the list of variables to
7245 function! SaveProjectVariables(...)
7246 let variables_List = ( a:0 >= 1 ? {a:1} : g:atp_ProjectLocalVariables )
7247 let variables_Dict = {}
7248 for var in variables_List
7250 call extend(variables_Dict, { var : {var} })
7253 return variables_Dict
7255 function! RestoreProjectVariables(variables_Dict)
7256 for var in keys(a:variables_Dict)
7257 let g:cmd = "let " . var . "=" . string(a:variables_Dict[var])
7259 exe "let " . var . "=" . string(a:variables_Dict[var])
7264 " This is to be extended into a nice function which shows the important options
7265 " and allows to reconfigure atp
7267 let s:file = expand('<sfile>:p')
7268 function! s:ShowOptions(bang,...)
7270 let pattern = a:0 >= 1 ? a:1 : ".*,"
7271 let mlen = max(map(copy(keys(s:optionsDict)), "len(v:val)"))
7273 echo "Local buffer variables:"
7275 for key in keys(s:optionsDict)
7277 for s in range(mlen-len(key)+1)
7280 if "b:".key =~ pattern
7281 " if patn != '' && "b:".key !~ patn
7282 echo "b:".key.space.getbufvar(bufnr(""), key)
7287 " Show some global options
7289 echo "Global variables (defined in ".s:file."):"
7290 let saved_loclist = getloclist(0)
7291 execute "lvimgrep /^\\s*let\\s\\+g:/j " . fnameescape(s:file)
7292 let global_vars = getloclist(0)
7293 call setloclist(0, saved_loclist)
7296 for var in global_vars
7297 let var_name = matchstr(var['text'], '^\s*let\s\+\zsg:\S*\ze\s*=')
7299 call add(var_list, var_name)
7303 " Filter only matching variables that exists!
7304 call filter(var_list, 'count(var_list, v:val) == 1 && exists(v:val)')
7305 let mlen = max(map(copy(var_list), "len(v:val)"))
7306 for var_name in var_list
7308 for s in range(mlen-len(var_name)+1)
7311 if var_name =~ pattern && var_name !~ '_command\|_amsfonts\|ams_negations\|tikz_\|keywords'
7312 " if patn != '' && var_name !~ patn
7313 echo var_name.space.string({var_name})
7320 command! -buffer -bang -nargs=* ShowOptions :call <SID>ShowOptions(<q-bang>, <q-args>)
7323 " Debug Mode Variables:
7325 let t:atp_DebugMode = g:atp_DefaultDebugMode
7326 " there are three possible values of t:atp_DebugMode
7327 " silent/normal/debug
7328 let t:atp_QuickFixOpen = 0
7331 augroup ATP_DebugMode
7332 au FileType *.tex let t:atp_DebugMode = g:atp_DefaultDebugMode
7333 " When opening the quickfix error buffer:
7334 au FileType qf let t:atp_QuickFixOpen=1
7335 " When closing the quickfix error buffer (:close, :q) also end the Debug Mode.
7336 au FileType qf au BufUnload <buffer> let t:atp_DebugMode = g:atp_DefaultDebugMode | let t:atp_QuickFixOpen = 0
7337 au FileType qf setl nospell
7344 if !exists("g:atp_keymaps")
7345 let g:atp_keymaps = {
7346 \ 'british' : 'ignore', 'english' : 'ignore',
7347 \ 'USenglish' : 'ignore', 'UKenglish' : 'ignore',
7348 \ 'american' : 'ignore',
7349 \ 'bulgarian' : 'bulgarian-bds', 'croatian' : 'croatian',
7350 \ 'czech' : 'czech', 'greek' : 'greek',
7351 \ 'plutonikogreek': 'greek', 'hebrew' : 'hebrew',
7352 \ 'russian' : 'russian-jcuken', 'serbian' : 'serbian',
7353 \ 'slovak' : 'slovak', 'ukrainian' : 'ukrainian-jcuken',
7354 \ 'polish' : 'polish-slash' }
7355 else "extend the existing dictionary with default values not ovverriding what is defind:
7356 for lang in [ 'croatian', 'czech', 'greek', 'hebrew', 'serbian', 'slovak' ]
7357 call extend(g:atp_keymaps, { lang : lang }, 'keep')
7359 call extend(g:atp_keymaps, { 'british' : 'ignore' }, 'keep')
7360 call extend(g:atp_keymaps, { 'american' : 'ignore' }, 'keep')
7361 call extend(g:atp_keymaps, { 'english' : 'ignore' }, 'keep')
7362 call extend(g:atp_keymaps, { 'UKenglish' : 'ignore' }, 'keep')
7363 call extend(g:atp_keymaps, { 'USenglish' : 'ignore' }, 'keep')
7364 call extend(g:atp_keymaps, { 'bulgarian' : 'bulgarian-bds' }, 'keep')
7365 call extend(g:atp_keymaps, { 'plutonikogreek' : 'greek' }, 'keep')
7366 call extend(g:atp_keymaps, { 'russian' : 'russian-jcuken' }, 'keep')
7367 call extend(g:atp_keymaps, { 'ukrainian' : 'ukrainian-jcuken' }, 'keep')
7371 function! <SID>Babel()
7372 " Todo: make notification.
7373 if &filetype != "tex" || !exists("b:atp_MainFile") || !has("keymap")
7374 " This only works for LaTeX documents.
7375 " but it might work for plain tex documents as well!
7378 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
7380 let saved_loclist = getloclist(0)
7382 execute '1lvimgrep /\\usepackage.*{babel}/j ' . atp_MainFile
7383 " Find \usepackage[babel_options]{babel} - this is the only way that one can
7384 " pass options to babel.
7390 let babel_line = get(get(getloclist(0), 0, {}), 'text', '')
7391 call setloclist(0, saved_loclist)
7392 let languages = split(matchstr(babel_line, '\[\zs[^]]*\ze\]'), ',')
7393 if len(languages) == 0
7396 let default_language = get(languages, '-1', '')
7398 echomsg "Babel : defualt language:" . default_language
7400 let keymap = get(g:atp_keymaps, default_language, '')
7404 echoerr "No keymap in g:atp_keymaps.\n" . babel_line
7409 if keymap != 'ignore'
7410 execute "set keymap=" . keymap
7412 execute "set keymap="
7415 command! -buffer Babel :call <SID>Babel()
7422 " These are two functions which sets options for Xpdf and Xdvi.
7424 " xdvi - supports forward and reverse searching
7428 " Remove menu entries
7429 let Compiler = get(g:CompilerMsg_Dict, matchstr(b:atp_TexCompiler, '^\s*\S*'), 'Compiler')
7430 let Viewer = get(g:ViewerMsg_Dict, matchstr(b:atp_Viewer, '^\s*\S*'), 'View\ Output')
7432 execute "unmenu LaTeX.".Compiler
7433 execute "unmenu LaTeX.".Compiler."\\ debug"
7434 execute "unmenu LaTeX.".Compiler."\\ twice"
7435 execute "unmenu LaTeX.View\\ with\\ ".Viewer
7440 let b:atp_TexCompiler = "latex "
7441 let b:atp_TexOptions = " -src-specials "
7442 let b:atp_Viewer="xdvi " . " -editor '" . v:progname . " --servername " . v:servername . " --remote-wait +%l %f'"
7443 " Set Reverse Search Function.
7444 if !exists("*RevSearch")
7445 function! RevSearch()
7446 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
7447 let dvi_file = fnameescape(fnamemodify(atp_MainFile,":p:r") . ".dvi")
7448 if !filereadable(dvi_file)
7449 echomsg "dvi file doesn't exist"
7450 ViewOutput RevSearch
7454 let options = (exists("g:atp_xdviOptions") ? g:atp_xdviOptions : "" ) . getbufvar(bufnr(""), "atp_xdviOptions")
7455 let g:options = options
7457 let b:xdvi_reverse_search="xdvi " . options .
7458 \ " -editor '" . v:progname . " --servername " . v:servername .
7459 \ " --remote-wait +%l %f' -sourceposition " .
7460 \ line(".") . ":" . col(".") . fnameescape(fnamemodify(expand("%"),":p")) .
7462 call system(b:xdvi_reverse_search)
7465 " Set Reverse Search Command and Map.
7466 command! -buffer RevSearch :call RevSearch()
7467 map <buffer> <LocalLeader>rs :call RevSearch()<CR>
7469 nmenu 550.65 &LaTeX.Reverse\ Search<Tab>:map\ <LocalLeader>rs :RevSearch<CR>
7473 " Put new menu entries:
7474 let Compiler = get(g:CompilerMsg_Dict, matchstr(b:atp_TexCompiler, '^\s*\zs\S*'), 'Compile')
7475 let Viewer = get(g:ViewerMsg_Dict, matchstr(b:atp_Viewer, '^\s*\zs\S*'), "View\\ Output")
7476 execute "nmenu 550.5 &LaTeX.&".Compiler."<Tab>:TEX :TEX<CR>"
7477 execute "nmenu 550.6 &LaTeX.".Compiler."\\ debug<Tab>:TEX\\ debug :DTEX<CR>"
7478 execute "nmenu 550.7 &LaTeX.".Compiler."\\ &twice<Tab>:2TEX :2TEX<CR>"
7479 execute "nmenu 550.10 LaTeX.&View\\ with\\ ".Viewer."<Tab>:ViewOutput :ViewOutput<CR>"
7481 command! -buffer SetXdvi :call SetXdvi()
7482 nnoremap <silent> <buffer> <Plug>SetXdvi :call SetXdvi()<CR>
7485 " xpdf - supports server option (we use the reoding mechanism, which allows to
7486 " copy the output file but not reload the viewer if there were errors during
7487 " compilation (b:atp_ReloadOnError variable)
7491 " Remove menu entries.
7492 let Compiler = get(g:CompilerMsg_Dict, matchstr(b:atp_TexCompiler, '^\s*\S*'), 'Compiler')
7493 let Viewer = get(g:ViewerMsg_Dict, matchstr(b:atp_Viewer, '^\s*\S*'), 'View\ Output')
7495 execute "unmenu LaTeX.".Compiler
7496 execute "unmenu LaTeX.".Compiler."\\ debug"
7497 execute "unmenu LaTeX.".Compiler."\\ twice"
7498 execute "unmenu LaTeX.View\\ with\\ ".Viewer
7502 let b:atp_TexCompiler = "pdflatex"
7503 " We have to clear tex options (for example -src-specials set by :SetXdvi)
7504 let b:atp_TexOptions = ""
7505 let b:atp_Viewer = "xpdf"
7506 " Remove the maps \rs.
7507 if hasmapto("RevSearch()",'n')
7508 unmap <buffer> <LocalLeader>rs
7511 if exists("RevSearch")
7512 delcommand RevSearch
7514 " Delete menu entry.
7516 silent aunmenu LaTeX.Reverse\ Search
7520 " Put new menu entries:
7521 let Compiler = get(g:CompilerMsg_Dict, matchstr(b:atp_TexCompiler, '^\s*\zs\S*'), 'Compile')
7522 let Viewer = get(g:ViewerMsg_Dict, matchstr(b:atp_Viewer, '^\s*\zs\S*'), 'View\ Output')
7523 execute "nmenu 550.5 &LaTeX.&".Compiler. "<Tab>:TEX :TEX<CR>"
7524 execute "nmenu 550.6 &LaTeX." .Compiler. "\\ debug<Tab>:TEX\\ debug :DTEX<CR>"
7525 execute "nmenu 550.7 &LaTeX." .Compiler. "\\ &twice<Tab>:2TEX :2TEX<CR>"
7526 execute "nmenu 550.10 LaTeX.&View\\ with\\ ".Viewer. "<Tab>:ViewOutput :ViewOutput<CR>"
7528 command! -buffer SetXpdf :call SetXpdf()
7529 nnoremap <silent> <buffer> <Plug>SetXpdf :call SetXpdf()<CR>
7533 " These are functions which toggles some of the options:
7534 "{{{ Toggle Functions
7536 " {{{ ATP_ToggleAuTeX
7537 " command! -buffer -count=1 TEX :call TEX(<count>)
7538 function! ATP_ToggleAuTeX(...)
7539 let on = ( a:0 >=1 ? ( a:1 == 'on' ? 1 : 0 ) : !b:atp_autex )
7542 echo "automatic tex processing is ON"
7543 silent! aunmenu LaTeX.Toggle\ AuTeX\ [off]
7544 silent! aunmenu LaTeX.Toggle\ AuTeX\ [on]
7545 menu 550.75 &LaTeX.&Toggle\ AuTeX\ [on]<Tab>b:atp_autex :<C-U>ToggleAuTeX<CR>
7546 cmenu 550.75 &LaTeX.&Toggle\ AuTeX\ [on]<Tab>b:atp_autex <C-U>ToggleAuTeX<CR>
7547 imenu 550.75 &LaTeX.&Toggle\ AuTeX\ [on]<Tab>b:atp_autex <ESC>:ToggleAuTeX<CR>a
7550 silent! aunmenu LaTeX.Toggle\ AuTeX\ [off]
7551 silent! aunmenu LaTeX.Toggle\ AuTeX\ [on]
7552 menu 550.75 &LaTeX.&Toggle\ AuTeX\ [off]<Tab>b:atp_autex :<C-U>ToggleAuTeX<CR>
7553 cmenu 550.75 &LaTeX.&Toggle\ AuTeX\ [off]<Tab>b:atp_autex <C-U>ToggleAuTeX<CR>
7554 imenu 550.75 &LaTeX.&Toggle\ AuTeX\ [off]<Tab>b:atp_autex <ESC>:ToggleAuTeX<CR>a
7555 echo "automatic tex processing is OFF"
7559 " {{{ ATP_ToggleSpace
7560 " Special Space for Searching
7561 let s:special_space="[off]"
7562 function! ATP_ToggleSpace(...)
7563 let on = ( a:0 >=1 ? ( a:1 == 'on' ? 1 : 0 ) : maparg('<space>','c') == "" )
7565 echomsg "special space is on"
7567 let s:special_space="[on]"
7568 silent! aunmenu LaTeX.Toggle\ Space\ [off]
7569 silent! aunmenu LaTeX.Toggle\ Space\ [on]
7570 menu 550.78 &LaTeX.&Toggle\ Space\ [on]<Tab>cmap\ <space>\ \\_s\\+ :<C-U>ToggleSpace<CR>
7571 cmenu 550.78 &LaTeX.&Toggle\ Space\ [on]<Tab>cmap\ <space>\ \\_s\\+ <C-U>ToggleSpace<CR>
7572 imenu 550.78 &LaTeX.&Toggle\ Space\ [on]<Tab>cmap\ <space>\ \\_s\\+ <Esc>:ToggleSpace<CR>a
7573 tmenu &LaTeX.&Toggle\ Space\ [on] cmap <space> \_s\+ is curently on
7575 echomsg "special space is off"
7577 let s:special_space="[off]"
7578 silent! aunmenu LaTeX.Toggle\ Space\ [on]
7579 silent! aunmenu LaTeX.Toggle\ Space\ [off]
7580 menu 550.78 &LaTeX.&Toggle\ Space\ [off]<Tab>cmap\ <space>\ \\_s\\+ :<C-U>ToggleSpace<CR>
7581 cmenu 550.78 &LaTeX.&Toggle\ Space\ [off]<Tab>cmap\ <space>\ \\_s\\+ <C-U>ToggleSpace<CR>
7582 imenu 550.78 &LaTeX.&Toggle\ Space\ [off]<Tab>cmap\ <space>\ \\_s\\+ <Esc>:ToggleSpace<CR>a
7583 tmenu &LaTeX.&Toggle\ Space\ [off] cmap <space> \_s\+ is curently off
7587 " {{{ ATP_ToggleCheckMathOpened
7588 " This function toggles if ATP is checking if editing a math mode.
7589 " This is used by insert completion.
7591 function! ATP_ToggleCheckMathOpened(...)
7592 let on = ( a:0 >=1 ? ( a:1 == 'on' ? 1 : 0 ) : !g:atp_MathOpened )
7593 " if g:atp_MathOpened
7595 let g:atp_MathOpened = 0
7596 echomsg "check if in math environment is off"
7597 silent! aunmenu LaTeX.Toggle\ Check\ if\ in\ Math\ [on]
7598 silent! aunmenu LaTeX.Toggle\ Check\ if\ in\ Math\ [off]
7599 menu 550.79 &LaTeX.Toggle\ &Check\ if\ in\ Math\ [off]<Tab>g:atp_MathOpened
7600 \ :<C-U>ToggleCheckMathOpened<CR>
7601 cmenu 550.79 &LaTeX.Toggle\ &Check\ if\ in\ Math\ [off]<Tab>g:atp_MathOpened
7602 \ <C-U>ToggleCheckMathOpened<CR>
7603 imenu 550.79 &LaTeX.Toggle\ &Check\ if\ in\ Math\ [off]<Tab>g:atp_MathOpened
7604 \ <Esc>:ToggleCheckMathOpened<CR>a
7606 let g:atp_MathOpened = 1
7607 echomsg "check if in math environment is on"
7608 silent! aunmenu LaTeX.Toggle\ Check\ if\ in\ Math\ [off]
7609 silent! aunmenu LaTeX.Toggle\ Check\ if\ in\ Math\ [off]
7610 menu 550.79 &LaTeX.Toggle\ &Check\ if\ in\ Math\ [on]<Tab>g:atp_MathOpened
7611 \ :<C-U>ToggleCheckMathOpened<CR>
7612 cmenu 550.79 &LaTeX.Toggle\ &Check\ if\ in\ Math\ [on]<Tab>g:atp_MathOpened
7613 \ <C-U>ToggleCheckMathOpened<CR>
7614 imenu 550.79 &LaTeX.Toggle\ &Check\ if\ in\ Math\ [on]<Tab>g:atp_MathOpened
7615 \ <Esc>:ToggleCheckMathOpened<CR>a
7619 " {{{ ATP_ToggleCallBack
7620 function! ATP_ToggleCallBack(...)
7621 let on = ( a:0 >=1 ? ( a:1 == 'on' ? 1 : 0 ) : !g:atp_callback )
7623 let g:atp_callback = 0
7624 echomsg "call back is off"
7625 silent! aunmenu LaTeX.Toggle\ Call\ Back\ [on]
7626 silent! aunmenu LaTeX.Toggle\ Call\ Back\ [off]
7627 menu 550.80 &LaTeX.Toggle\ &Call\ Back\ [off]<Tab>g:atp_callback
7628 \ :<C-U>call ToggleCallBack()<CR>
7629 cmenu 550.80 &LaTeX.Toggle\ &Call\ Back\ [off]<Tab>g:atp_callback
7630 \ <C-U>call ToggleCallBack()<CR>
7631 imenu 550.80 &LaTeX.Toggle\ &Call\ Back\ [off]<Tab>g:atp_callback
7632 \ <Esc>:call ToggleCallBack()<CR>a
7634 let g:atp_callback = 1
7635 echomsg "call back is on"
7636 silent! aunmenu LaTeX.Toggle\ Call\ Back\ [on]
7637 silent! aunmenu LaTeX.Toggle\ Call\ Back\ [off]
7638 menu 550.80 &LaTeX.Toggle\ &Call\ Back\ [on]<Tab>g:atp_callback
7639 \ :call ToggleCallBack()<CR>
7640 cmenu 550.80 &LaTeX.Toggle\ &Call\ Back\ [on]<Tab>g:atp_callback
7641 \ <C-U>call ToggleCallBack()<CR>
7642 imenu 550.80 &LaTeX.Toggle\ &Call\ Back\ [on]<Tab>g:atp_callback
7643 \ <Esc>:call ToggleCallBack()<CR>a
7647 " {{{ ATP_ToggleDebugMode
7649 " TODO: it would be nice to have this command (and the map) in quickflist (FileType qf)
7650 " describe DEBUG MODE in doc properly.
7651 function! ATP_ToggleDebugMode(...)
7652 let on = ( a:0 >=1 ? ( a:1 == 'on' ? 1 : 0 ) : t:atp_DebugMode != "debug" )
7654 echomsg "debug mode is off"
7656 silent! aunmenu 550.20.5 &LaTeX.&Log.Toggle\ &Debug\ Mode\ [on]
7657 silent! aunmenu 550.20.5 &LaTeX.&Log.Toggle\ &Debug\ Mode\ [off]
7658 menu 550.20.5 &LaTeX.&Log.Toggle\ &Debug\ Mode\ [off]<Tab>t:atp_DebugMode
7659 \ :<C-U>ToggleDebugMode<CR>
7660 cmenu 550.20.5 &LaTeX.&Log.Toggle\ &Debug\ Mode\ [off]<Tab>t:atp_DebugMode
7661 \ <C-U>ToggleDebugMode<CR>
7662 imenu 550.20.5 &LaTeX.&Log.Toggle\ &Debug\ Mode\ [off]<Tab>t:atp_DebugMode
7663 \ <Esc>:ToggleDebugMode<CR>a
7665 silent! aunmenu LaTeX.Toggle\ Call\ Back\ [on]
7666 silent! aunmenu LaTeX.Toggle\ Call\ Back\ [off]
7667 menu 550.80 &LaTeX.Toggle\ &Call\ Back\ [off]<Tab>g:atp_callback
7668 \ :<C-U>ToggleDebugMode<CR>
7669 cmenu 550.80 &LaTeX.Toggle\ &Call\ Back\ [off]<Tab>g:atp_callback
7670 \ <C-U>ToggleDebugMode<CR>
7671 imenu 550.80 &LaTeX.Toggle\ &Call\ Back\ [off]<Tab>g:atp_callback
7672 \ <Esc>:ToggleDebugMode<CR>a
7674 let t:atp_DebugMode = g:atp_DefaultDebugMode
7677 echomsg "debug mode is on"
7679 silent! aunmenu 550.20.5 LaTeX.Log.Toggle\ Debug\ Mode\ [off]
7680 silent! aunmenu 550.20.5 &LaTeX.&Log.Toggle\ &Debug\ Mode\ [on]
7681 menu 550.20.5 &LaTeX.&Log.Toggle\ &Debug\ Mode\ [on]<Tab>t:atp_DebugMode
7682 \ :<C-U>ToggleDebugMode<CR>
7683 cmenu 550.20.5 &LaTeX.&Log.Toggle\ &Debug\ Mode\ [on]<Tab>t:atp_DebugMode
7684 \ <C-U>ToggleDebugMode<CR>
7685 imenu 550.20.5 &LaTeX.&Log.Toggle\ &Debug\ Mode\ [on]<Tab>t:atp_DebugMode
7686 \ <Esc>:ToggleDebugMode<CR>a
7688 silent! aunmenu LaTeX.Toggle\ Call\ Back\ [on]
7689 silent! aunmenu LaTeX.Toggle\ Call\ Back\ [off]
7690 menu 550.80 &LaTeX.Toggle\ &Call\ Back\ [on]<Tab>g:atp_callback
7691 \ :<C-U>ToggleDebugMode<CR>
7692 cmenu 550.80 &LaTeX.Toggle\ &Call\ Back\ [on]<Tab>g:atp_callback
7693 \ <C-U>ToggleDebugMode<CR>
7694 imenu 550.80 &LaTeX.Toggle\ &Call\ Back\ [on]<Tab>g:atp_callback
7695 \ <Esc>:ToggleDebugMode<CR>a
7697 let g:atp_callback=1
7698 let t:atp_DebugMode = "debug"
7699 let winnr = bufwinnr("%")
7701 exe winnr . " wincmd w"
7704 augroup ATP_DebugModeCommandsAndMaps
7706 au FileType qf command! -buffer ToggleDebugMode :call <SID>ToggleDebugMode()
7707 au FileType qf nnoremap <silent> <LocalLeader>D :ToggleDebugMode<CR>
7711 " switches on/off the <Tab> map for TabCompletion
7712 function! ATP_ToggleTab(...)
7713 if mapcheck('<F7>','i') !~ 'atplib#TabCompletion'
7714 let on = ( a:0 >=1 ? ( a:1 == 'on' ? 1 : 0 ) : mapcheck('<Tab>','i') !~# 'atplib#TabCompletion' )
7716 iunmap <buffer> <Tab>
7717 echo '<Tab> map turned off'
7719 imap <buffer> <Tab> <C-R>=atplib#TabCompletion(1)<CR>
7720 echo '<Tab> map turned on'
7727 " Commands And Maps:
7728 command! -buffer -nargs=? -complete=customlist,atplib#OnOffComp ToggleAuTeX :call ATP_ToggleAuTeX(<f-args>)
7729 nnoremap <silent> <buffer> <Plug>ToggleAuTeX :call ATP_ToggleAuTeX()<CR>
7731 command! -buffer -nargs=? -complete=customlist,atplib#OnOffComp ToggleSpace :call ATP_ToggleSpace(<f-args>)
7732 nnoremap <silent> <buffer> <Plug>ToggleSpace :call ATP_ToggleSpace()<CR>
7734 command! -buffer -nargs=? -complete=customlist,atplib#OnOffComp ToggleCheckMathOpened :call ATP_ToggleCheckMathOpened(<f-args>)
7735 nnoremap <silent> <buffer> <Plug>ToggleCheckMathOpened :call ATP_ToggleCheckMathOpened()<CR>
7737 command! -buffer -nargs=? -complete=customlist,atplib#OnOffComp ToggleCallBack :call ATP_ToggleCallBack(<f-args>)
7738 nnoremap <silent> <buffer> <Plug>ToggleCallBack :call ATP_ToggleCallBack()<CR>
7740 command! -buffer -nargs=? -complete=customlist,atplib#OnOffComp ToggleDebugMode :call ATP_ToggleDebugMode(<f-args>)
7741 nnoremap <silent> <buffer> <Plug>ToggleDebugMode :call ATP_ToggleDebugMode()<CR>
7743 command! -buffer -nargs=? -complete=customlist,atplib#OnOffComp ToggleTab :call ATP_ToggleTab(<f-args>)
7744 nnoremap <silent> <buffer> <Plug>ToggleTab :call ATP_ToggleTab()<CR>
7745 inoremap <silent> <buffer> <Plug>ToggleTab <Esc>:call ATP_ToggleTab()<CR>
7748 " Tab Completion Variables:
7749 " {{{ TAB COMPLETION variables
7750 " ( functions are in autoload/atplib.vim )
7753 let g:atp_completion_modes=[
7754 \ 'commands', 'labels',
7755 \ 'tikz libraries', 'environment names',
7756 \ 'close environments' , 'brackets',
7757 \ 'input files', 'bibstyles',
7758 \ 'bibitems', 'bibfiles',
7759 \ 'documentclass', 'tikzpicture commands',
7760 \ 'tikzpicture', 'tikzpicture keywords',
7761 \ 'package names', 'font encoding',
7762 \ 'font family', 'font series',
7763 \ 'font shape', 'algorithmic' ]
7764 lockvar 2 g:atp_completion_modes
7768 if !exists("g:atp_completion_modes_normal_mode")
7769 let g:atp_completion_modes_normal_mode=[
7770 \ 'close environments' , 'brackets', 'algorithmic' ]
7771 lockvar g:atp_completion_modes_normal_mode
7774 " By defualt all completion modes are ative.
7775 if !exists("g:atp_completion_active_modes")
7776 let g:atp_completion_active_modes=deepcopy(g:atp_completion_modes)
7778 if !exists("g:atp_completion_active_modes_normal_mode")
7779 let g:atp_completion_active_modes_normal_mode=deepcopy(g:atp_completion_modes_normal_mode)
7782 if !exists("g:atp_sort_completion_list")
7783 let g:atp_sort_completion_list = 12
7786 " Note: to remove completions: 'inline_math' or 'displayed_math' one has to
7787 " remove also: 'close_environments' /the function atplib#CloseLastEnvironment can
7788 " close math instead of an environment/.
7790 " ToDo: make list of complition commands from the input files.
7791 " ToDo: make complition fot \cite, and for \ref and \eqref commands.
7793 " ToDo: there is second such a list! line 3150
7794 let g:atp_Environments=['array', 'abstract', 'center', 'corollary',
7795 \ 'definition', 'document', 'description', 'displaymath',
7796 \ 'enumerate', 'example', 'eqnarray',
7797 \ 'flushright', 'flushleft', 'figure', 'frontmatter',
7799 \ 'itemize', 'lemma', 'list', 'notation', 'minipage',
7800 \ 'proof', 'proposition', 'picture', 'theorem', 'tikzpicture',
7801 \ 'tabular', 'table', 'tabbing', 'thebibliography', 'titlepage',
7802 \ 'quotation', 'quote',
7803 \ 'remark', 'verbatim', 'verse' ]
7805 let g:atp_amsmath_environments=['align', 'alignat', 'equation', 'gather',
7806 \ 'multline', 'split', 'substack', 'flalign', 'smallmatrix', 'subeqations',
7807 \ 'pmatrix', 'bmatrix', 'Bmatrix', 'vmatrix' ]
7809 " if short name is no_short_name or '' then both means to do not put
7810 " anything, also if there is no key it will not get a short name.
7811 let g:atp_shortname_dict = { 'theorem' : 'thm',
7812 \ 'proposition' : 'prop', 'definition' : 'defi',
7813 \ 'lemma' : 'lem', 'array' : 'ar',
7814 \ 'abstract' : 'no_short_name',
7815 \ 'tikzpicture' : 'tikz', 'tabular' : 'table',
7816 \ 'table' : 'table', 'proof' : 'pr',
7817 \ 'corollary' : 'cor', 'enumerate' : 'enum',
7818 \ 'example' : 'ex', 'itemize' : 'it',
7819 \ 'item' : 'itm', 'algorithmic' : 'alg',
7820 \ 'algorithm' : 'alg',
7821 \ 'remark' : 'rem', 'notation' : 'not',
7822 \ 'center' : '', 'flushright' : '',
7823 \ 'flushleft' : '', 'quotation' : 'quot',
7824 \ 'quot' : 'quot', 'tabbing' : '',
7825 \ 'picture' : 'pic', 'minipage' : '',
7826 \ 'list' : 'list', 'figure' : 'fig',
7827 \ 'verbatim' : 'verb', 'verse' : 'verse',
7828 \ 'thebibliography' : '', 'document' : 'no_short_name',
7829 \ 'titlepave' : '', 'align' : 'eq',
7830 \ 'alignat' : 'eq', 'equation' : 'eq',
7831 \ 'gather' : 'eq', 'multline' : 'eq',
7832 \ 'split' : 'eq', 'substack' : '',
7833 \ 'flalign' : 'eq', 'displaymath' : 'eq',
7834 \ 'part' : 'prt', 'chapter' : 'chap',
7835 \ 'section' : 'sec', 'subsection' : 'ssec',
7836 \ 'subsubsection' : 'sssec', 'paragraph' : 'par',
7837 \ 'subparagraph' : 'spar', 'subequations' : 'eq' }
7840 " Usage: \label{l:shorn_env_name . g:atp_separator
7841 if !exists("g:atp_separator")
7842 let g:atp_separator=':'
7844 if !exists("g:atp_no_separator")
7845 let g:atp_no_separator = 0
7847 if !exists("g:atp_no_short_names")
7848 let g:atp_env_short_names = 1
7850 " the separator will not be put after the environments in this list:
7851 " the empty string is on purpose: to not put separator when there is
7853 let g:atp_no_separator_list=['', 'titlepage']
7855 " let g:atp_package_list=sort(['amsmath', 'amssymb', 'amsthm', 'amstex',
7856 " \ 'babel', 'booktabs', 'bookman', 'color', 'colorx', 'chancery', 'charter', 'courier',
7857 " \ 'enumerate', 'euro', 'fancyhdr', 'fancyheadings', 'fontinst',
7858 " \ 'geometry', 'graphicx', 'graphics',
7859 " \ 'hyperref', 'helvet', 'layout', 'longtable',
7860 " \ 'newcent', 'nicefrac', 'ntheorem', 'palatino', 'stmaryrd', 'showkeys', 'tikz',
7861 " \ 'qpalatin', 'qbookman', 'qcourier', 'qswiss', 'qtimes', 'verbatim', 'wasysym'])
7863 " the command \label is added at the end.
7864 let g:atp_Commands=["\\begin{", "\\end{",
7865 \ "\\cite{", "\\nocite{", "\\ref{", "\\pageref{", "\\eqref{", "\\item",
7866 \ "\\emph{", "\\documentclass{", "\\usepackage{",
7867 \ "\\section{", "\\subsection{", "\\subsubsection{", "\\part{",
7868 \ "\\chapter{", "\\appendix", "\\subparagraph", "\\paragraph",
7869 \ "\\textbf{", "\\textsf{", "\\textrm{", "\\textit{", "\\texttt{",
7870 \ "\\textsc{", "\\textsl{", "\\textup{", "\\textnormal", "\\textcolor{",
7871 \ "\\bfseries", "\\mdseries", "\\bigskip", "\\bibitem",
7872 \ "\\tiny", "\\scriptsize", "\\footnotesize", "\\small",
7873 \ "\\noindent", "\\normalfont", "\normalsize", "\\normalsize", "\\normal",
7874 \ "\\large", "\\Large", "\\LARGE", "\\huge", "\\HUGE",
7875 \ "\\usefont{", "\\fontsize{", "\\selectfont", "\\fontencoding{", "\\fontfamiliy{", "\\fontseries{", "\\fontshape{",
7876 \ "\\rmdefault", "\\sfdefault", "\\ttdefault", "\\bfdefault", "\\mddefault", "\\itdefault",
7877 \ "\\sldefault", "\\scdefault", "\\updefault", "\\renewcommand{", "\\newcommand{",
7878 \ "\\addcontentsline{", "\\addtocontents",
7879 \ "\\input", "\\include", "\\includeonly", "\\includegraphics",
7880 \ "\\savebox", "\\sbox", "\\usebox", "\\rule", "\\raisebox{",
7881 \ "\\parbox{", "\\mbox{", "\\makebox{", "\\framebox{", "\\fbox{",
7882 \ "\\medskip", "\\smallskip", "\\vskip", "\\vfil", "\\vfill", "\\vspace{",
7883 \ "\\hspace", "\\hrulefill", "\hfil", "\\hfill", "\\dotfill",
7884 \ "\\thispagestyle", "\\mathnormal", "\\markright", "\\pagestyle", "\\pagenumbering",
7885 \ "\\author{", "\\date{", "\\thanks{", "\\title{",
7886 \ "\\maketitle", "\\overline", "\\underline",
7887 \ "\\marginpar", "\\indent", "\\par", "\\sloppy", "\\pagebreak", "\\nopagebreak",
7888 \ "\\newpage", "\\newline", "\\newtheorem{", "\\linebreak", "\\line", "\\hyphenation{", "\\fussy",
7889 \ "\\enlagrethispage{", "\\clearpage", "\\cleardoublepage",
7891 \ "\\opening{", "\\name{", "\\makelabels{", "\\location{", "\\closing{", "\\address{",
7892 \ "\\signature{", "\\stopbreaks", "\\startbreaks",
7893 \ "\\newcounter{", "\\refstepcounter{",
7894 \ "\\roman{", "\\Roman{", "\\stepcounter{", "\\setcounter{",
7895 \ "\\usecounter{", "\\value{",
7896 \ "\\newlength{", "\\setlength{", "\\addtolength{", "\\settodepth{",
7897 \ "\\settoheight{", "\\settowidth{",
7898 \ "\\width", "\\height", "\\depth", "\\totalheight",
7899 \ "\\footnote{", "\\footnotemark", "\\footnotetetext",
7900 \ "\\bibliography{", "\\bibliographystyle{",
7901 \ "\\flushbottom", "\\onecolumn", "\\raggedbottom", "\\twocolumn",
7902 \ "\\alph{", "\\Alph{", "\\arabic{", "\\fnsymbol{", "\\reversemarginpar",
7903 \ "\\exhyphenpenalty",
7904 \ "\\topmargin", "\\oddsidemargin", "\\evensidemargin", "\\headheight", "\\headsep",
7905 \ "\\textwidth", "\\textheight", "\\marginparwidth", "\\marginparsep", "\\marginparpush", "\\footskip", "\\hoffset",
7906 \ "\\voffset", "\\paperwidth", "\\paperheight", "\\theequation", "\\thepage", "\\usetikzlibrary{",
7907 \ "\\tableofcontents", "\\newfont{", "\\phantom",
7908 \ "\\DeclareRobustCommand", "\\show", "\\CheckCommand", "\\mathnormal",
7909 \ "\\pounds", "\\magstep{" ]
7911 let g:atp_picture_commands=[ "\\put", "\\circle", "\\dashbox", "\\frame{",
7912 \"\\framebox(", "\\line(", "\\linethickness{",
7913 \ "\\makebox(", "\\\multiput(", "\\oval(", "\\put",
7914 \ "\\shortstack", "\\vector(" ]
7916 " ToDo: end writting layout commands.
7917 " ToDo: MAKE COMMANDS FOR PREAMBULE.
7919 let g:atp_math_commands=["\\forall", "\\exists", "\\emptyset", "\\aleph", "\\partial",
7920 \ "\\nabla", "\\Box", "\\bot", "\\top", "\\flat", "\\sharp", "\\natural",
7921 \ "\\mathbf{", "\\mathsf{", "\\mathrm{", "\\mathit{", "\\mathtt{", "\\mathcal{",
7922 \ "\\mathop{", "\\mathversion", "\\limits", "\\text{", "\\leqslant", "\\leq", "\\geqslant", "\\geq",
7923 \ "\\gtrsim", "\\lesssim", "\\gtrless", "\\left", "\\right",
7924 \ "\\rightarrow", "\\Rightarrow", "\\leftarrow", "\\Leftarrow", "\\iff",
7925 \ "\\oplus", "\\otimes", "\\odot", "\\oint",
7926 \ "\\leftrightarrow", "\\Leftrightarrow", "\\downarrow", "\\Downarrow",
7927 \ "\\overbrace{", "\\underbrace{","\\Uparrow",
7928 \ "\\Longrightarrow", "\\longrightarrow", "\\Longleftarrow", "\\longleftarrow",
7929 \ "\\overrightarrow{", "\\overleftarrow{", "\\underrightarrow{", "\\underleftarrow{",
7930 \ "\\uparrow", "\\nearrow", "\\searrow", "\\swarrow", "\\nwarrow", "\\mapsto", "\\longmapsto",
7931 \ "\\hookrightarrow", "\\hookleftarrow", "\\gets", "\\to", "\\backslash",
7932 \ "\\sum", "\\bigsum", "\\cup", "\\bigcup", "\\cap", "\\bigcap",
7933 \ "\\prod", "\\coprod", "\\bigvee", "\\bigwedge", "\\wedge",
7934 \ "\\int", "\\bigoplus", "\\bigotimes", "\\bigodot", "\\times",
7935 \ "\\smile", "\\frown", "\\subset", "\\subseteq", "\\supset", "\\supseteq",
7936 \ "\\dashv", "\\vdash", "\\vDash", "\\Vdash", "\\models", "\\sim", "\\simeq",
7937 \ "\\prec", "\\preceq", "\\preccurlyeq", "\\precapprox", "\\mid",
7938 \ "\\succ", "\\succeq", "\\succcurlyeq", "\\succapprox", "\\approx",
7939 \ "\\thickapprox", "\\cong", "\\bullet",
7940 \ "\\lhd", "\\unlhd", "\\rhd", "\\unrhd", "\\dagger", "\\ddager", "\\dag", "\\ddag",
7941 \ "\\ldots", "\\cdots", "\\vdots", "\\ddots",
7942 \ "\\vartriangleright", "\\vartriangleleft", "\\trianglerighteq", "\\trianglelefteq",
7943 \ "\\copyright", "\\textregistered", "\\puonds",
7944 \ "\\big", "\\Big", "\\Bigg", "\\huge",
7945 \ "\\bigr", "\\Bigr", "\\biggr", "\\Biggr",
7946 \ "\\bigl", "\\Bigl", "\\biggl", "\\Biggl",
7947 \ "\\hat", "\\grave", "\\bar", "\\acute", "\\mathring", "\\check",
7948 \ "\\dots", "\\dot", "\\vec", "\\breve",
7949 \ "\\tilde", "\\widetilde" , "\\widehat", "\\ddot",
7950 \ "\\sqrt", "\\frac", "\\binom{", "\\cline", "\\vline", "\\hline", "\\multicolumn{",
7951 \ "\\nouppercase", "\\sqsubseteq", "\\sqsubset", "\\sqsupseteq", "\\sqsupset",
7952 \ "\\square", "\\blacksquare", "\\triangledown", "\\triangle",
7953 \ "\\diagdown", "\\diagup", "\\nexists", "\\varnothing", "\\Bbbk", "\\circledS",
7954 \ "\\complement", "\\hslash", "\\hbar",
7955 \ "\\eth", "\\rightrightarrows", "\\leftleftarrows", "\\rightleftarrows", "\\leftrighrarrows",
7956 \ "\\downdownarrows", "\\upuparrows", "\\rightarrowtail", "\\leftarrowtail",
7957 \ "\\rightharpoondown", "\\rightharpoonup", "\\rightleftharpoons", "\\leftharpoondown", "\\leftharpoonup",
7958 \ "\\twoheadrightarrow", "\\twoheadleftarrow", "\\rceil", "\\lceil", "\\rfloor", "\\lfloor",
7959 \ "\\bigtriangledown", "\\bigtriangleup", "\\ominus", "\\bigcirc", "\\amalg", "\\asymp",
7960 \ "\\vert", "\\Arrowvert", "\\arrowvert", "\\bracevert", "\\lmoustache", "\\rmoustache",
7961 \ "\\setminus", "\\sqcup", "\\sqcap", "\\bowtie", "\\owns", "\\oslash",
7962 \ "\\lnot", "\\notin", "\\neq", "\\smile", "\\frown", "\\equiv", "\\perp",
7963 \ "\\quad", "\\qquad", "\\stackrel", "\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle",
7964 \ "\\langle", "\\rangle", "\\Diamond", "\\lgroup", "\\rgroup", "\\propto", "\\Join", "\\div",
7965 \ "\\land", "\\star", "\\uplus", "\\leadsto", "\\rbrack", "\\lbrack", "\\mho",
7966 \ "\\diamondsuit", "\\heartsuit", "\\clubsuit", "\\spadesuit", "\\top", "\\ell",
7967 \ "\\imath", "\\jmath", "\\wp", "\\Im", "\\Re", "\\prime", "\\ll", "\\gg" ]
7969 " commands defined by the user in input files.
7971 " ToDo: this doesn't work with input files well enough.
7973 " Returns a list of two lists: [ commanad_names, enironment_names ]
7975 " The BufEnter augroup doesn't work with EditInputFile, but at least it works
7976 " when entering. Debuging shows that when entering new buffer it uses
7977 " wrong b:atp_MainFile, it is still equal to the bufername and not the
7978 " real main file. Maybe it is better to use s:mainfile variable.
7980 if !exists("g:atp_local_completion")
7981 let g:atp_local_completion = 1
7985 let g:atp_math_commands_non_expert_mode=[ "\\leqq", "\\geqq", "\\succeqq", "\\preceqq",
7986 \ "\\subseteqq", "\\supseteqq", "\\gtrapprox", "\\lessapprox" ]
7988 " requiers amssymb package:
7989 let g:atp_ams_negations=[ "\\nless", "\\ngtr", "\\lneq", "\\gneq", "\\nleq", "\\ngeq", "\\nleqslant", "\\ngeqslant",
7990 \ "\\nsim", "\\nconq", "\\nvdash", "\\nvDash",
7991 \ "\\nsubseteq", "\\nsupseteq",
7992 \ "\\varsubsetneq", "\\subsetneq", "\\varsupsetneq", "\\supsetneq",
7993 \ "\\ntriangleright", "\\ntriangleleft", "\\ntrianglerighteq", "\\ntrianglelefteq",
7994 \ "\\nrightarrow", "\\nleftarrow", "\\nRightarrow", "\\nLeftarrow",
7995 \ "\\nleftrightarrow", "\\nLeftrightarrow", "\\nsucc", "\\nprec", "\\npreceq", "\\nsucceq",
7996 \ "\\precneq", "\\succneq", "\\precnapprox", "\\ltimes", "\\rtimes" ]
7998 let g:atp_ams_negations_non_expert_mode=[ "\\lneqq", "\\ngeqq", "\\nleqq", "\\ngeqq", "\\nsubseteqq",
7999 \ "\\nsupseteqq", "\\subsetneqq", "\\supsetneqq", "\\nsucceqq", "\\precneqq", "\\succneqq" ]
8001 " ToDo: add more amsmath commands.
8002 let g:atp_amsmath_commands=[ "\\boxed", "\\intertext", "\\multiligngap", "\\shoveleft", "\\shoveright", "\\notag", "\\tag",
8003 \ "\\notag", "\\raistag{", "\\displaybreak", "\\allowdisplaybreaks", "\\numberwithin{",
8004 \ "\\hdotsfor{" , "\\mspace{",
8005 \ "\\negthinspace", "\\negmedspace", "\\negthickspace", "\\thinspace", "\\medspace", "\\thickspace",
8006 \ "\\leftroot{", "\\uproot{", "\\overset{", "\\underset{", "\\sideset{",
8007 \ "\\dfrac", "\\tfrac", "\\cfrac", "\\dbinom{", "\\tbinom{", "\\smash",
8008 \ "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\DeclareMatchOperator{",
8009 \ "\\arccos", "\\arcsin", "\\arg", "\\cos", "\\cosh", "\\cot", "\\coth", "\\csc", "\\deg", "\\det",
8010 \ "\\dim", "\\exp", "\\gcd", "\\hom", "\\inf", "\\injlim", "\\ker", "\\lg", "\\lim", "\\liminf", "\\limsup",
8011 \ "\\log", "\\min", "\\max", "\\Pr", "\\projlim", "\\sec", "\\sin", "\\sinh", "\\sup", "\\tan", "\\tanh",
8012 \ "\\varlimsup", "\\varliminf", "\\varinjlim", "\\varprojlim", "\\mod", "\\bmod", "\\pmod", "\\pod", "\\sideset",
8013 \ "\\iint", "\\iiint", "\\iiiint", "\\idotsint", "\\tag",
8014 \ "\\varGamma", "\\varDelta", "\\varTheta", "\\varLambda", "\\varXi", "\\varPi", "\\varSigma",
8015 \ "\\varUpsilon", "\\varPhi", "\\varPsi", "\\varOmega" ]
8017 " ToDo: integrate in TabCompletion (amsfonts, euscript packages).
8018 let g:atp_amsfonts=[ "\\mathbb{", "\\mathfrak{", "\\mathscr{" ]
8020 " not yet supported: in TabCompletion:
8021 let g:atp_amsextra_commands=[ "\\sphat", "\\sptilde" ]
8022 let g:atp_fancyhdr_commands=["\\lfoot{", "\\rfoot{", "\\rhead{", "\\lhead{",
8023 \ "\\cfoot{", "\\chead{", "\\fancyhead{", "\\fancyfoot{",
8024 \ "\\fancypagestyle{", "\\fancyhf{}", "\\headrulewidth", "\\footrulewidth",
8025 \ "\\rightmark", "\\leftmark", "\\markboth",
8026 \ "\\chaptermark", "\\sectionmark", "\\subsectionmark",
8027 \ "\\fancyheadoffset", "\\fancyfootoffset", "\\fancyhfoffset"]
8029 let g:atp_makeidx_commands=[ "\\makeindex", "\\index{", "\\printindex" ]
8032 " ToDo: remove tikzpicture from above and integrate the
8033 " tikz_envirnoments variable
8034 " \begin{pgfonlayer}{background} (complete the second argument as
8037 " Tikz command cuold be accitve only in tikzpicture and after \tikz
8038 " command! There is a way to do that.
8040 let g:atp_tikz_environments=['tikzpicture', 'scope', 'pgfonlayer', 'background' ]
8041 " ToDo: this should be completed as packages.
8042 let g:atp_tikz_libraries=sort(['arrows', 'automata', 'backgrounds', 'calc', 'calendar', 'chains', 'decorations',
8043 \ 'decorations.footprints', 'decorations.fractals',
8044 \ 'decorations.markings', 'decorations.pathmorphing',
8045 \ 'decorations.replacing', 'decorations.shapes',
8046 \ 'decorations.text', 'er', 'fadings', 'fit',
8047 \ 'folding', 'matrix', 'mindmap', 'scopes',
8048 \ 'patterns', 'pteri', 'plothandlers', 'plotmarks',
8049 \ 'plcaments', 'pgflibrarypatterns', 'pgflibraryshapes',
8050 \ 'pgflibraryplotmarks', 'positioning', 'replacements',
8051 \ 'shadows', 'shapes.arrows', 'shapes.callout', 'shapes.geometric',
8052 \ 'shapes.gates.logic.IEC', 'shapes.gates.logic.US', 'shapes.misc',
8053 \ 'shapes.multipart', 'shapes.symbols', 'topaths', 'through', 'trees' ])
8054 " tikz keywords = begin without '\'!
8055 " ToDo: add mote keywords: done until page 145.
8056 " ToDo: put them in a correct order!!!
8057 " ToDo: completion for arguments in brackets [] for tikz commands.
8058 let g:atp_tikz_commands=[ "\\begin", "\\end", "\\matrix", "\\node", "\\shadedraw",
8059 \ "\\draw", "\\tikz", "\\tikzset",
8060 \ "\\path", "\\filldraw", "\\fill", "\\clip", "\\drawclip", "\\foreach", "\\angle", "\\coordinate",
8061 \ "\\useasboundingbox", "\\tikztostart", "\\tikztotarget", "\\tikztonodes", "\\tikzlastnode",
8062 \ "\\pgfextra", "\\endpgfextra", "\\verb", "\\coordinate",
8063 \ "\\pattern", "\\shade", "\\shadedraw", "\\colorlet", "\\definecolor" ]
8064 let g:atp_tikz_keywords=[ 'draw', 'node', 'matrix', 'anchor', 'top', 'bottom',
8065 \ 'west', 'east', 'north', 'south', 'at', 'thin', 'thick', 'semithick', 'rounded', 'corners',
8066 \ 'controls', 'and', 'circle', 'step', 'grid', 'very', 'style', 'line', 'help',
8067 \ 'color', 'arc', 'curve', 'scale', 'parabola', 'line', 'ellipse', 'bend', 'sin', 'rectangle', 'ultra',
8068 \ 'right', 'left', 'intersection', 'xshift', 'yshift', 'shift', 'near', 'start', 'above', 'below',
8069 \ 'end', 'sloped', 'coordinate', 'cap', 'shape', 'label', 'every',
8070 \ 'edge', 'point', 'loop', 'join', 'distance', 'sharp', 'rotate', 'blue', 'red', 'green', 'yellow',
8071 \ 'black', 'white', 'gray',
8072 \ 'text', 'width', 'inner', 'sep', 'baseline', 'current', 'bounding', 'box',
8073 \ 'canvas', 'polar', 'radius', 'barycentric', 'angle', 'opacity',
8074 \ 'solid', 'phase', 'loosly', 'dashed', 'dotted' , 'densly',
8075 \ 'latex', 'diamond', 'double', 'smooth', 'cycle', 'coordinates', 'distance',
8076 \ 'even', 'odd', 'rule', 'pattern',
8077 \ 'stars', 'shading', 'ball', 'axis', 'middle', 'outer', 'transorm',
8078 \ 'fading', 'horizontal', 'vertical', 'light', 'dark', 'button', 'postaction', 'out',
8079 \ 'circular', 'shadow', 'scope', 'borders', 'spreading', 'false', 'position', 'midway',
8080 \ 'paint', 'from', 'to' ]
8081 let g:atp_tikz_library_arrows_keywords = [ 'reversed', 'stealth', 'triangle', 'open',
8082 \ 'hooks', 'round', 'fast', 'cap', 'butt']
8083 let g:atp_tikz_library_automata_keywords=[ 'state', 'accepting', 'initial', 'swap',
8084 \ 'loop', 'nodepart', 'lower', 'upper', 'output']
8085 let g:atp_tikz_library_backgrounds_keywords=[ 'background', 'show', 'inner', 'frame', 'framed',
8086 \ 'tight', 'loose', 'xsep', 'ysep']
8088 let g:atp_tikz_library_calendar_commands=[ '\calendar', '\tikzmonthtext' ]
8089 let g:atp_tikz_library_calendar_keywords=[ 'week list', 'dates', 'day', 'day list', 'month', 'year', 'execute',
8090 \ 'before', 'after', 'downward', 'upward' ]
8091 let g:atp_tikz_library_chain_commands=[ '\chainin' ]
8092 let g:atp_tikz_library_chain_keywords=[ 'chain', 'start chain', 'on chain', 'continue chain',
8093 \ 'start branch', 'branch', 'going', 'numbers', 'greek' ]
8094 let g:atp_tikz_library_decorations_commands=[ '\\arrowreversed' ]
8095 let g:atp_tikz_library_decorations_keywords=[ 'decorate', 'decoration', 'lineto', 'straight', 'zigzag',
8096 \ 'saw', 'random steps', 'bent', 'aspect', 'bumps', 'coil', 'curveto', 'snake',
8097 \ 'border', 'brace', 'segment lenght', 'waves', 'ticks', 'expanding',
8098 \ 'crosses', 'triangles', 'dart', 'shape', 'width', 'size', 'sep', 'shape backgrounds',
8099 \ 'between', 'along', 'path',
8100 \ 'Koch curve type 1', 'Koch curve type 1', 'Koch snowflake', 'Cantor set', 'footprints',
8101 \ 'foot', 'stride lenght', 'foot', 'foot', 'foot of', 'gnome', 'human',
8102 \ 'bird', 'felis silvestris', 'evenly', 'spread', 'scaled', 'star', 'height', 'text',
8103 \ 'mark', 'reset', 'marks' ]
8104 let g:atp_tikz_library_er_keywords = [ 'entity', 'relationship', 'attribute', 'key']
8105 let g:atp_tikz_library_fadings_keywords = [ 'with', 'fuzzy', 'percent', 'ring' ]
8106 let g:atp_tikz_library_fit_keywords = [ 'fit']
8107 let g:atp_tikz_library_matrix_keywords = ['matrix', 'of', 'nodes', 'math', 'matrix of math nodes',
8108 \ 'matrix of nodes', 'delimiter',
8109 \ 'rmoustache', 'column sep=', 'row sep=' ]
8110 let g:atp_tikz_library_mindmap_keywords = [ 'mindmap', 'concept', 'large', 'huge', 'extra', 'root', 'level',
8111 \ 'connection', 'bar', 'switch', 'annotation' ]
8112 let g:atp_tikz_library_folding_commands = ["\\tikzfoldingdodecahedron"]
8113 let g:atp_tikz_library_folding_keywords = ['face', 'cut', 'fold']
8114 let g:atp_tikz_library_patterns_keywords = ['lines', 'fivepointed', 'sixpointed', 'bricks', 'checkerboard',
8115 \ 'crosshatch', 'dots']
8116 let g:atp_tikz_library_petri_commands = ["\\tokennumber" ]
8117 let g:atp_tikz_library_petri_keywords = ['place', 'transition', 'pre', 'post', 'token', 'child', 'children',
8118 \ 'are', 'tokens', 'colored', 'structured' ]
8119 let g:atp_tikz_library_pgfplothandlers_commands = ["\\pgfplothandlercurveto", "\\pgfsetplottension",
8120 \ "\\pgfplothandlerclosedcurve", "\\pgfplothandlerxcomb", "\\pgfplothandlerycomb",
8121 \ "\\pgfplothandlerpolarcomb", "\\pgfplothandlermark{", "\\pgfsetplotmarkpeat{",
8122 \ "\\pgfsetplotmarkphase", "\\pgfplothandlermarklisted{", "\\pgfuseplotmark",
8123 \ "\\pgfsetplotmarksize{", "\\pgfplotmarksize" ]
8124 let g:atp_tikz_library_plotmarks_keywords = [ 'asterisk', 'star', 'oplus', 'oplus*', 'otimes', 'otimes*',
8125 \ 'square', 'square*', 'triangle', 'triangle*', 'diamond*', 'pentagon', 'pentagon*']
8126 let g:atp_tikz_library_shadow_keywords = ['general shadow', 'shadow', 'drop shadow', 'copy shadow', 'glow' ]
8127 let g:atp_tikz_library_shapes_keywords = ['shape', 'center', 'base', 'mid', 'trapezium', 'semicircle', 'chord', 'regular polygon', 'corner', 'star', 'isoscales triangle', 'border', 'stretches', 'kite', 'vertex', 'side', 'dart', 'tip', 'tail', 'circular', 'sector', 'cylinder', 'minimum', 'height', 'width', 'aspect', 'uses', 'custom', 'body', 'forbidden sign', 'cloud', 'puffs', 'ignores', 'starburst', 'random', 'signal', 'pointer', 'tape',
8128 \ 'single', 'arrow', 'head', 'extend', 'indent', 'after', 'before', 'arrow box', 'shaft',
8129 \ 'lower', 'upper', 'split', 'empty', 'part',
8130 \ 'callout', 'relative', 'absolute', 'shorten',
8131 \ 'logic gate', 'gate', 'inputs', 'inverted', 'radius', 'use', 'US style', 'CDH style', 'nand', 'and', 'or', 'nor', 'xor', 'xnor', 'not', 'buffer', 'IEC symbol', 'symbol', 'align',
8132 \ 'cross out', 'strike out', 'length', 'chamfered rectangle' ]
8133 let g:atp_tikz_library_topath_keywords = ['line to', 'curve to', 'out', 'in', 'relative', 'bend', 'looseness', 'min', 'max', 'control', 'loop']
8134 let g:atp_tikz_library_through_keywords = ['through']
8135 let g:atp_tikz_library_trees_keywords = ['grow', 'via', 'three', 'points', 'two', 'child', 'children', 'sibling', 'clockwise', 'counterclockwise', 'edge', 'parent', 'fork']
8137 if !exists("g:atp_MathOpened")
8138 let g:atp_MathOpened = 1
8140 " augroup ATP_MathOpened
8142 " au Syntax tex :let g:atp_MathOpened = 1
8145 " ToDo: Think about even better math modes patterns.
8146 " \[ - math mode \\[ - not mathmode (this can be at the end of a line as: \\[3pt])
8147 " \\[ - this is math mode, but tex will complain (now I'm not matching it,
8148 " that's maybe good.)
8149 " How to deal with $:$ (they are usually in one line, we could count them) and $$:$$
8152 let g:atp_math_modes=[ ['\%([^\\]\|^\)\%(\\\|\\\{3}\)(','\%([^\\]\|^\)\%(\\\|\\\{3}\)\zs)'],
8153 \ ['\%([^\\]\|^\)\%(\\\|\\\{3}\)\[','\%([^\\]\|^\)\%(\\\|\\\{3}\)\zs\]'],
8154 \ ['\\begin{align', '\\end{alig\zsn'], ['\\begin{gather', '\\end{gathe\zsr'],
8155 \ ['\\begin{falign', '\\end{flagi\zsn'], ['\\begin[multline', '\\end{multlin\zse'],
8156 \ ['\\begin{equation', '\\end{equatio\zsn'],
8157 \ ['\\begin{\%(display\)\?math', '\\end{\%(display\)\?mat\zsh'] ]
8158 " ToDo: user command list, env list g:atp_Commands, g:atp_Environments,
8161 " Some of the autocommands (Status Line, LocalCommands, Log File):
8167 augroup ATP_updatetime
8168 au VimEnter if &l:updatetime == 4000 | let &l:updatetime = 800 | endif
8169 au InsertEnter *.tex let s:updatetime=&l:updatetime | let &l:updatetime = g:atp_insert_updatetime
8170 au InsertLeave *.tex let &l:updatetime=s:updatetime
8173 if (exists("g:atp_statusline") && g:atp_statusline == '1') || !exists("g:atp_statusline")
8176 au BufWinEnter *.tex call ATPStatus("")
8180 if g:atp_local_completion == 2
8181 augroup ATP_LocaCommands
8183 au BufEnter *.tex call LocalCommands()
8187 augroup ATP_TeXFlavor
8189 au FileType *tex let b:atp_TexFlavor = &filetype
8192 " au *.log if LogBufferFileDiffer | silent execute '%g/^\s*$/d' | w! | endif
8193 " or maybe it is better to do that after latex made the log file in the call back
8194 " function, but this adds something to every compilation process !
8195 " This changes the cursor position in the log file which is NOT GOOD.
8196 " au WinEnter *.log execute "normal m'" | silent execute '%g/^\s*$/d' | execute "normal ''"
8199 " This doesn't work !
8201 " fun! GetSynStackI()
8203 " let synstackI=synstack(line("."), col("."))
8205 " let test = synstackI == 0
8207 " catch /Can only compare List with List/
8214 " return map(synstack, "synIDattr(v:val, 'name')")
8218 " The first one is not working! (which is the more important of these two :(
8219 " au CursorMovedI *.tex let g:atp_synstackI = GetSynStackI()
8220 " This has problems in visual mode:
8221 " au CursorMoved *.tex let g:atp_synstack = map(synstack(line('.'), col('.')), "synIDattr(v:val, 'name')")
8226 " This function and the following autocommand toggles the textwidth option if
8227 " editing a math mode. Currently, supported are $:$, \(:\), \[:\] and $$:$$.
8228 " {{{ SetMathVimOptions
8230 if !exists("g:atp_SetMathVimOptions")
8231 let g:atp_SetMathVimOptions = 1
8234 if !exists("g:atp_MathVimOptions")
8235 " { 'option_name' : [ val_in_math, normal_val], ... }
8236 let g:atp_MathVimOptions = { 'textwidth' : [ 0, &textwidth],
8240 if !exists("g:atp_MathZones")
8241 let g:atp_MathZones = &l:filetype == "tex" ? [
8242 \ 'texMathZoneV', 'texMathZoneW',
8243 \ 'texMathZoneX', 'texMathZoneY',
8244 \ 'texMathZoneA', 'texMathZoneAS',
8245 \ 'texMathZoneB', 'texMathZoneBS',
8246 \ 'texMathZoneC', 'texMathZoneCS',
8247 \ 'texMathZoneD', 'texMathZoneDS',
8248 \ 'texMathZoneE', 'texMathZoneES',
8249 \ 'texMathZoneF', 'texMathZoneFS',
8250 \ 'texMathZoneG', 'texMathZoneGS',
8251 \ 'texMathZoneH', 'texMathZoneHS',
8252 \ 'texMathZoneI', 'texMathZoneIS',
8253 \ 'texMathZoneJ', 'texMathZoneJS',
8254 \ 'texMathZoneK', 'texMathZoneKS',
8255 \ 'texMathZoneL', 'texMathZoneLS'
8257 \ : [ 'plaintexMath' ]
8260 " a:0 = 0 check if in math mode
8261 " a:1 = 0 assume cursor is not in math
8262 " a:1 = 1 assume cursor stands in math
8263 function! s:SetMathVimOptions(...)
8265 if !g:atp_SetMathVimOptions
8266 return "no setting to toggle"
8269 let MathZones = copy(g:atp_MathZones)
8270 if b:atp_TexFlavor == 'plaintex'
8271 call add(MathZones, 'texMathZoneY')
8274 " Change the long values to numbers
8275 let MathVimOptions = map(copy(g:atp_MathVimOptions),
8276 \ " v:val[0] =~ v:key ? [ v:val[0] =~ 'no' . v:key ? 0 : 1, v:val[1] ] : v:val " )
8277 let MathVimOptions = map(MathVimOptions,
8278 \ " v:val[1] =~ v:key ? [ v:val[0], v:val[1] =~ 'no' . v:key ? 0 : 1 ] : v:val " )
8280 " check if the current (and 3 steps back) cursor position is in math
8282 let check = a:0 == 0 ? atplib#CheckSyntaxGroups(MathZones) + atplib#CheckSyntaxGroups(MathZones, line("."), max([ 1, col(".")-3])) : a:1
8285 for option_name in keys(MathVimOptions)
8286 execute "let &l:".option_name. " = " . MathVimOptions[option_name][0]
8289 for option_name in keys(MathVimOptions)
8290 execute "let &l:".option_name. " = " . MathVimOptions[option_name][1]
8298 augroup ATP_SetMathVimOptions
8300 " if leaving the insert mode set the non-math options
8301 au InsertLeave *.tex :call s:SetMathVimOptions(0)
8302 " if entering the insert mode or in the insert mode check if the cursor is in
8303 " math or not and set the options acrodingly
8304 au InsertEnter *.tex :call s:SetMathVimOptions()
8305 au CursorMovedI *.tex :call s:SetMathVimOptions()
8306 " This slows down vim when moving the cursor:
8307 " au CursorMoved *.tex :call s:SetMathVimOptions()
8313 " Add extra syntax groups
8314 " {{{1 ATP_SyntaxGroups
8315 function! s:ATP_SyntaxGroups()
8316 if atplib#SearchPackage('tikz') || atplib#SearchPackage('pgfplots')
8318 call TexNewMathZone("T", "tikzpicture", 0)
8322 if atplib#SearchPackage('algorithmic')
8324 call TexNewMathZone("ALG", "algorithmic", 0)
8330 augroup ATP_Syntax_TikzZone
8331 au Syntax tex :call <SID>ATP_SyntaxGroups()
8335 au BufEnter *.sty :setl nospell
8336 au BufEnter *.cls :setl nospell
8337 au BufEnter *.fd :setl nospell
8341 "{{{1 Highlightings in help file
8342 augroup ATP_HelpFile_Highlight
8343 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('atp_FileName') ? "atp_FileName" : "Title", 'highlight atp_FileName\s\+Title')
8344 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('atp_LineNr') ? "atp_LineNr" : "LineNr", 'highlight atp_LineNr\s\+LineNr')
8345 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('atp_Number') ? "atp_Number" : "Number", 'highlight atp_Number\s\+Number')
8346 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('atp_Chapter') ? "atp_Chapter" : "Label", 'highlight atp_Chapter\s\+Label')
8347 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('atp_Section') ? "atp_Section" : "Label", 'highlight atp_Section\s\+Label')
8348 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('atp_SubSection') ? "atp_SubSection": "Label", 'highlight atp_SubSection\s\+Label')
8349 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('atp_Abstract') ? "atp_Abstract" : "Label", 'highlight atp_Abstract\s\+Label')
8351 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('atp_label_FileName') ? "atp_label_FileName" : "Title", '^\s*highlight atp_label_FileName\s\+Title\s*$')
8352 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('atp_label_LineNr') ? "atp_label_LineNr" : "LineNr", '^\s*highlight atp_label_LineNr\s\+LineNr\s*$')
8353 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('atp_label_Name') ? "atp_label_Name" : "Label", '^\s*highlight atp_label_Name\s\+Label\s*$')
8354 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('atp_label_Counter') ? "atp_label_Counter" : "Keyword", '^\s*highlight atp_label_Counter\s\+Keyword\s*$')
8356 au BufEnter automatic-tex-plugin.txt call matchadd(hlexists('bibsearchInfo') ? "bibsearchInfo" : "Number", '^\s*highlight bibsearchInfo\s*$')
8360 " {{{1 :Viewer, :Compiler, :DebugMode
8361 function! s:Viewer(viewer)
8362 let old_viewer = b:atp_Viewer
8363 let oldViewer = get(g:ViewerMsg_Dict, matchstr(old_viewer, '^\s*\zs\S*'), "")
8364 let b:atp_Viewer = a:viewer
8365 let Viewer = get(g:ViewerMsg_Dict, matchstr(b:atp_Viewer, '^\s*\zs\S*'), "")
8366 silent! execute "aunmenu LaTeX.View\\ with\\ ".oldViewer
8367 silent! execute "aunmenu LaTeX.View\\ Output"
8369 execute "menu 550.10 LaTe&X.&View\\ with\\ ".Viewer."<Tab>:ViewOutput :<C-U>ViewOutput<CR>"
8370 execute "cmenu 550.10 LaTe&X.&View\\ with\\ ".Viewer."<Tab>:ViewOutput <C-U>ViewOutput<CR>"
8371 execute "imenu 550.10 LaTe&X.&View\\ with\\ ".Viewer."<Tab>:ViewOutput <Esc>:ViewOutput<CR>a"
8373 execute "menu 550.10 LaTe&X.&View\\ Output\\ <Tab>:ViewOutput :<C-U>ViewOutput<CR>"
8374 execute "cmenu 550.10 LaTe&X.&View\\ Output\\ <Tab>:ViewOutput <C-U>ViewOutput<CR>"
8375 execute "imenu 550.10 LaTe&X.&View\\ Output\\ <Tab>:ViewOutput <Esc>:ViewOutput<CR>a"
8378 command! -buffer -nargs=1 -complete=customlist,ViewerComp Viewer :call <SID>Viewer(<q-args>)
8379 function! ViewerComp(A,L,P)
8380 let view = [ 'okular', 'xpdf', 'xdvi', 'evince', 'epdfview', 'kpdf', 'acroread' ]
8381 call filter(view, "v:val =~ '^' . a:A")
8382 call filter(view, 'executable(v:val)')
8386 function! s:Compiler(compiler)
8387 let old_compiler = b:atp_TexCompiler
8388 let oldCompiler = get(g:CompilerMsg_Dict, matchstr(old_compiler, '^\s*\zs\S*'), "")
8389 let b:atp_TexCompiler = a:compiler
8390 let Compiler = get(g:CompilerMsg_Dict, matchstr(b:atp_TexCompiler, '^\s*\zs\S*'), "")
8391 silent! execute "aunmenu LaTeX.".oldCompiler
8392 silent! execute "aunmenu LaTeX.".oldCompiler."\\ debug"
8393 silent! execute "aunmenu LaTeX.".oldCompiler."\\ twice"
8394 execute "menu 550.5 LaTe&X.&".Compiler."<Tab>:TEX :<C-U>TEX<CR>"
8395 execute "cmenu 550.5 LaTe&X.&".Compiler."<Tab>:TEX <C-U>TEX<CR>"
8396 execute "imenu 550.5 LaTe&X.&".Compiler."<Tab>:TEX <Esc>:TEX<CR>a"
8397 execute "menu 550.6 LaTe&X.".Compiler."\\ debug<Tab>:TEX\\ debug :<C-U>DTEX<CR>"
8398 execute "cmenu 550.6 LaTe&X.".Compiler."\\ debug<Tab>:TEX\\ debug <C-U>DTEX<CR>"
8399 execute "imenu 550.6 LaTe&X.".Compiler."\\ debug<Tab>:TEX\\ debug <Esc>:DTEX<CR>a"
8400 execute "menu 550.7 LaTe&X.".Compiler."\\ &twice<Tab>:2TEX :<C-U>2TEX<CR>"
8401 execute "cmenu 550.7 LaTe&X.".Compiler."\\ &twice<Tab>:2TEX <C-U>2TEX<CR>"
8402 execute "imenu 550.7 LaTe&X.".Compiler."\\ &twice<Tab>:2TEX <Esc>:2TEX<CR>a"
8404 command! -buffer -nargs=1 -complete=customlist,CompilerComp Compiler :call <SID>Compiler(<q-args>)
8405 function! CompilerComp(A,L,P)
8406 let compilers = [ 'tex', 'pdftex', 'latex', 'pdflatex', 'etex', 'xetex', 'luatex' ]
8407 " let g:compilers = copy(compilers)
8408 call filter(compilers, "v:val =~ '^' . a:A")
8409 call filter(compilers, 'executable(v:val)')
8413 command! -buffer -nargs=1 -complete=customlist,DebugComp DebugMode :let t:atp_DebugMode=<q-args>
8414 function! DebugComp(A,L,P)
8415 let modes = [ 'silent', 'debug', 'verbose']
8416 call filter(modes, "v:val =~ '^' . a:A")
8420 " vim:fdm=marker:tw=85:ff=unix:noet:ts=8:sw=4:fdc=1
8421 ftplugin/ATP_files/search.vim [[[1
8423 " Author: Marcin Szamotulski
8424 " Description: This file provides searching tools of ATP.
8425 " Note: This file is a part of Automatic Tex Plugin for Vim.
8426 " URL: https://launchpad.net/automatictexplugin
8429 let s:sourced = exists("s:sourced") ? 1 : 0
8432 " Make a dictionary of definitions found in all input files.
8433 " {{{ s:make_defi_dict
8434 " Comparing with ]D, ]d, ]i, ]I vim maps this function deals with multiline
8437 " The output dictionary is of the form:
8438 " { input_file : [ [begin_line, end_line], ... ] }
8439 " a:1 = buffer name to search in for input files
8440 " a:3 = 1 skip searching for the end_line
8442 " ToDo: it is possible to check for the end using searchpairpos, but it
8443 " operates on a list not on a buffer.
8444 function! s:make_defi_dict(bang,...)
8446 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
8447 let bufname = a:0 >= 1 ? a:1 : atp_MainFile
8449 " pattern to match the definitions this function is also used to fine
8450 " \newtheorem, and \newenvironment commands
8451 let pattern = a:0 >= 2 ? a:2 : '\\def\|\\newcommand'
8453 let preambule_only= a:bang == "!" ? 0 : 1
8455 " this is still to slow!
8456 let only_begining = a:0 >= 3 ? a:3 : 0
8460 let inputfiles=FindInputFiles(bufname)
8463 " TeX: How this work in TeX files.
8464 for inputfile in keys(inputfiles)
8465 if inputfiles[inputfile][0] != "bib" && ( !preambule_only || inputfiles[inputfile][0] == "preambule" )
8466 call add(input_files, inputfiles[inputfile][2])
8470 let input_files=filter(input_files, 'v:val != ""')
8471 if !count(input_files, atp_MainFile)
8472 call extend(input_files,[ atp_MainFile ])
8475 if len(input_files) > 0
8476 for inputfile in input_files
8477 let defi_dict[inputfile]=[]
8478 " do not search for definitions in bib files
8479 "TODO: it skips lines somehow.
8480 let ifile=readfile(inputfile)
8482 " search for definitions
8484 while (lnr <= len(ifile) && (!preambule_only || ifile[lnr-1] !~ '\\begin\s*{document}'))
8488 let line=ifile[lnr-1]
8489 if substitute(line,'%.*','','') =~ pattern
8495 let open=atplib#count(line,'{')
8496 let close=atplib#count(line,'}')
8498 "go to next line and count if the definition ends at
8500 let line = ifile[lnr-1]
8501 let open +=atplib#count(line,'{')
8502 let close +=atplib#count(line,'}')
8506 call add(defi_dict[inputfile], [ b_line, e_line ])
8508 call add(defi_dict[inputfile], [ b_line ])
8521 " Find all names of locally defined commands, colors and environments.
8522 " Used by the completion function.
8525 " a:2 = "!" => renegenerate the input files.
8526 function! LocalCommands(...)
8527 " let time = reltime()
8528 let pattern = a:0 >= 1 && a:1 != '' ? a:1 : '\\def\>\|\\newcommand\>\|\\newenvironment\|\\newtheorem\|\\definecolor'
8529 let bang = a:0 >= 2 ? a:2 : ''
8531 " Regenerate the package list
8533 let b:atp_PacakgeList = atplib#GrepPackageList()
8536 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
8539 " Makeing lists of commands and environments found in input files
8540 if bang == "!" || !exists("b:TreeOfFiles")
8541 " Update the cached values:
8542 let [ b:TreeOfFiles, b:ListOfFiles, b:TypeDict, b:LevelDict ] = TreeOfFiles(atp_MainFile)
8544 let [ Tree, List, Type_Dict, Level_Dict ] = deepcopy([ b:TreeOfFiles, b:ListOfFiles, b:TypeDict, b:LevelDict ])
8546 let saved_loclist = getloclist(0)
8547 " I should scan the preambule separately!
8548 " This will make the function twice as fast!
8549 silent! execute "lvimgrep /".pattern."/j " . fnameescape(atp_MainFile)
8551 if get(Type_Dict, file, 'no_file') == 'preambule'
8552 silent! execute "lvimgrepadd /".pattern."/j " . fnameescape(file)
8555 let loclist = getloclist(0)
8556 call setloclist(0, saved_loclist)
8558 let atp_LocalCommands = []
8559 let atp_LocalEnvironments = []
8560 let atp_LocalColors = []
8563 " the order of pattern is important
8564 if line['text'] =~ '\\definecolor'
8566 let name=matchstr(line['text'],
8567 \ '\\definecolor\s*{\s*\zs[^}]*\ze\s*}')
8569 elseif line['text'] =~ '\\def\|\\newcommand'
8571 let name= '\' . matchstr(line['text'],
8572 \ '\\def\\\zs[^{#]*\ze[{#]\|\\newcommand{\?\\\zs[^\[{]*\ze}')
8575 " let def=matchstr(line['text'],
8576 " \ '^\%(\\def\\[^{]*{\zs.*\ze}\|\\newcommand\\[^{]*{\zs.*\ze}\)')
8577 elseif line['text'] =~ '\%(\\newenvironment\|\\newtheorem\)'
8579 let name=matchstr(line['text'],
8580 \ '\\\%(newtheorem\*\?\|newenvironment\)\s*{\s*\zs[^}]*\ze\s*}')
8581 let type="Environments"
8583 if name != '' && name != '\'
8584 if count(atp_Local{type}, name) == 0
8585 call add(atp_Local{type}, name)
8590 let b:atp_LocalCommands = atp_LocalCommands
8591 let b:atp_LocalEnvironments = atp_LocalEnvironments
8592 let b:atp_LocalColors = atp_LocalColors
8593 " echomsg reltimestr(reltime(time))
8594 return [ atp_LocalEnvironments, atp_LocalCommands, atp_LocalColors ]
8599 " Search for Definition in the definition dictionary (s:make_defi_dict).
8601 function! DefiSearch(bang,...)
8603 let pattern = a:0 >= 1 ? a:1 : ''
8604 let preambule_only = a:bang == "!" ? 0 : 1
8605 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
8607 let defi_dict = s:make_defi_dict(a:bang, atp_MainFile, '\\def\|\\newcommand')
8610 let openbuffer=" +setl\\ buftype=nofile\\ nospell\\ syntax=tex " . fnameescape("DefiSearch")
8612 let openbuffer="vsplit " . openbuffer
8614 let openbuffer="split " . openbuffer
8617 if len(defi_dict) > 0
8618 " wipe out the old buffer and open new one instead
8619 if bufloaded("DefiSearch")
8620 exe "silent bd! " . bufnr("DefiSearch")
8622 silent exe openbuffer
8623 map <buffer> q :bd<CR>
8625 for inputfile in keys(defi_dict)
8626 let ifile = readfile(inputfile)
8627 for l:range in defi_dict[inputfile]
8628 if ifile[l:range[0]-1] =~ pattern
8629 " print the lines into the buffer
8632 " add an empty line if the definition is longer than one line
8633 if l:range[0] != l:range[1]
8634 call setline(line('$')+1,'')
8637 while c <= l:range[1]-l:range[0]
8638 let line=l:range[0]+c
8639 call setline(line('$')+1,ifile[line-1])
8646 if getbufline("DefiSearch",'1','$') == ['']
8650 echomsg "Definition not found."
8656 echomsg "Definition not found."
8662 " Search in tree and return the one level up element and its line number.
8663 " {{{1 <SID>SearchInTree
8664 " Before running this function one has to set the two variables
8665 " s:branch/s:branch_line to 0.
8666 " the a:tree variable should be something like:
8667 " a:tree = { b:atp_MainFile, [ TreeOfFiles(b:atp_MainFile)[0], 0 ] }
8668 " necessary a rooted tree!
8670 " This function remaps keys of dictionary.
8671 function! MapDict(dict)
8673 for key in keys(a:dict)
8674 let new_key = fnamemodify(key, ":p")
8675 let new_dict[new_key] = a:dict[key]
8680 function! <SID>SearchInTree(tree, branch, what)
8682 redir! >> /tmp/atp_debugSIT
8683 silent! echo "___SEARCH_IN_TREE___"
8684 silent! echo "a:branch=". a:branch
8685 silent! echo "a:what=" . a:what
8687 if g:atp_debugSIT >= 2
8688 silent! echo "a:tree=" . string(a:tree)
8691 " let branch = a:tree[a:branch][0]
8692 if a:branch =~ '^\s*\/'
8694 exe "lcd " . b:atp_ProjectDir
8695 let branchArg = ( g:atp_RelativePath ? fnamemodify(a:branch, ":.") : a:branch )
8696 let branchArgN = ( !g:atp_RelativePath ? fnamemodify(a:branch, ":.") : a:branch )
8697 let whatArg = ( g:atp_RelativePath ? fnamemodify(a:what, ":.") : a:what )
8698 let whatArgN = ( !g:atp_RelativePath ? fnamemodify(a:what, ":.") : a:what )
8700 silent! echo "*** cwd=" . getcwd() . " b:atp_ProjectDir= " . b:atp_ProjectDir . " " . fnamemodify(a:branch, ":.") . " " . a:branch
8704 let branchArg = ( g:atp_RelativePath ? a:branch : atplib#FullPath(a:branch) )
8705 let branchArgN = ( !g:atp_RelativePath ? a:branch : atplib#FullPath(a:branch) )
8706 let whatArg = ( g:atp_RelativePath ? a:what : atplib#FullPath(a:what) )
8707 let whatArgN = ( !g:atp_RelativePath ? a:what : atplib#FullPath(a:what) )
8710 silent! echo "branchArg=" . branchArg . " branchArgN=" . branchArgN
8711 silent! echo "whatArg=" . whatArg . " whatArgN=" . whatArgN
8713 let branch = get(a:tree, branchArg , get(a:tree, branchArgN, ['NO_BRANCH']))[0]
8714 if count(keys(branch), whatArg) || count(keys(branch), whatArgN)
8715 " The following variable is used as a return value in
8717 let g:ATP_branch = branchArg
8718 " let g:ATP_branch_line = a:tree[a:branch][0][a:what][1]
8719 let g:ATP_branch_line = get(branch, whatArg, get(branch, whatArgN, ['', 'ERROR']))[1]
8721 silent! echo "g:ATP_branch=" . g:ATP_branch . " g:ATP_branch_line=" . g:ATP_branch_line
8727 for new_branch in keys(branch)
8728 call <SID>SearchInTree(branch, new_branch, whatArg)
8738 " Search in all input files recursively.
8739 " {{{1 Search (recursive)
8741 " Variables are used to pass them to next runs (this function calls it self)
8742 " a:main_file = b:atp_MainFile
8743 " a:start_file = expand("%:p") /this variable will not change untill the
8745 " a:tree = make_tree => make a tree
8746 " = any other value => use { a:main_file : [ b:TreeOfFiles, 0] }
8747 " a:cur_branch = expand("%") /this will change whenever we change a file/
8748 " a:call_nr = number of the call
8749 " a:wrap_nr = if hit top/bottom a:call=0 but a:wrap_nr+=1
8750 " a:winsaveview = winsaveview(0) to resotre the view if the pattern was not found
8751 " a:bufnr = bufnr("%") to come back to begining buffer if pattern not found
8752 " a:strftime = strftime(0) to compute the time
8753 " a:pattern = pattern to search
8754 " a:1 = flags: 'bcewWs'
8755 " a:2 is not not used:
8756 " a:2 = goto = DOWN_ACCEPT / Must not be used by the end user/
8759 " g:atp_debugRS if 1 sets debugging messages which are appended to '/tmp/ATP_rs_debug'
8760 " you can :set errorfile=/tmp/ATP_rs_debug
8763 " log file : /tmp/ATP_rs_debug
8764 " {{{2 s:RecursiveSearch function
8765 let g:atp_swapexists = 0
8767 function! <SID>RecursiveSearch(main_file, start_file, tree, cur_branch, call_nr, wrap_nr, winsaveview, bufnr, strftime, vim_options, cwd, pattern, ... )
8769 let main_file = g:atp_RelativePath ? atplib#RelativePath(a:main_file, b:atp_ProjectDir) : a:main_file
8771 let time0 = reltime()
8773 " set and restore some options:
8774 " foldenable (unset to prevent opening the folds :h winsaveview)
8775 " comeback to the starting buffer
8776 if a:call_nr == 1 && a:wrap_nr == 1
8778 if a:vim_options == { 'no_options' : 'no_options' }
8779 let vim_options = { 'hidden' : &l:hidden,
8780 \ 'foldenable' : &l:foldenable,
8781 \ 'autochdir' : &l:autochdir }
8783 let vim_options = a:vim_options
8786 let &l:foldenable = 0
8787 let &l:autochdir = 0
8789 if a:cwd == 'no_cwd'
8794 exe "lcd " . b:atp_ProjectDir
8796 " This makes it work faster when the input files were not yet opened by vim
8797 " some of them will not be shown to the user.
8800 " there are many errors in /tmp/ATP_rs_debug file due to this which are not
8804 let vim_options = a:vim_options
8808 " Redirect debuggin messages:
8810 if a:wrap_nr == 1 && a:call_nr == 1
8811 redir! > /tmp/ATP_rs_debug
8813 redir! >> /tmp/ATP_rs_debug
8815 silent echo "________________"
8816 silent echo "Args: a:pattern:".a:pattern." call_nr:".a:call_nr. " wrap_nr:".a:wrap_nr . " cwd=" . getcwd()
8819 let flags_supplied = a:0 >= 1 ? a:1 : ""
8821 if flags_supplied =~# 'p'
8822 let flags_supplied = substitute(flags_supplied, 'p', '', 'g')
8824 echomsg "Searching flag 'p' is not supported, filtering it out."
8828 if a:tree == 'make_tree'
8830 silent echo "*** Makeing Tree 1 ***"
8832 let l:tree = { main_file : [ TreeOfFiles(main_file)[0], 0] }
8833 elseif exists("b:TreeOfFiles")
8835 silent echo "*** Using Tree ***"
8837 let l:tree = { main_file : [ b:TreeOfFiles, 0] }
8839 let ttime = reltime()
8841 silent echo "*** Makeing Tree 2 ***"
8843 let l:tree = { main_file : [ TreeOfFiles(main_file)[0], 0] }
8844 if g:atp_debugRS >= 2
8845 silent echo "tTIME:" . reltimestr(reltime(ttime))
8849 if a:cur_branch != "no cur_branch "
8850 let cur_branch = a:cur_branch
8852 let cur_branch = main_file
8855 if g:atp_debugRS > 1
8856 silent echo "TIME0:" . reltimestr(reltime(time0))
8859 let pattern = a:pattern
8860 let flags_supplied = substitute(flags_supplied, '[^bcenswWS]', '', 'g')
8862 " Add pattern to the search history
8864 call histadd("search", a:pattern)
8868 " Set up searching flags
8869 let flag = flags_supplied
8871 let flag = flags_supplied !~# 'c' ? flags_supplied . 'c' : flags_supplied
8873 let flag = substitute(flag, 'w', '', 'g') . 'W'
8874 let flag = flag !~# 'n' ? substitute(flag, 'n', '', 'g') . 'n' : flag
8875 let flag = substitute(flag, 's', '', 'g')
8877 if flags_supplied !~# 'b'
8878 " forward searching flag for input files:
8879 let flag_i = flags_supplied !~# 'c' ? flags_supplied . 'c' : flags_supplied
8881 let flag_i = substitute(flags_supplied, 'c', '', 'g')
8883 let flag_i = flag_i !~# 'n' ? flag_i . 'n' : flag_i
8884 let flag_i = substitute(flag_i, 'w', '', 'g') . 'W'
8885 let flag_i = substitute(flag_i, 's', '', 'g')
8888 silent echo " flags_supplied:".flags_supplied." flag:".flag." flag_i:".flag_i." a:1=".(a:0 != 0 ? a:1 : "")
8892 let cur_pos = [line("."), col(".")]
8893 " We filter out the 's' flag which should be used only once
8894 " as the flags passed to next <SID>RecursiveSearch()es are based on flags_supplied variable
8896 let s_flag = flags_supplied =~# 's' ? 1 : 0
8897 let flags_supplied = substitute(flags_supplied, 's', '', 'g')
8899 call setpos("''", getpos("."))
8901 keepjumps let pat_pos = searchpos(pattern, flag)
8903 if g:atp_debugRS > 1
8904 silent echo "TIME1:" . reltimestr(reltime(time0))
8907 " FIND INPUT PATTERN:
8908 " (we do not need to search further than pat_pos)
8909 if pat_pos == [0, 0]
8910 let stop_line = flag !~# 'b' ? line("$") : 1
8912 let stop_line = pat_pos[0]
8914 keepjumps let input_pos = searchpos('\m^[^%]*\\input\s*{', flag_i . 'n', stop_line )
8916 if g:atp_debugRS > 1
8917 silent echo "TIME2:" . reltimestr(reltime(time0))
8921 silent echo "Positions: ".string(cur_pos)." ".string(pat_pos)." ".string(input_pos)." in branch: ".cur_branch."#".expand("%:p") . " stop_line: " . stop_line
8925 " the current value of down_accept
8926 let DOWN_ACCEPT = a:0 >= 2 ? a:2 : 0
8927 " the value of down_accept in next turn
8928 let down_accept = getline(input_pos[0]) =~ pattern || input_pos == [0, 0] ? 1 : 0
8931 " silent echo "DOWN_ACCEPT=" . DOWN_ACCEPT . " down_accept=" . down_accept
8934 " Decide what to do: accept the pattern, go to higher branch, go to lower
8935 " branch or say Pattern not found
8936 if flags_supplied !~# 'b'
8938 " cur < pat <= input
8939 if atplib#CompareCoordinates(cur_pos,pat_pos) && atplib#CompareCoordinates_leq(pat_pos, input_pos)
8940 let goto = 'ACCEPT' . 1
8941 let goto_s = 'ACCEPT'
8942 " cur == pat <= input
8943 elseif cur_pos == pat_pos && atplib#CompareCoordinates_leq(pat_pos, input_pos)
8944 " this means that the 'flag' variable has to contain 'c' or the
8946 " ACCEPT if 'c' and wrapscan is off or there is another match below,
8947 " if there is not go UP.
8948 let wrapscan = ( flags_supplied =~# 'w' || &l:wrapscan && flags_supplied !~# 'W' )
8950 let goto = 'ACCEPT' . 2
8951 let goto_s = 'ACCEPT'
8953 " if in wrapscan and without 'c' flag
8957 " this should not happen: cur == put can hold only in two cases:
8958 " wrapscan is on or 'c' is used.
8959 let goto = 'ERROR' . 2
8960 let goto_s = 'ERROR'
8962 " pat < cur <= input
8963 elseif atplib#CompareCoordinates(pat_pos, cur_pos) && atplib#CompareCoordinates_leq(cur_pos, input_pos)
8967 elseif atplib#CompareCoordinates(cur_pos, input_pos) && atplib#CompareCoordinates(input_pos, pat_pos)
8968 let goto = 'UP' . 41
8970 " cur < input == pat /we are looking for '\\input'/
8971 elseif atplib#CompareCoordinates(cur_pos, input_pos) && input_pos == pat_pos
8973 let goto_s = 'ACCEPT'
8974 " input < cur <= pat (includes input = 0])
8975 elseif atplib#CompareCoordinates(input_pos, cur_pos) && atplib#CompareCoordinates_leq(cur_pos, pat_pos)
8976 " cur == pat thus 'flag' contains 'c'.
8978 let goto_s = 'ACCEPT'
8980 elseif cur_pos == input_pos
8984 " input == 0 /there is no 'input' ahead - flag_i contains 'W'/
8985 " /but there is no 'pattern ahead as well/
8986 " at this stage: pat < cur (if not then input = 0 < cur <= pat was done above).
8987 elseif input_pos == [0, 0]
8988 if expand("%:p") == fnamemodify(main_file, ":p")
8990 if ( flags_supplied =~# 'w' || &l:wrapscan && flags_supplied !~# 'W' )
8991 let new_flags = substitute(flags_supplied, 'w', '', 'g') . 'W'
8996 silent echo " END 1 new_flags:" . new_flags
9000 keepjumps call <SID>RecursiveSearch(main_file, a:start_file, "", a:cur_branch, 1, a:wrap_nr+1, a:winsaveview, a:bufnr, a:strftime, vim_options, cwd, pattern, new_flags)
9004 let goto = "REJECT".1
9005 let goto_s = "REJECT"
9007 " echomsg 'Pattern not found: ' . a:pattern
9011 let goto = "REJECT".2
9012 let goto_s = "REJECT"
9014 " echomsg 'Pattern not found: ' . a:pattern
9017 " if we are not in the main file go up.
9019 let goto = "DOWN" . 21
9023 let goto = 'ERROR' . 13
9024 let goto_s = 'ERROR'
9028 " input <= pat < cur (pat != 0)
9029 if atplib#CompareCoordinates(pat_pos, cur_pos) && atplib#CompareCoordinates_leq(input_pos, pat_pos) && pat_pos != [0, 0]
9031 if input_pos != pat_pos
9032 let goto = 'ACCEPT' . 1 . 'b'
9033 let goto_s = 'ACCEPT'
9036 let goto = 'UP' . 1 . 'b'
9039 " input <= pat == cur (input != 0) /pat == cur => pat != 0/
9040 elseif cur_pos == pat_pos && atplib#CompareCoordinates_leq(input_pos, pat_pos) && input_pos != [0, 0]
9041 " this means that the 'flag' variable has to contain 'c' or the
9043 let wrapscan = ( flags_supplied =~# 'w' || &l:wrapscan && flags_supplied !~# 'W' )
9045 let goto = 'ACCEPT' . 2 . 'b'
9046 let goto_s = 'ACCEPT'
9048 " if in wrapscan and without 'c' flag
9049 let goto = 'UP' . 2 . 'b'
9052 " this should not happen: cur == put can hold only in two cases:
9053 " wrapscan is on or 'c' is used.
9054 let goto = 'ERROR' . 2 . 'b'
9055 let goto_s = 'ERROR'
9057 " input <= cur < pat (input != 0)
9058 elseif atplib#CompareCoordinates(cur_pos, pat_pos) && atplib#CompareCoordinates_leq(input_pos, cur_pos) && input_pos != [0, 0]
9059 let goto = 'UP' . 4 .'b'
9061 " pat < input <= cur (input != 0)
9062 elseif atplib#CompareCoordinates_leq(input_pos, cur_pos) && atplib#CompareCoordinates(pat_pos, input_pos) && input_pos != [0, 0]
9063 let goto = 'UP' . 41 . 'b'
9065 " input == pat < cur (pat != 0) /we are looking for '\\input'/
9066 elseif atplib#CompareCoordinates(input_pos, cur_pos) && input_pos == pat_pos && pat_pos != [0, 0]
9067 let goto = 'ACCEPT' . 5 . 'b'
9068 let goto_s = 'ACCEPT'
9069 " pat <= cur < input (pat != 0)
9070 elseif atplib#CompareCoordinates(cur_pos, input_pos) && atplib#CompareCoordinates_leq(pat_pos, cur_pos) && input_pos != [0, 0]
9071 " cur == pat thus 'flag' contains 'c'.
9072 let goto = 'ACCEPT' . 6 . 'b'
9073 let goto_s = 'ACCEPT'
9075 elseif cur_pos == input_pos
9078 " input == 0 /there is no 'input' ahead - flag_i contains 'W'/
9079 " /but there is no 'pattern ahead as well/
9080 " at this stage: cur < pat || pat=input=0 (if not then pat <= cur was done above, input=pat=0 is the
9081 " only posibility to be passed by the above filter).
9082 elseif input_pos == [0, 0]
9083 " I claim that then cur < pat or pat=0
9084 if expand("%:p") == fnamemodify(main_file, ":p")
9086 if ( flags_supplied =~# 'w' || &l:wrapscan && flags_supplied !~# 'W' )
9087 let new_flags = substitute(flags_supplied, 'w', '', 'g') . 'W'
9089 call cursor(line("$"), col("$"))
9092 silent echo " END 2 new_flags:".new_flags
9096 keepjumps call <SID>RecursiveSearch(main_file, a:start_file, "", a:cur_branch, 1, a:wrap_nr+1, a:winsaveview, a:bufnr, a:strftime, vim_options, cwd, pattern, new_flags)
9098 if g:atp_debugRS > 1
9099 silent echo "TIME_END:" . reltimestr(reltime(time0))
9104 let goto = "REJECT" . 1 . 'b'
9105 let goto_s = "REJECT"
9107 " echomsg 'Pattern not found: ' . a:pattern
9111 let goto = "REJECT" . 2 . 'b'
9112 let goto_s = "REJECT"
9114 " if we are not in the main file go up.
9116 let goto = "DOWN" . 3 . 'b'
9118 " If using the following line DOWN_ACCEPT and down_accept
9119 " variables are not needed. This seems to be the best way.
9120 " There is no need to use this feature for
9121 " \input <file_name> files.
9122 if pattern =~ '\\\\input' || pattern =~ '\\\\include'
9123 " if getline(input_pos[0]) =~ pattern || getline(".") =~ pattern
9124 let goto = "DOWN_ACCEPT" . 3 . 'b'
9125 let goto_s = "DOWN_ACCEPT"
9129 let goto = 'ERROR' . 13 . 'b'
9130 let goto_s = 'ERROR'
9135 silent echo "goto:".goto
9137 if g:atp_debugRS >= 2
9138 silent echo "TIME ***goto*** " . reltimestr(reltime(time0))
9141 " When ACCEPTING the line:
9142 if goto_s == 'ACCEPT'
9143 keepjumps call setpos(".", [ 0, pat_pos[0], pat_pos[1], 0])
9144 if flags_supplied =~# 'e'
9145 keepjumps call search(pattern, 'e', line("."))
9147 "A Better solution must be found.
9149 " execute '2match Search /'.pattern.'/'
9152 let time = matchstr(reltimestr(reltime(a:strftime)), '\d\+\.\d\d\d') . "sec."
9154 if a:wrap_nr == 2 && flags_supplied =~# 'b'
9157 echo "search hit TOP, continuing at BOTTOM "
9159 elseif a:wrap_nr == 2
9162 echo "search hit BOTTOM, continuing at TOP "
9168 silent echo "FOUND PATTERN: " . a:pattern . " time " . time
9173 " restore vim options
9174 if a:vim_options != { 'no_options' : 'no_options' }
9175 for option in keys(a:vim_options)
9176 execute "let &l:".option."=".a:vim_options[option]
9187 elseif goto_s == 'UP'
9188 call setpos(".", [ 0, input_pos[0], input_pos[0], 0])
9189 " Open file and Search in it"
9190 " This should be done by kpsewhich:
9191 let file = matchstr(getline(input_pos[0]), '\\input\s*{\zs[^}]*\ze}')
9192 let file = atplib#append_ext(l:file, '.tex')
9194 let open = flags_supplied =~ 'b' ? 'edit + ' : 'edit +1 '
9195 let swapfile = globpath(fnamemodify(file, ":h"), ( has("unix") ? "." : "" ) . fnamemodify(file, ":t") . ".swp")
9197 if !( a:call_nr == 1 && a:wrap_nr == 1 )
9198 let open = "silent keepjumps keepalt " . open
9201 let projectVarDict = SaveProjectVariables()
9202 " let projectScript = SaveProjectVariables("g:atp_cached_local_variables")
9203 " let atp_ProjectScript = [ exists("g:atp_ProjectScript") ? g:atp_ProjectScript : b:atp_ProjectScript, exists("g:atp_ProjectScript") ]
9204 " let g:atp_ProjectScript = 0
9205 if g:atp_debugRS >= 3
9206 silent echo "projectVarDict : " . string(projectVarDict)
9207 let g:projectVarDict = projectVarDict
9208 elseif g:atp_debugRS >= 2
9209 let g:projectVarDict = projectVarDict
9211 if g:atp_debugRS >= 2
9212 silent echo "TIME ***goto UP before open*** " . reltimestr(reltime(time0))
9215 if empty(swapfile) || bufexists(file)
9216 silent! execute open . file
9218 echoerr "Recursive Search: swap file: " . swapfile . " exists. Aborting."
9221 if g:atp_debugRS >= 2
9222 redir! >> /tmp/ATP_rs_debug
9223 silent echo "TIME ***goto UP after open*** " . reltimestr(reltime(time0))
9225 " call RestoreProjectVariables(projectScript)
9226 " if atp_ProjectScript[1]
9227 " let g:atp_ProjectScript = atp_ProjectScript[0]
9229 " unlet g:atp_ProjectScript
9231 call RestoreProjectVariables(projectVarDict)
9232 if g:atp_debugRS >= 2
9233 silent echo "TIME ***goto UP restore variables *** " . reltimestr(reltime(time0))
9236 if flags_supplied =~# 'b'
9237 call cursor(line("$"), col("$"))
9243 silent echo "In higher branch: " . l:file . " pos " line(".").":".col(".") . " edit " . open . " file " . expand("%:p")
9244 silent echo "flags_supplied=" . flags_supplied
9247 if g:atp_debugRS >= 2
9248 silent echo "TIME_END:" . reltimestr(reltime(time0))
9251 " let flag = flags_supplied =~ 'W' ? flags_supplied : flags_supplied . 'W'
9252 keepalt keepjumps call <SID>RecursiveSearch(main_file, a:start_file, "", expand("%:p"), a:call_nr+1, a:wrap_nr, a:winsaveview, a:bufnr, a:strftime, vim_options, cwd, pattern, flags_supplied, down_accept)
9260 elseif goto_s == 'DOWN' || goto_s == 'DOWN_ACCEPT'
9261 " We have to get the element in the tree one level up + line number
9262 let g:ATP_branch = "nobranch"
9263 let g:ATP_branch_line = "nobranch_line"
9266 silent echo " SearchInTree Args " . expand("%:p")
9269 if g:atp_RelativePath
9270 call <SID>SearchInTree(l:tree, main_file, atplib#RelativePath(expand("%:p"), resolve(b:atp_ProjectDir)))
9272 call <SID>SearchInTree(l:tree, main_file, expand("%:p"))
9276 silent echo " SearchInTree found " . g:ATP_branch . " g:ATP_branch_line=" . g:ATP_branch_line
9279 if g:ATP_branch == "nobranch"
9281 echomsg "This probably happend while searching for \\input, it is not yet supported, if not it is a bug"
9284 silent! echomsg "Tree=" . string(l:tree)
9285 silent! echomsg "MainFile " . main_file . " current_file=" . expand("%:p")
9286 silent! echomsg "Going to file : " . g:ATP_branch . " ( g:ATP_branch ) "
9288 " restore the window and buffer!
9289 silent execute "keepjumps keepalt edit #" . a:bufnr
9290 call winrestview(a:winsaveview)
9295 let next_branch = atplib#FullPath(g:ATP_branch)
9296 let swapfile = globpath(fnamemodify(next_branch, ":h"), ( has("unix") ? "." : "" ) . fnamemodify(next_branch, ":t") . ".swp")
9297 if a:call_nr == 1 && a:wrap_nr == 1
9298 let open = 'silent edit +'.g:ATP_branch_line." ".next_branch
9300 let open = 'silent keepjumps keepalt edit +'.g:ATP_branch_line." ".next_branch
9303 if g:atp_debugRS >= 2
9304 silent echo "TIME ***goto DOWN before open*** " . reltimestr(reltime(time0))
9306 let projectVarDict = SaveProjectVariables()
9307 " let projectScript = SaveProjectVariables("g:atp_cached_local_variables")
9308 " let atp_ProjectScript = [ exists("g:atp_ProjectScript") ? g:atp_ProjectScript : b:atp_ProjectScript, exists("g:atp_ProjectScript") ]
9309 " let g:atp_ProjectScript = 0
9310 if empty(swapfile) || bufexists(next_branch)
9311 silent! execute open
9313 echoerr "Recursive Search: swap file: " . swapfile . " exists. Aborting."
9316 if g:atp_debugRS >= 2
9317 silent echo "TIME ***goto DOWN after open*** " . reltimestr(reltime(time0))
9319 " call RestoreProjectVariables(projectScript)
9320 " if atp_ProjectScript[1]
9321 " let g:atp_ProjectScript = atp_ProjectScript[0]
9323 " unlet g:atp_ProjectScript
9325 call RestoreProjectVariables(projectVarDict)
9326 if g:atp_debugRS >= 2
9327 silent echo "TIME ***goto DOWN restore project variables *** " . reltimestr(reltime(time0))
9330 " call cursor(g:ATP_branch_line, 1)
9331 if flags_supplied !~# 'b'
9332 keepjumps call search('\m\\input\s*{[^}]*}', 'e', line("."))
9336 silent echo "In lower branch: " . g:ATP_branch . " at line " . line(".") . ":" . col(".") . " branch_line=" . g:ATP_branch_line
9339 if g:atp_debugRS > 1
9340 silent echo "TIME_END:" . reltimestr(reltime(time0))
9344 unlet g:ATP_branch_line
9345 " let flag = flags_supplied =~ 'W' ? flags_supplied : flags_supplied . 'W'
9347 keepalt keepjumps call <SID>RecursiveSearch(main_file, a:start_file, "", expand("%:p"), a:call_nr+1, a:wrap_nr, a:winsaveview, a:bufnr, a:strftime, vim_options, cwd, pattern, flags_supplied)
9351 elseif goto_s == 'REJECT'
9353 echomsg "Pattern not found"
9356 if g:atp_debugRS > 1
9357 silent echo "TIME_END:" . reltimestr(reltime(time0))
9360 " restore the window and buffer!
9361 " it is better to remember bufnumber
9362 silent execute "keepjumps keepalt edit #" . a:bufnr
9363 call winrestview(a:winsaveview)
9370 " restore vim options
9371 if a:vim_options != { 'no_options' : 'no_options' }
9372 for option in keys(a:vim_options)
9373 execute "let &l:".option."=".a:vim_options[option]
9386 echomsg "This is a bug in ATP."
9389 " restore vim options
9390 if a:vim_options != { 'no_options' : 'no_options' }
9391 for option in keys(a:vim_options)
9392 execute "let &l:".option."=".a:vim_options[option]
9400 " restore the window and buffer!
9401 silent execute "keepjumps keepalt edit #" . a:bufnr
9402 call winrestview(a:winsaveview)
9411 " User interface to s:RecursiveSearch function.
9412 " s:GetSearchArgs {{{2
9413 " This functionn returns arguments from <q-args> - a list [ pattern, flag ]
9414 " It allows to pass arguments to s:Search in a similar way to :vimgrep, :ijump, ...
9415 function! s:GetSearchArgs(Arg,flags)
9417 let pattern = matchstr(a:Arg, '^\/\zs.*\ze\/')
9418 let flag = matchstr(a:Arg, '\/.*\/\s*\zs['.a:flags.']*\ze\s*$')
9419 elseif a:Arg =~ '^\i' && a:Arg !~ '^\w'
9420 let pattern = matchstr(a:Arg, '^\(\i\)\zs.*\ze\1')
9421 let flag = matchstr(a:Arg, '\(\i\).*\1\s*\zs['.a:flags.']*\ze\s*$')
9423 let pattern = matchstr(a:Arg, '^\zs\S*\ze')
9424 let flag = matchstr(a:Arg, '^\S*\s*\zs['.a:flags.']*\ze\s*$')
9426 return [ pattern, flag ]
9431 function! Search(Bang, Arg)
9433 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
9434 let [ pattern, flag ] = s:GetSearchArgs(a:Arg, 'bceswW')
9435 " echomsg " pattern " . pattern . " flag " . flag
9439 echomsg "Enclose the pattern with /.../"
9445 call <SID>RecursiveSearch(atp_MainFile, expand("%:p"), 'make_tree', expand("%:p"), 1, 1, winsaveview(), bufnr("%"), reltime(), { 'no_options' : 'no_options' }, 'no_cwd', pattern, flag)
9447 call <SID>RecursiveSearch(atp_MainFile, expand("%:p"), '', expand("%:p"), 1, 1, winsaveview(), bufnr("%"), reltime(), { 'no_options' : 'no_options' }, 'no_cwd', pattern, flag)
9451 catch /E127: Cannot redefine function/
9454 function! ATP_ToggleNn(...) " {{{2
9455 let on = ( a:0 >=1 ? ( a:1 == 'on' ? 1 : 0 ) : !g:atp_mapNn )
9458 silent! nunmap <buffer> n
9459 silent! nunmap <buffer> N
9460 silent! aunmenu LaTeX.Toggle\ Nn\ [on]
9462 nmenu 550.79 &LaTeX.Toggle\ &Nn\ [off]<Tab>:ToggleNn :ToggleNn<CR>
9463 imenu 550.79 &LaTeX.Toggle\ &Nn\ [off]<Tab>:ToggleNn <Esc>:ToggleNn<CR>a
9464 tmenu LaTeX.Toggle\ Nn\ [off] atp maps to n,N.
9465 echomsg "vim nN maps"
9467 silent! nmap <buffer> <silent> n <Plug>RecursiveSearchn
9468 silent! nmap <buffer> <silent> N <Plug>RecursiveSearchN
9469 silent! aunmenu LaTeX.Toggle\ Nn\ [off]
9471 nmenu 550.79 &LaTeX.Toggle\ &Nn\ [on]<Tab>:ToggleNn :ToggleNn<CR>
9472 imenu 550.79 &LaTeX.Toggle\ &Nn\ [on]<Tab>:ToggleNn <Esc>:ToggleNn<CR>a
9473 tmenu LaTeX.Toggle\ Nn\ [on] n,N vim normal commands.
9474 echomsg "atp nN maps"
9477 function! SearchHistCompletion(ArgLead, CmdLine, CursorPos)
9478 let search_history=[]
9479 let hist_entry = histget("search")
9481 while hist_entry != ""
9482 call add(search_history, hist_entry)
9484 let hist_entry = histget("search", nr)
9487 return filter(search_history, "v:val =~# '^'.a:ArgLead")
9491 " These are only variables and front end functions for Bib Search Engine of ATP.
9492 " Search engine is define in autoload/atplib.vim script library.
9494 "-------------SEARCH IN BIBFILES ----------------------
9495 " This function counts accurence of a:keyword in string a:line,
9496 " there are two methods keyword is a string to find (a:1=0)or a pattern to
9497 " match, the pattern used to is a:keyword\zs.* to find the place where to cut.
9499 " command -buffer -nargs=* Count :echo atplib#count(<args>)
9501 let g:bibentries=['article', 'book', 'booklet', 'conference', 'inbook', 'incollection', 'inproceedings', 'manual', 'mastertheosis', 'misc', 'phdthesis', 'proceedings', 'techreport', 'unpublished']
9505 let g:bibmatchgroup ='String'
9506 let g:defaultbibflags = 'tabejsyu'
9507 let g:defaultallbibflags = 'tabejfsvnyPNSohiuHcp'
9508 let b:lastbibflags = g:defaultbibflags " Set the lastflags variable to the default value on the startup.
9509 let g:bibflagsdict=atplib#bibflagsdict
9510 " These two variables were s:... but I switched to atplib ...
9511 let g:bibflagslist = keys(g:bibflagsdict)
9512 let g:bibflagsstring = join(g:bibflagslist,'')
9513 let g:kwflagsdict={ '@a' : '@article',
9514 \ '@b' : '@book\%(let\)\@<!',
9515 \ '@B' : '@booklet',
9516 \ '@c' : '@in\%(collection\|book\)',
9519 \ '@p' : '@\%(conference\)\|\%(\%(in\)\?proceedings\)',
9520 \ '@t' : '@\%(\%(master)\|\%(phd\)\)thesis',
9521 \ '@T' : '@techreport',
9522 \ '@u' : '@unpublished' }
9526 " Front End Function
9528 " There are three arguments: {pattern}, [flags, [choose]]
9529 function! BibSearch(bang,...)
9530 " let pattern = a:0 >= 1 ? a:1 : ""
9531 " let flag = a:0 >= 2 ? a:2 : ""
9534 let Arg = ( a:0 >= 1 ? a:1 : "" )
9537 let [ pattern, flag ] = s:GetSearchArgs(Arg, 'aetbjsynvpPNShouH@BcpmMtTulL')
9539 let [ pattern, flag ] = [ "", ""]
9542 let b:atp_LastBibPattern = pattern
9543 " This cannot be set here. It is set later by atplib#showresults function.
9544 " let b:atp_LastBibFlags = flag
9548 redir! >> /tmp/ATP_log
9549 silent! echo "==========BibSearch=========================="
9550 silent! echo "b:BibSearch_pattern=" . pattern
9551 silent! echo "b:BibSearch bang=" . a:bang
9552 silent! echo "b:BibSearch flag=" . flag
9553 let g:BibSearch_pattern = pattern
9554 let g:BibSearch_bang = a:bang
9555 let g:BibSearch_flag = flag
9559 call atplib#showresults( atplib#searchbib(pattern, a:bang), flag, pattern)
9561 nnoremap <silent> <Plug>BibSearchLast :call BibSearch("", b:atp_LastBibPattern, b:atp_LastBibFlags)<CR>
9566 command! -buffer -bang -complete=customlist,SearchHistCompletion -nargs=* S :call Search(<q-bang>, <q-args>) | let v:searchforward = ( s:GetSearchArgs(<q-args>, 'bceswW')[1] =~# 'b' ? 0 : 1 )
9567 nmap <buffer> <silent> <Plug>RecursiveSearchn :call <SID>RecursiveSearch(atplib#FullPath(b:atp_MainFile), expand("%:p"), '', expand("%:p"), 1, 1, winsaveview(), bufnr("%"), reltime(), { 'no_options' : 'no_options' }, 'no_cwd', @/, v:searchforward ? "" : "b") <CR>
9568 nmap <buffer> <silent> <Plug>RecursiveSearchN :call <SID>RecursiveSearch(atplib#FullPath(b:atp_MainFile), expand("%:p"), '', expand("%:p"), 1, 1, winsaveview(), bufnr("%"), reltime(), { 'no_options' : 'no_options' }, 'no_cwd', @/, !v:searchforward ? "" : "b") <CR>
9571 " These two maps behaves now like n (N): after forward search n (N) acts as forward (backward), after
9572 " backward search n acts as backward (forward, respectively).
9574 nmap <buffer> <silent> n <Plug>RecursiveSearchn
9575 nmap <buffer> <silent> N <Plug>RecursiveSearchN
9577 " Note: the final step if the mapps n and N are made is in s:LoadHistory
9580 command! -buffer -bang LocalCommands :call LocalCommands("",<q-bang>)
9581 command! -buffer -bang -nargs=* DefiSearch :call DefiSearch(<q-bang>, <q-args>)
9582 command! -buffer -nargs=? -complete=customlist,atplib#OnOffComp ToggleNn :call ATP_ToggleNn(<f-args>)
9583 command! -buffer -bang -nargs=* BibSearch :call BibSearch(<q-bang>, <q-args>)
9586 hi link BibResultsFileNames Title
9587 hi link BibResultEntry ModeMsg
9588 hi link BibResultsMatch WarningMsg
9589 hi link BibResultsGeneral Normal
9591 hi link Chapter Normal
9592 hi link Section Normal
9593 hi link Subsection Normal
9594 hi link Subsubsection Normal
9595 hi link CurrentSection WarningMsg
9597 " vim:fdm=marker:tw=85:ff=unix:noet:ts=8:sw=4:fdc=1
9598 ftplugin/ATP_files/various.vim [[[1
9600 " Author: Marcin Szamotulski
9601 " Descriptiion: These are various editting tools used in ATP.
9602 " Note: This file is a part of Automatic Tex Plugin for Vim.
9603 " URL: https://launchpad.net/automatictexplugin
9606 let s:sourced = exists("s:sourced") ? 1 : 0
9608 " Functions: (source once)
9610 " This is the wrap selection function.
9612 function! s:WrapSelection(wrapper,...)
9614 let l:end_wrapper = ( a:0 >= 1 ? a:1 : '}' )
9615 let l:cursor_pos = ( a:0 >= 2 ? a:2 : 'end' )
9616 let l:new_line = ( a:0 >= 3 ? a:3 : 0 )
9618 " let b:new_line=l:new_line
9619 " let b:cursor_pos=l:cursor_pos
9620 " let b:end_wrapper=l:end_wrapper
9622 let l:begin=getpos("'<")
9623 " todo: if and on 'Ä…' we should go one character further! (this is
9624 " a multibyte character)
9625 let l:end=getpos("'>")
9626 let l:pos_save=getpos(".")
9629 let l:pos=deepcopy(l:end)
9630 keepjumps call setpos(".",l:end)
9632 let l:pos_new=getpos(".")
9633 if l:pos_new[2]-l:pos[2] > 1
9634 let l:end[2]+=l:pos_new[2]-l:pos[2]-1
9637 let l:begin_line=getline(l:begin[1])
9638 let l:end_line=getline(l:end[1])
9640 let b:begin=l:begin[1]
9643 " ToDo: this doesn't work yet!
9644 let l:add_indent=' '
9645 if l:begin[1] != l:end[1]
9646 let l:bbegin_line=strpart(l:begin_line,0,l:begin[2]-1)
9647 let l:ebegin_line=strpart(l:begin_line,l:begin[2]-1)
9650 let b:bbegin_line=l:bbegin_line
9651 let b:ebegin_line=l:ebegin_line
9653 let l:bend_line=strpart(l:end_line,0,l:end[2])
9654 let l:eend_line=strpart(l:end_line,l:end[2])
9659 let l:begin_line=l:bbegin_line.a:wrapper.l:ebegin_line
9660 let l:end_line=l:bend_line.l:end_wrapper.l:eend_line
9661 call setline(l:begin[1],l:begin_line)
9662 call setline(l:end[1],l:end_line)
9663 let l:end[2]+=len(l:end_wrapper)
9667 let l:indent=atplib#CopyIndentation(l:begin_line)
9668 if l:bbegin_line !~ '^\s*$'
9669 let l:begin_choice=1
9670 call setline(l:begin[1],l:bbegin_line)
9671 call append(l:begin[1],l:indent.a:wrapper) " THERE IS AN ISSUE HERE!
9672 call append(copy(l:begin[1])+1,l:indent.substitute(l:ebegin_line,'^\s*','',''))
9674 elseif l:bbegin_line =~ '^\s\+$'
9675 let l:begin_choice=2
9676 call append(l:begin[1]-1,l:indent.a:wrapper)
9677 call append(l:begin[1],l:begin_line.l:ebegin_line)
9680 let l:begin_choice=3
9681 call append(copy(l:begin[1])-1,l:indent.a:wrapper)
9684 if l:eend_line !~ '^\s*$'
9686 call setline(l:end[1],l:bend_line)
9687 call append(l:end[1],l:indent.l:end_wrapper)
9688 call append(copy(l:end[1])+1,l:indent.substitute(l:eend_line,'^\s*','',''))
9691 call append(l:end[1],l:indent.l:end_wrapper)
9693 if (l:end[1] - l:begin[1]) >= 0
9694 if l:begin_choice == 1
9696 elseif l:begin_choice == 2
9698 elseif l:begin_choice == 3
9701 if l:end_choice == 5
9702 let j=l:end[1]-l:begin[1]+1
9704 let j=l:end[1]-l:begin[1]+1
9707 " Adding indentation doesn't work in this simple way here?
9708 " but the result is ok.
9709 call setline(l:begin[1]+i,l:indent.l:add_indent.getline(l:begin[1]+i))
9717 let l:begin_l=strpart(l:begin_line,0,l:begin[2]-1)
9718 let l:middle_l=strpart(l:begin_line,l:begin[2]-1,l:end[2]-l:begin[2]+1)
9719 let l:end_l=strpart(l:begin_line,l:end[2])
9722 let l:line=l:begin_l.a:wrapper.l:middle_l.l:end_wrapper.l:end_l
9723 call setline(l:begin[1],l:line)
9724 let l:end[2]+=len(a:wrapper)+1
9727 let b:begin_l=l:begin_l
9728 let b:middle_l=l:middle_l
9731 let l:indent=atplib#CopyIndentation(l:begin_line)
9733 if l:begin_l =~ '\S'
9734 call setline(l:begin[1],l:begin_l)
9735 call append(copy(l:begin[1]),l:indent.a:wrapper)
9736 call append(copy(l:begin[1])+1,l:indent.l:add_indent.l:middle_l)
9737 call append(copy(l:begin[1])+2,l:indent.l:end_wrapper)
9738 if substitute(l:end_l,'^\s*','','') =~ '\S'
9739 call append(copy(l:begin[1])+3,l:indent.substitute(l:end_l,'^\s*','',''))
9742 call setline(copy(l:begin[1]),l:indent.a:wrapper)
9743 call append(copy(l:begin[1]),l:indent.l:add_indent.l:middle_l)
9744 call append(copy(l:begin[1])+1,l:indent.l:end_wrapper)
9745 if substitute(l:end_l,'^\s*','','') =~ '\S'
9746 call append(copy(l:begin[1])+2,l:indent.substitute(l:end_l,'^\s*','',''))
9751 if l:cursor_pos == "end"
9752 let l:end[2]+=len(l:end_wrapper)-1
9753 call setpos(".",l:end)
9754 elseif l:cursor_pos =~ '\d\+'
9756 let l:pos[2]+=l:cursor_pos
9757 call setpos(".",l:pos)
9758 elseif l:cursor_pos == "current"
9759 keepjumps call setpos(".",l:pos_save)
9760 elseif l:cursor_pos == "begin"
9761 let l:begin[2]+=len(a:wrapper)-1
9762 keepjumps call setpos(".",l:begin)
9766 "{{{ Inteligent Wrap Selection
9767 " This function selects the correct font wrapper for math/text environment.
9768 " the rest of arguments are the same as for WrapSelection (and are passed to
9769 " WrapSelection function)
9770 " a:text_wrapper = [ 'begin_text_wrapper', 'end_text_wrapper' ]
9771 " a:math_wrapper = [ 'begin_math_wrapper', 'end_math_wrapper' ]
9772 " if end_(math\|text)_wrapper is not given '}' is used (but neverthe less both
9773 " arguments must be lists).
9774 function! s:InteligentWrapSelection(text_wrapper, math_wrapper, ...)
9776 let cursor_pos = ( a:0 >= 1 ? a:2 : 'end' )
9777 let new_line = ( a:0 >= 2 ? a:3 : 0 )
9779 let MathZones = copy(g:atp_MathZones)
9780 let pattern = '^texMathZone[VWX]'
9781 if b:atp_TexFlavor == 'plaintex'
9782 call add(MathZones, 'texMathZoneY')
9783 let pattern = '^texMathZone[VWXY]'
9786 " select the correct wrapper
9788 let MathZone = get(filter(map(synstack(line("."),max([1,col(".")-1])),"synIDattr(v:val,'name')"),"v:val=~pattern"),0,"")
9789 if MathZone =~ '^texMathZone[VWY]'
9791 elseif MathZone == 'texMathZoneX'
9797 " Note: in visual mode col(".") returns always the column starting position of
9798 " the visual area, thus it is enough to check the begining (if we stand on
9799 " $:\(:\[:$$ use text wrapper).
9800 if !empty(MathZone) && col(".") > step && atplib#CheckSyntaxGroups(MathZones, line("."), max([1, col(".")-step]))
9801 let begin_wrapper = a:math_wrapper[0]
9802 let end_wrapper = get(a:math_wrapper,1, '}')
9804 let begin_wrapper = a:text_wrapper[0]
9805 let end_wrapper = get(a:text_wrapper,1, '}')
9808 " if the wrapper is empty return
9809 " useful for wrappers which are valid only in one mode.
9810 if begin_wrapper == ""
9814 call s:WrapSelection(begin_wrapper, end_wrapper, cursor_pos, new_line)
9820 " This needs Aling vim plugin.
9821 function! TexAlign()
9822 let save_pos = getpos(".")
9823 let synstack = map(synstack(line("."), col(".")), 'synIDattr( v:val, "name")')
9824 if count(synstack, 'texMathZoneA') || count(synstack, 'texMathZoneAS')
9825 let bpat = '\\begin\s*{\s*align\*\=\s*}'
9826 let epat = '\\end\s*{\s*align\*\=\s*}'
9827 let AlignCtr = 'Il+ &'
9828 " let g:debug = "align"
9829 elseif count(synstack, 'texMathZoneB') || count(synstack, 'texMathZoneBS')
9830 let bpat = '\\begin\s*{\s*alignat\*\=\s*}'
9831 let epat = '\\end\s*{\s*alignat\*\=\s*}'
9832 let AlignCtr = 'Il+ &'
9833 " let g:debug = "alignat"
9834 elseif count(synstack, 'texMathZoneD') || count(synstack, 'texMathZoneDS')
9835 let bpat = '\\begin\s*{\s*eqnarray\*\=\s*}'
9836 let epat = '\\end\s*{\s*eqnarray\*\=\s*}'
9837 let AlignCtr = 'Il+ &'
9838 " let g:debug = "eqnarray"
9839 elseif count(synstack, 'texMathZoneE') || count(synstack, 'texMathZoneES')
9840 let bpat = '\\begin\s*{\s*equation\*\=\s*}'
9841 let epat = '\\end\s*{\s*equation\*\=\s*}'
9842 let AlignCtr = 'Il+ =+-'
9843 " let g:debug = "equation"
9844 elseif count(synstack, 'texMathZoneF') || count(synstack, 'texMathZoneFS')
9845 let bpat = '\\begin\s*{\s*flalign\*\=\s*}'
9846 let epat = '\\end\s*{\s*flalign\*\=\s*}'
9847 let AlignCtr = 'jl+ &'
9848 " let g:debug = "falign"
9849 " elseif count(synstack, 'texMathZoneG') || count(synstack, 'texMathZoneGS')
9850 " gather doesn't need alignment (by design it give unaligned equation.
9851 " let bpat = '\\begin\s*{\s*gather\*\=\s*}'
9852 " let epat = '\\end\s*{\s*gather\*\=\s*}'
9853 " let AlignCtr = 'Il+ &'
9854 " let g:debug = "gather"
9855 elseif count(synstack, 'displaymath')
9856 let bpat = '\\begin\s*{\s*displaymath\*\=\s*}'
9857 let epat = '\\end\s*{\s*displaymath\*\=\s*}'
9858 let AlignCtr = 'Il+ =+-'
9859 " let g:debug = "displaymath"
9860 elseif searchpair('\\begin\s*{\s*tabular\s*\}', '', '\\end\s*{\s*tabular\s*}', 'bnW', '', max([1, (line(".")-g:atp_completion_limits[2])]))
9861 let bpat = '\\begin\s*{\s*tabular\*\=\s*}'
9862 let epat = '\\end\s*{\s*tabular\*\=\s*}'
9863 let AlignCtr = 'jl+ &'
9864 " let g:debug = "tabular"
9869 " Check if we are inside array environment
9870 let align = searchpair('\\begin\s*{\s*array\s*}', '', '\\end\s*{\s*array\s*}', 'bnW')
9872 " let bpat = '\\begin\s*{\s*array\s*}'
9873 let bline = align + 1
9874 let epat = '\\end\s*{\s*array\s*}'
9875 let AlignCtr = 'Il+ &'
9878 " let g:AlignCtr = AlignCtr
9881 let bline = search(bpat, 'cnb') + 1
9883 let eline = search(epat, 'cn') - 1
9885 " let g:bline = bline
9886 " let g:eline = eline
9889 execute bline . ',' . eline . 'Align ' . AlignCtr
9892 call setpos(".", save_pos)
9896 " Insert() function, which is used to insert text depending on mode: text/math.
9898 " Should be called via an imap:
9899 " imap <lhs> <Esc>:call Insert(text, math)<CR>a
9900 " a:text = text to insert in text mode
9901 " a:math = text to insert in math mode
9902 function! Insert(text, math)
9904 let MathZones = copy(g:atp_MathZones)
9905 if b:atp_TexFlavor == 'plaintex'
9906 call add(MathZones, 'texMathZoneY')
9909 " select the correct wrapper
9910 if atplib#CheckSyntaxGroups(MathZones, line("."), col("."))
9916 " if the insert variable is empty return
9921 let line = getline(".")
9924 let new_line = strpart(line, 0, col) . insert . strpart(line, col)
9925 call setline(line("."), new_line)
9926 call cursor(line("."), col(".")+len(insert))
9930 " Insert \item update the number.
9933 function! InsertItem()
9934 let begin_line = searchpair( '\\begin\s*{\s*\%(enumerate\|itemize\)\s*}', '', '\\end\s*{\s*\%(enumerate\|itemize\)\s*}', 'bnW')
9935 let saved_pos = getpos(".")
9936 call cursor(line("."), 1)
9938 " This will work with \item [[1]], but not with \item [1]]
9939 let [ bline, bcol] = searchpos('\\item\s*\zs\[', 'b', begin_line)
9941 keepjumps call setpos(".", saved_pos)
9942 let new_line = strpart(getline("."), 0, col(".")) . '\item'. strpart(getline("."), col("."))
9943 call setline(line("."), new_line)
9946 if &l:indentexpr != ""
9947 execute "let indent = " . &l:indentexpr
9956 ind = matchstr(getline("."), '^\s*')
9958 call setline(line("."), ind . substitute(getline("."), '^\s*', '', ''))
9960 " Set the cursor position
9961 let saved_pos[2] += len('\item') + indent
9962 keepjumps call setpos(".", saved_pos)
9966 let [ eline, ecol] = searchpairpos('\[', '', '\]', 'nr', '', line("."))
9971 let item = strpart(getline("."), bcol, ecol - bcol - 1)
9972 let bpat = '(\|{\|\['
9973 let epat = ')\|}\|\]\|\.'
9974 let number = matchstr(item, '\d\+')
9975 let subNr = matchstr(item, '\d\+\zs\a\ze')
9976 let space = matchstr(getline("."), '\\item\zs\s*\ze\[')
9977 if nr2char(number) != "" && subNr == ""
9978 let new_item = substitute(item, number, number + 1, '')
9979 elseif nr2char(number) != "" && subNr != ""
9980 let alphabet = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'w', 'x', 'y', 'z' ]
9981 let char = matchstr(item, '^\%('.bpat.'\)\=\s*\d\+\zs\a\ze\s*\%('.epat.'\)\=$')
9982 let new_char = get(alphabet, index(alphabet, char) + 1, 'z')
9983 let new_item = substitute(item, '^\%('.bpat.'\)\=\s*\d\+\zs\a\ze\s*\%('.epat.'\)\=$', new_char, 'g')
9984 elseif item =~ '\%('.bpat.'\)\=\s*\w\s*\%('.epat.'\)\='
9985 let alphabet = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'w', 'x', 'y', 'z' ]
9986 let char = matchstr(item, '^\%('.bpat.'\)\=\s*\zs\w\ze\s*\%('.epat.'\)\=$')
9987 let new_char = get(alphabet, index(alphabet, char) + 1, 'z')
9988 let new_item = substitute(item, '^\%('.bpat.'\)\=\s*\zs\w\ze\s*\%('.epat.'\)\=$', new_char, 'g')
9993 keepjumps call setpos(".", saved_pos)
9995 let new_line = strpart(getline("."), 0, col(".")) . '\item' . space . '[' . new_item . ']' . strpart(getline("."), col("."))
9996 call setline(line("."), new_line)
9999 if &l:indentexpr != ""
10000 execute "let indent = " . &l:indentexpr
10008 ind = matchstr(getline("."), '^\s*')
10010 call setline(line("."), ind . substitute(getline("."), '^\s*', '', ''))
10012 " Set the cursor position
10013 let saved_pos[2] += len('\item' . space . '[' . new_item . ']') + indent
10014 keepjumps call setpos(".", saved_pos)
10021 " Editing Toggle Functions
10023 if !exists("g:atp_no_toggle_environments")
10024 let g:atp_no_toggle_environments=[ 'document', 'tikzpicture', 'picture']
10026 if !exists("g:atp_toggle_environment_1")
10027 let g:atp_toggle_environment_1=[ 'center', 'flushleft', 'flushright', 'minipage' ]
10029 if !exists("g:atp_toggle_environment_2")
10030 let g:atp_toggle_environment_2=[ 'enumerate', 'itemize', 'list', 'description' ]
10032 if !exists("g:atp_toggle_environment_3")
10033 let g:atp_toggle_environment_3=[ 'quotation', 'quote', 'verse' ]
10035 if !exists("g:atp_toggle_environment_4")
10036 let g:atp_toggle_environment_4=[ 'theorem', 'proposition', 'lemma' ]
10038 if !exists("g:atp_toggle_environment_5")
10039 let g:atp_toggle_environment_5=[ 'corollary', 'remark', 'note' ]
10041 if !exists("g:atp_toggle_environment_6")
10042 let g:atp_toggle_environment_6=[ 'equation', 'align', 'array', 'alignat', 'gather', 'flalign', 'multline' ]
10044 if !exists("g:atp_toggle_environment_7")
10045 let g:atp_toggle_environment_7=[ 'smallmatrix', 'pmatrix', 'bmatrix', 'Bmatrix', 'vmatrix' ]
10047 if !exists("g:atp_toggle_environment_8")
10048 let g:atp_toggle_environment_8=[ 'tabbing', 'tabular']
10050 if !exists("g:atp_toggle_labels")
10051 let g:atp_toggle_labels=1
10055 " this function adds a star to the current environment
10057 function! s:ToggleStar()
10060 let l:from_line=max([1,line(".")-g:atp_completion_limits[2]])
10061 let l:to_line=line(".")+g:atp_completion_limits[2]
10064 let l:omit=join(g:atp_no_star_environments,'\|')
10065 let l:open_pos=searchpairpos('\\begin\s*{','','\\end\s*{[^}]*}\zs','cbnW','getline(".") =~ "\\\\begin\\s*{".l:omit."}"',l:from_line)
10066 let b:open_pos=l:open_pos
10067 let l:env_name=matchstr(strpart(getline(l:open_pos[0]),l:open_pos[1]),'begin\s*{\zs[^}]*\ze}')
10068 let b:env_name=l:env_name
10069 if l:open_pos == [0, 0] || index(g:atp_no_star_environments,l:env_name) != -1
10072 if l:env_name =~ '\*$'
10073 let l:env_name=substitute(l:env_name,'\*$','','')
10074 let l:close_pos=searchpairpos('\\begin\s*{'.l:env_name.'\*}','','\\end\s*{'.l:env_name.'\*}\zs','cnW',"",l:to_line)
10075 if l:close_pos != [0, 0]
10076 call setline(l:open_pos[0],substitute(getline(l:open_pos[0]),'\(\\begin\s*{\)'.l:env_name.'\*}','\1'.l:env_name.'}',''))
10077 call setline(l:close_pos[0],substitute(getline(l:close_pos[0]),
10078 \ '\(\\end\s*{\)'.l:env_name.'\*}','\1'.l:env_name.'}',''))
10079 echomsg "Star removed from '".l:env_name."*' at lines: " .l:open_pos[0]." and ".l:close_pos[0]
10082 let l:close_pos=searchpairpos('\\begin\s{'.l:env_name.'}','','\\end\s*{'.l:env_name.'}\zs','cnW',"",l:to_line)
10083 if l:close_pos != [0, 0]
10084 call setline(l:open_pos[0],substitute(getline(l:open_pos[0]),
10085 \ '\(\\begin\s*{\)'.l:env_name.'}','\1'.l:env_name.'\*}',''))
10086 call setline(l:close_pos[0],substitute(getline(l:close_pos[0]),
10087 \ '\(\\end\s*{\)'.l:env_name.'}','\1'.l:env_name.'\*}',''))
10088 echomsg "Star added to '".l:env_name."' at lines: " .l:open_pos[0]." and ".l:close_pos[0]
10093 "{{{ ToggleEnvironment
10094 " this function toggles envrionment name.
10096 " a:ask = 0 toggle, 1 ask for the new env name if not given as the first argument.
10097 " the argument specifies the speed (if -1 then toggle back)
10098 " default is '1' or the new environment name
10100 function! s:ToggleEnvironment(ask, ...)
10102 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
10103 let l:add = ( a:0 >= 1 ? a:1 : 1 )
10106 let l:from_line=max([1,line(".")-g:atp_completion_limits[2]])
10107 let l:to_line=line(".")+g:atp_completion_limits[2]
10110 let l:omit=join(g:atp_no_toggle_environments,'\|')
10111 let l:open_pos=searchpairpos('\\begin\s*{','','\\end\s*{[^}]*}\zs','bnW','getline(".") =~ "\\\\begin\\s*{".l:omit."}"',l:from_line)
10112 let l:env_name=matchstr(strpart(getline(l:open_pos[0]),l:open_pos[1]),'begin\s*{\zs[^}]*\ze}')
10114 let l:label=matchstr(strpart(getline(l:open_pos[0]),l:open_pos[1]),'\\label\s*{\zs[^}]*\ze}')
10116 " let b:line=strpart(getline(l:open_pos[0]),l:open_pos[1])
10117 " let b:label=l:label
10118 " let b:env_name=l:env_name
10119 if l:open_pos == [0, 0] || index(g:atp_no_toggle_environments,l:env_name) != -1
10123 let l:env_name_ws=substitute(l:env_name,'\*$','','')
10126 let l:variable="g:atp_toggle_environment_1"
10129 let l:env_idx=index({l:variable},l:env_name_ws)
10134 let l:variable="g:atp_toggle_environment_".l:i
10136 if !exists(l:variable)
10141 if l:add > 0 && l:env_idx > len({l:variable})-l:add-1
10143 elseif ( l:add < 0 && l:env_idx < -1*l:add )
10144 let l:env_idx=len({l:variable})-1
10146 let l:env_idx+=l:add
10148 let l:new_env_name={l:variable}[l:env_idx]
10149 if l:env_name =~ '\*$'
10150 let l:new_env_name.="*"
10154 let l:new_env_name=input("What is the new name for " . l:env_name . "? type and hit <Enter> ")
10155 if l:new_env_name == ""
10156 echomsg "Environment name not changed"
10160 let l:new_env_name = l:add
10166 " let g:env_idx=l:env_idx
10167 " let g:env_name=l:env_name
10168 " let g:add = l:add
10169 " let g:new_env_name=l:new_env_name
10171 let l:env_name=escape(l:env_name,'*')
10172 let l:close_pos=searchpairpos('\\begin\s*{'.l:env_name.'}','','\\end\s*{'.l:env_name.'}\zs','nW',"",l:to_line)
10173 if l:close_pos != [0, 0]
10174 call setline(l:open_pos[0],substitute(getline(l:open_pos[0]),'\(\\begin\s*{\)'.l:env_name.'}','\1'.l:new_env_name.'}',''))
10175 call setline(l:close_pos[0],substitute(getline(l:close_pos[0]),
10176 \ '\(\\end\s*{\)'.l:env_name.'}','\1'.l:new_env_name.'}',''))
10177 echomsg "Environment toggeled at lines: " .l:open_pos[0]." and ".l:close_pos[0]
10180 if l:label != "" && g:atp_toggle_labels
10181 if l:env_name == ""
10182 let l:new_env_name_ws=substitute(l:new_env_name,'\*$','','')
10183 let l:new_short_name=get(g:atp_shortname_dict,l:new_env_name_ws,"")
10184 let l:new_label = l:new_short_name . strpart(l:label, stridx(l:label, g:atp_separator))
10185 " let g:new_label = l:new_label . "XXX"
10187 " let g:label = l:label
10188 let l:new_env_name_ws=substitute(l:new_env_name,'\*$','','')
10189 " let g:new_env_name_ws=l:new_env_name_ws
10190 let l:new_short_name=get(g:atp_shortname_dict,l:new_env_name_ws,"")
10191 " let g:new_short_name=l:new_short_name
10192 let l:short_pattern= '^\(\ze:\|' . join(values(filter(g:atp_shortname_dict,'v:val != ""')),'\|') . '\)'
10193 " let g:short_pattern=l:short_pattern
10194 let l:short_name=matchstr(l:label, l:short_pattern)
10195 " let g:short_name=l:short_name
10196 let l:new_label=substitute(l:label,'^'.l:short_name,l:new_short_name,'')
10197 " let g:new_label=l:new_label
10201 " check if new label is in use!
10202 let pos_save=getpos(".")
10203 let n=search('\m\C\\\(label\|\%(eq\|page\)\?ref\)\s*{'.l:new_label.'}','nwc')
10205 if n == 0 && l:new_label != l:label
10206 let hidden = &hidden
10208 silent! keepjumps execute l:open_pos[0].'substitute /\\label{'.l:label.'}/\\label{'.l:new_label.'}'
10209 " This should be done for every file in the project.
10210 if !exists("b:TypeDict")
10211 call TreeOfFiles(atp_MainFile)
10213 let save_view = winsaveview()
10214 let file = expand("%:p")
10215 for project_file in keys(filter(b:TypeDict, "v:val == 'input'")) + [ atp_MainFile ]
10216 exe "keepalt edit " . project_file
10217 " echo " IN FILE : " . expand("%")
10218 let pos_save_pf=getpos(".")
10219 silent! keepjumps execute '%substitute /\\\(eq\|page\)\?\(ref\s*\){'.l:label.'}/\\\1\2{'.l:new_label.'}/gIe'
10220 keepjumps call setpos(".", pos_save_pf)
10222 execute "keepalt buffer " . file
10223 keepjumps call setpos(".", pos_save)
10224 let &hidden = hidden
10225 elseif n != 0 && l:new_label != l:label
10227 echomsg "Labels not changed, new label: ".l:new_label." is in use!"
10231 return l:open_pos[0]."-".l:close_pos[0]
10235 " TexDoc commanand and its completion
10237 " This is non interactive !, use :!texdoc for interactive command.
10238 " But it simulates it with a nice command completion (Ctrl-D, <Tab>)
10239 " based on alias files for texdoc.
10240 function! s:TexDoc(...)
10241 let texdoc_arg = ""
10242 for i in range(1,a:0)
10243 let texdoc_arg.=" " . a:{i}
10245 if texdoc_arg == ""
10246 let texdoc_arg = "-m " . g:atp_TeXdocDefault
10248 " If the file is a text file texdoc is 'cat'-ing it into the terminal,
10249 " we use echo to capture the output.
10250 " The rediraction prevents showing texdoc info messages which are not that
10251 " important, if a document is not found texdoc sends a message to the standard
10252 " output not the error.
10254 " -I prevents from using interactive menus
10255 echo system("texdoc " . texdoc_arg . " 2>/dev/null")
10258 function! s:TeXdoc_complete(ArgLead, CmdLine, CursorPos)
10259 let texdoc_alias_files=split(system("texdoc -f"), '\n')
10260 call filter(texdoc_alias_files, "v:val =~ 'active'")
10261 call map(texdoc_alias_files, "substitute(substitute(v:val, '^[^/]*\\ze', '', ''), '\/\/\\+', '/', 'g')")
10263 for file in texdoc_alias_files
10264 call extend(aliases, readfile(file))
10267 call filter(aliases, "v:val =~ 'alias'")
10268 call filter(map(aliases, "matchstr(v:val, '^\\s*alias\\s*\\zs\\S*\\ze\\s*=')"),"v:val !~ '^\\s*$'")
10270 return filter(copy(aliases), "v:val =~ '^' . a:ArgLead")
10274 " This function deletes tex specific output files (exept the pdf/dvi file, unless
10275 " bang is used - then also delets the current output file)
10277 function! s:Delete(delete_output)
10279 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
10280 call atplib#outdir()
10282 let l:atp_tex_extensions=deepcopy(g:atp_tex_extensions)
10285 if a:delete_output == "!"
10286 if b:atp_TexCompiler == "pdftex" || b:atp_TexCompiler == "pdflatex"
10291 call add(l:atp_tex_extensions,l:ext)
10294 for l:ext in l:atp_tex_extensions
10295 if executable(g:rmcommand)
10296 if g:rmcommand =~ "^\s*rm\p*" || g:rmcommand =~ "^\s*perltrash\p*"
10297 if l:ext != "dvi" && l:ext != "pdf"
10298 let l:rm=g:rmcommand . " " . shellescape(b:atp_OutDir) . "*." . l:ext . " 2>/dev/null && echo Removed: ./*" . l:ext
10300 let l:rm=g:rmcommand . " " . fnamemodify(atp_MainFile,":r").".".l:ext . " 2>/dev/null && echo Removed: " . fnamemodify(atp_MainFile,":r").".".l:ext
10306 call add(g:rm, l:rm)
10311 let l:file=b:atp_OutDir . fnamemodify(expand("%"),":t:r") . "." . l:ext
10312 if delete(l:file) == 0
10313 echo "Removed " . l:file
10319 " echo "Please set g:rmcommand to clear the working directory"
10324 "{{{ OpenLog, TexLog, TexLog Buffer Options, PdfFonts, YesNoCompletion
10325 "{{{ s:Search function for Log Buffer
10326 function! <SID>Search(pattern, flag, ...)
10328 let center = ( a:0 >= 1 ? a:1 : 1 )
10333 " while nr <= a:count
10334 " let keepjumps = ( a:nr < a:count ? 'keepjumps' : '')
10335 " exe keepjumps . "let line = search(a:pattern, a:flag)"
10339 let line = search(a:pattern, a:flag)
10342 let message = a:flag =~# 'b' ? 'previous' : 'next'
10343 if a:pattern =~ 'warning'
10344 let type = 'warning'
10345 elseif a:pattern =~ '\^!'
10347 elseif a:pattern =~ 'info'
10353 echo "No " . message . " " . type . " message."
10361 " command! -count=1 -nargs=* <SID>Search :call <SID>Search(<count>,<args>)
10363 function! <SID>Searchpair(start, middle, end, flag, ...)
10364 let center = ( a:0 >= 1 ? a:1 : 1 )
10365 if getline(".")[col(".")-1] == ')'
10366 let flag= a:flag.'b'
10368 let flag= substitute(a:flag, 'b', '', 'g')
10370 call searchpair(a:start, a:middle, a:end, flag)
10376 function! s:OpenLog()
10377 if filereadable(&l:errorfile)
10379 let projectVarDict = SaveProjectVariables()
10380 let g:projectVarDict = projectVarDict
10381 let s:winnr = bufwinnr("")
10382 exe "rightbelow split +setl\\ nospell\\ ruler\\ syn=log_atp\\ autoread " . fnameescape(&l:errorfile)
10383 call RestoreProjectVariables(projectVarDict)
10385 map <buffer> q :bd!<CR>
10386 nnoremap <silent> <buffer> ]m :call <SID>Search('\CWarning\\|^!', 'W')<CR>
10387 nnoremap <silent> <buffer> [m :call <SID>Search('\CWarning\\|^!', 'bW')<CR>
10388 nnoremap <silent> <buffer> ]w :call <SID>Search('\CWarning', 'W')<CR>
10389 nnoremap <silent> <buffer> [w :call <SID>Search('\CWarning', 'bW')<CR>
10390 nnoremap <silent> <buffer> ]c :call <SID>Search('\CLaTeX Warning: Citation', 'W')<CR>
10391 nnoremap <silent> <buffer> [c :call <SID>Search('\CLaTeX Warning: Citation', 'bW')<CR>
10392 nnoremap <silent> <buffer> ]r :call <SID>Search('\CLaTeX Warning: Reference', 'W')<CR>
10393 nnoremap <silent> <buffer> [r :call <SID>Search('\CLaTeX Warning: Reference', 'bW')<CR>
10394 nnoremap <silent> <buffer> ]e :call <SID>Search('^!', 'W')<CR>
10395 nnoremap <silent> <buffer> [e :call <SID>Search('^!', 'bW')<CR>
10396 nnoremap <silent> <buffer> ]f :call <SID>Search('\CFont \%(Info\\|Warning\)', 'W')<CR>
10397 nnoremap <silent> <buffer> [f :call <SID>Search('\CFont \%(Info\\|Warning\)', 'bW')<CR>
10398 nnoremap <silent> <buffer> ]p :call <SID>Search('\CPackage', 'W')<CR>
10399 nnoremap <silent> <buffer> [p :call <SID>Search('\CPackage', 'bW')<CR>
10400 nnoremap <silent> <buffer> ]P :call <SID>Search('\[\_d\+\zs', 'W')<CR>
10401 nnoremap <silent> <buffer> [P :call <SID>Search('\[\_d\+\zs', 'bW')<CR>
10402 nnoremap <silent> <buffer> ]i :call <SID>Search('\CInfo', 'W')<CR>
10403 nnoremap <silent> <buffer> [i :call <SID>Search('\CInfo', 'bW')<CR>
10404 nnoremap <silent> <buffer> % :call <SID>Searchpair('(', '', ')', 'W')<CR>
10406 " This prevents vim from reloading with 'autoread' option: the buffer is
10407 " modified outside and inside vim.
10409 silent! execute 'keepjumps %g/^\s*$/d'
10410 silent! execute "keepjumps normal ''"
10414 function! <SID>SyncTex(bang,...)
10417 exe "lcd " . b:atp_ProjectDir
10421 " if sync = 1 sync log file and the window - can be used by autocommand
10422 let sync = ( a:0 >= 1 ? a:1 : 0 )
10427 if sync && !g:atp_SyncLog
10428 exe "normal! " . cwd
10433 " Find the end pos of error msg
10434 keepjumps let [ stopline, stopcol ] = searchpairpos('(', '', ')', 'nW')
10436 let g:stopline = stopline
10439 let saved_pos = getpos(".")
10442 call setpos(".", [0, line("."), 1, 0])
10445 " keepjumps let [ LineNr, ColNr ] = searchpos('^l.\zs\d\+\>\|oninput line \zs\|at lines \zs', 'W', stopline)
10446 keepjumps let [ LineNr, ColNr ] = searchpos('^l.\zs\d\+\>\|o\n\=n\_s\+i\n\=n\n\=p\n\=u\n\=t\_s\+l\n\=i\n\=n\n\=e\_s\+\zs\|a\n\=t\_s\+l\n\=i\n\=n\n\=e\n\=s\_s\+\zs', 'W', stopline)
10447 let line = strpart(getline(LineNr), ColNr-1)
10448 let lineNr = matchstr(line, '^\d\+\ze')
10449 let g:lineNr=lineNr
10450 if lineNr !~ '\d\+'
10451 keepjumps call setpos(".", saved_pos)
10454 if getline(LineNr) =~ '^l\.\d\+'
10455 let error = escape(matchstr(getline(LineNr), '^l\.\d\+\s*\zs.*$'), '\.')
10456 " let error = escape(matchstr(getline(LineNr), '^l\.\d\+\s*\zs.*$'), '\.') . '\s*' . escape(substitute(strpart(getline(LineNr+1), 0, stridx(getline(LineNr+1), '...')), '^\s*', '', ''), '\.')
10458 let g:error = error
10462 " Find the file name/bufnr/winnr where the error occurs.
10465 " There should be a finer way to get the file name if it is split in two
10468 " Some times in the lof file there is a '(' from the source tex file
10469 " which might be not closed, then this while loop is used to find
10470 " readable file name.
10471 let [ startline, startcol ] = searchpairpos('(', '', ')', 'bW')
10473 redir! >> /tmp/SyncTex_log
10474 let g:startline = startline
10475 silent! echomsg " [ startline, startcol ] " . string([ startline, startcol ])
10477 " THIS CODE IS NOT WORKING:
10478 " if nr >= 1 && [ startline, startcol ] == [ startline_o, startcol_o ] && !test
10479 " keepjumps call setpos(".", saved_pos)
10480 " let g:debug = "return " . nr
10485 silent! echomsg "END startline = " . startline
10488 keepjumps call setpos(".", saved_pos)
10491 let fname = matchstr(strpart(getline(startline), startcol), '^\f\+')
10492 " if the file name was broken in the log file in two lines,
10493 " get the end of file name from the next line.
10494 let tex_extensions = extend(copy(g:atp_tex_extensions), [ 'tex', 'cls', 'sty', 'clo', 'def' ], 0)
10495 let pat = '\.\%('.join(tex_extensions, '\|').'\)$'
10498 for end in tex_extensions
10499 call extend(stridx, { end : stridx(getline(startline+1), "." . end) })
10501 call filter(stridx, "v:val != -1")
10503 for end in keys(stridx)
10504 call extend(StrIdx, { stridx[end] : end }, 'keep')
10506 let idx = min(keys(StrIdx))
10507 let end = get(StrIdx, idx, "")
10508 let fname .= strpart(getline(startline+1), 0, idx + len(end) + 1)
10511 let g:fname = fnamemodify(fname, ":t")
10512 let g:dir = fnamemodify(g:fname, ":p:h")
10514 " if g:fname =~# '^' . escape(fnamemodify(tempname(), ":h"), '\/')
10515 " let g:fname = substitute(g:fname, fnamemodify(tempname(), ":h"), b:atp_ProjectDir)
10518 let test = filereadable(fname)
10520 let [ startline_o, startcol_o ] = deepcopy([ startline, startcol ])
10522 keepjumps call setpos(".", saved_pos)
10524 let g:fname = fname
10527 " if the file is under texmf directory return unless g:atp_developer = 1
10528 " i.e. do not visit packages and classes.
10529 if ( fnamemodify(fname, ':p') =~ '\%(\/\|\\\)texmf' || index(['cls', 'sty', 'bst'], fnamemodify(fname, ":e")) != -1 ) && !g:atp_developer
10530 keepjumps call setpos(".", saved_pos)
10532 elseif fnamemodify(fname, ':p') =~ '\%(\/\|\\\)texmf'
10533 " comma separated list of options
10534 let options = 'nospell'
10539 let bufnr = bufnr(fname)
10540 " let g:bufnr = bufnr
10541 let bufwinnr = bufwinnr(bufnr)
10542 let log_winnr = bufwinnr("")
10544 " Goto found file and correct line.
10545 " with bang open file in a new window,
10546 " without open file in previous window.
10549 exe bufwinnr . " wincmd w"
10552 elseif buflisted(bufnr)
10553 exe 'split #' . bufnr
10557 " allows to go to errrors in packages.
10558 exe 'split ' . fname
10564 exe bufwinnr . " wincmd w"
10568 exe s:winnr . " wincmd w"
10569 if buflisted(bufnr)
10574 exe "edit " . fname
10586 for option in split(options, ',')
10587 exe "setl " . option
10590 " highlight the error
10591 if exists("error") && error != ""
10592 " let error_pat = escape(error, '\.')
10593 " call matchadd("ErrorMsg", '\%'.lineNr.'l' . error_pat)
10594 let matchID = matchadd("Error", error, 15)
10599 " Unset 'cursorline' option when entering the window.
10600 exe 'au! WinEnter ' . expand("%:p") . " setl nocursorline"
10601 " if exists("matchID")
10602 " exe 'au! WinEnter ' . expand("%:p") . " call matchdelete(".matchID.")"
10604 exe log_winnr . ' wincmd w'
10611 command! -buffer -bang SyncTex :call <SID>SyncTex(<q-bang>)
10612 map <buffer> <Enter> :SyncTex<CR>
10613 " nnoremap <buffer> <LocalLeader>g :SyncTex<CR>
10614 augroup ATP_SyncLog
10615 au CursorMoved *.log :call <SID>SyncTex("", 1)
10618 function! s:SyncXpdfLog(...)
10620 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
10621 " check the value of g:atp_SyncXpdfLog
10622 let check = ( a:0 >= 1 ? a:1 : 1 )
10624 if b:atp_Viewer !~ '^\s*xpdf\>' || b:atp_XpdfServer == "" || check && !g:atp_SyncXpdfLog
10628 " let saved_pos = getpos(".")
10630 let [ lineNr, colNr ] = searchpos('\[\_d\+\%({[^}]*}\)\=\n\=\]', 'n')
10631 let line = strpart(getline(lineNr), colNr-1) . getline(lineNr+1)
10633 let pageNr = substitute(matchstr(line, '\[\zs\_d\+\ze\%({[^}]*}\)\=\]'), "\n", "", "g")
10634 let g:pageNr = pageNr
10637 let cmd = "xpdf -remote " . b:atp_XpdfServer . " " . fnamemodify(atp_MainFile, ":r") . ".pdf " . pageNr . " &"
10642 command! -buffer SyncXpdf :call s:SyncXpdfLog(0)
10643 command! -buffer Xpdf :call s:SyncXpdfLog(0)
10644 map <buffer> <silent> <F3> :SyncXpdf<CR>
10645 augroup ATP_SyncXpdfLog
10646 au CursorMoved *.log :call s:SyncXpdfLog(1)
10655 if &buftype == 'quickfix'
10656 setlocal modifiable
10659 function! s:TexLog(options)
10660 if executable("texloganalyser")
10661 let s:command="texloganalyser " . a:options . " " . &l:errorfile
10662 echo system(s:command)
10664 echo "Please install 'texloganalyser' to have this functionality. The perl program written by Thomas van Oudenhove."
10668 function! s:PdfFonts()
10669 if b:atp_OutDir !~ "\/$"
10670 b:atp_OutDir=b:atp_OutDir . "/"
10672 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
10673 if executable("pdffonts")
10674 let s:command="pdffonts " . fnameescape(fnamemodify(atp_MainFile,":r")) . ".pdf"
10675 echo system(s:command)
10677 echo "Please install 'pdffonts' to have this functionality. In 'gentoo' it is in the package 'app-text/poppler-utils'."
10681 " function! s:setprintexpr()
10682 " if b:atp_TexCompiler == "pdftex" || b:atp_TexCompiler == "pdflatex"
10683 " let s:ext = ".pdf"
10685 " let s:ext = ".dvi"
10687 " let &printexpr="system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' " . fnameescape(fnamemodify(expand("%"),":p:r")) . s:ext . "') . + v:shell_error"
10689 " call s:setprintexpr()
10691 function! YesNoCompletion(A,P,L)
10692 return ['yes','no']
10696 " Ssh printing tools
10697 "{{{ Print, Lpstat, ListPrinters
10698 " This function can send the output file to local or remote printer.
10699 " a:1 = file to print (if not given printing the output file)
10700 " a:2 = printer name (if g:atp_ssh is non empty or different from
10701 " 'localhost' printer on remote server)
10702 " a:3 = printing options (give printing optinos or 'default' then use
10703 " the variable g:printingoptions)
10704 " a:4 = printing command (default lpr)
10705 function! s:SshPrint(...)
10707 call atplib#outdir()
10709 " set the extension of the file to print
10710 " if prining the tex output file.
10711 if a:0 == 0 || a:0 >= 1 && a:1 == ""
10712 let l:ext = get(g:atp_CompilersDict, b:atp_TexCompiler, "not present")
10713 if l:ext == "not present"
10715 echomsg b:atp_TexCompiler . " is not present in g:atp_CompilersDict"
10717 return "extension not found"
10719 if b:atp_TexCompiler =~ "lua"
10720 if b:atp_TexOptions == "" || b:atp_TexOptions =~ "output-format=\s*pdf"
10728 " set the file to print
10729 let l:pfile = ( a:0 == 0 || (a:0 >= 1 && a:1 == "" ) ? b:atp_OutDir . fnamemodify(expand("%"),":t:r") . l:ext : a:1 )
10731 " set the printing command
10732 let l:lprcommand = ( a:0 >= 4 ? a:4 : "lpr" )
10733 let l:print_options = ( a:0 >= 3 ? a:3 : g:printingoptions )
10735 " print locally or remotely
10736 " the default is to print locally (g:atp_ssh=`whoami`@localhost)
10737 let l:server = ( exists("g:atp_ssh") ? strpart(g:atp_ssh,stridx(g:atp_ssh,"@")+1) : "localhost" )
10738 " To which printer send the file:
10739 let l:printer = ( a:0 >= 2 ? "-P " . a:2 : "" )
10740 " Set Printing Options
10741 let l:print_options .= " " . l:printer
10743 echomsg "Server " . l:server
10744 echomsg "File " . l:pfile
10746 if l:server =~ 'localhost'
10747 let l:ok = confirm("Are the printing options set right?\n".l:print_options,"&Yes\n&No\n&Cancel")
10749 let l:print_options = input("Give new printing options ")
10754 let l:com = l:lprcommand . " " . l:print_options . " " . fnameescape(l:pfile)
10757 echomsg "Printing ... " . l:com
10758 " let b:com=l:com " DEBUG
10760 " print over ssh on the server g:atp_ssh with the printer a:1 (or the
10761 " default system printer if a:0 == 0
10763 " TODO: write completion :).
10764 let l:ok = confirm("Are the printing options set right?\n".l:print_options,"&Yes\n&No\n&Cancel")
10766 let l:print_options=input("Give new printing options ")
10771 let l:com="cat " . fnameescape(l:pfile) . " | ssh " . g:atp_ssh . " " . l:lprcommand . " " . l:print_options
10772 echomsg "Printing ... " . l:com
10773 " let b:com=l:com " DEBUG
10777 " The command only prints the output file.
10780 if exists("g:apt_ssh")
10781 let l:server=strpart(g:atp_ssh,stridx(g:atp_ssh,"@")+1)
10783 let l:server='locahost'
10785 if l:server == 'localhost'
10786 echo system("lpstat -l")
10788 echo system("ssh " . g:atp_ssh . " lpstat -l ")
10792 " it is used for completetion of the command SshPrint
10793 function! s:ListPrinters(A,L,P)
10794 if exists("g:atp_ssh") && g:atp_ssh !~ '@localhost' && g:atp_ssh != ""
10795 let l:com="ssh -q " . g:atp_ssh . " lpstat -a | awk '{print $1}'"
10797 let l:com="lpstat -a | awk '{print $1}'"
10799 return system(l:com)
10803 " Open Library Command
10805 command! -nargs=? -bang -complete=file Open call atplib#Open(<q-bang>, g:atp_LibraryPath, g:atp_OpenTypeDict, <q-args>)
10806 let g:atp_open_completion = []
10807 " -complete=customlist,ATP_CompleteOpen
10808 " function! ATP_CompleteOpen(ArgLead, CmdLead, CurPos)
10809 " return filter(deepcopy(g:atp_open_completion), "v:val =~ '^' . a:ArgLead")
10816 " TODO if the file was not found ask to make one.
10817 function! ToDo(keyword,stop,...)
10820 let bufname = bufname("%")
10826 let texfile=getbufline(bufname, 1, "$")
10831 for line in texfile
10832 if line =~ '%.*' . a:keyword
10833 call extend(todo, { nr : line })
10840 if len(keys(todo)) == 0
10841 echomsg " List for '%.*" . a:keyword . "' in '" . bufname . "' is empty."
10844 echomsg " List for '%.*" . a:keyword . "' in '" . bufname . "':"
10845 let sortedkeys=sort(keys(todo), "atplib#CompareNumbers")
10846 for key in sortedkeys
10847 " echo the todo line.
10848 echomsg key . " " . substitute(substitute(todo[key],'%','',''),'\t',' ','g')
10852 " show all comment lines right below the found todo line.
10853 while true && texfile[linenr] !~ '%.*\c\<todo\>'
10855 if texfile[linenr] =~ '\s*%' && texfile[linenr] !~ a:stop
10856 " make space of length equal to len(linenr)
10859 while j < len(linenr)
10860 let space=space . " "
10863 echomsg space . " " . substitute(substitute(texfile[linenr],'%','',''),'\t',' ','g')
10874 " This functions reloads ATP (whole or just a function)
10877 if !exists("g:debug_atp_plugin")
10878 let g:debug_atp_plugin=0
10880 if g:debug_atp_plugin==1 && !exists("*Reload")
10881 " Reload() - reload all the tex_apt functions
10882 " Reload(func1,func2,...) reload list of functions func1 and func2
10884 let l:pos_saved=getpos(".")
10885 let l:bufname=fnamemodify(expand("%"),":p")
10888 let l:runtime_path=split(&runtimepath,',')
10889 echo "Searching for atp plugin files"
10890 let l:file_list=['ftplugin/tex_atp.vim', 'ftplugin/fd_atp.vim',
10891 \ 'ftplugin/bibsearch_atp.vim', 'ftplugin/toc_atp.vim',
10892 \ 'autoload/atplib.vim', 'ftplugin/atp_LatexBox.vim',
10893 \ 'indent/tex_atp.vim' ]
10895 for l:file in l:file_list
10896 call add(l:file_path,globpath(&rtp,l:file))
10898 " if exists("b:atp_debug")
10899 " if b:atp_debug == "v" || b:atp_debug == "verbose"
10900 " echomsg string(l:file_path)
10903 for l:file in l:file_path
10904 echomsg "deleting FUNCTIONS and VARIABLES from " . l:file
10905 let l:atp=readfile(l:file)
10906 for l:line in l:atp
10907 let l:function_name=matchstr(l:line,'^\s*fun\%(ction\)\?!\?\s\+\zs\<[^(]*\>\ze(')
10908 if l:function_name != "" && l:function_name != "Reload"
10909 if exists("*" . l:function_name)
10910 if exists("b:atp_debug")
10911 if b:atp_debug == "v" || b:atp_debug == "verbose"
10912 echomsg "deleting function " . l:function_name
10915 execute "delfunction " . l:function_name
10918 let l:variable_name=matchstr(l:line,'^\s*let\s\+\zsg:[a-zA-Z_^{}]*\ze\>')
10919 if exists(l:variable_name)
10920 execute "unlet ".l:variable_name
10921 if exists("b:atp_debug")
10922 if b:atp_debug == "v" || b:atp_debug == "verbose"
10923 echomsg "unlet ".l:variable_name
10930 if a:1 != "maps" && a:1 != "reload"
10931 let l:f_list=split(a:1,',')
10932 let g:f_list=l:f_list
10933 for l:function in l:f_list
10934 execute "delfunction " . l:function
10935 if exists("b:atp_debug")
10936 if b:atp_debug == "v" || b:atp_debug == "verbose"
10937 echomsg "delfunction " . l:function
10944 " Do not write project script file while saving the file.
10945 let atp_ProjectScript = ( exists("g:atp_ProjectScript") ? g:atp_ProjectScript : -1 )
10946 let g:atp_ProjectScript = 0
10948 if atp_ProjectScript == -1
10949 unlet g:atp_ProjectScript
10951 let g:atp_ProjectScript = atp_ProjectScript
10953 " THIS IS THE SLOW WAY:
10955 execute "edit " . fnameescape(l:bufname)
10956 keepjumps call setpos(".",l:pos_saved)
10957 " This could be faster: but aparently doesn't work.
10958 " execute "source " . l:file_path[0]
10961 " command! -buffer -nargs=* -complete=function Reload :call Reload(<f-args>)
10966 vmap <buffer> <Plug>WrapSelection :<C-U>call <SID>WrapSelection('')<CR>i
10967 vmap <buffer> <Plug>InteligentWrapSelection :<C-U>call <SID>InteligentWrapSelection('')<CR>i
10968 nnoremap <silent> <buffer> <Plug>ToggleStar :call <SID>ToggleStar()<CR>
10969 nnoremap <silent> <buffer> <Plug>ToggleEnvForward :call <SID>ToggleEnvironment(0, 1)<CR>
10970 nnoremap <silent> <buffer> <Plug>ToggleEnvBackward :call <SID>ToggleEnvironment(0, -1)<CR>
10971 nnoremap <silent> <buffer> <Plug>ChangeEnv :call <SID>ToggleEnvironment(1)<CR>
10972 nnoremap <silent> <buffer> <Plug>TexDoc :TexDoc
10974 command! -buffer -nargs=? -range WrapSelection :call <SID>WrapSelection(<args>)
10975 command! -buffer -nargs=? -range InteligentWrapSelection :call <SID>InteligentWrapSelection(<args>)
10976 command! TexAlign :call TexAlign()
10977 command! -buffer ToggleStar :call <SID>ToggleStar()<CR>
10978 command! -buffer -nargs=? ToggleEnv :call <SID>ToggleEnvironment(0, <f-args>)
10979 command! -buffer -nargs=* ChengeEnv :call <SID>ToggleEnvironment(1, <f-args>)
10980 command! -buffer -nargs=* -complete=customlist,<SID>TeXdoc_complete TexDoc :call <SID>TexDoc(<f-args>)
10981 command! -buffer -bang Delete :call <SID>Delete(<q-bang>)
10982 nmap <silent> <buffer> <Plug>Delete :call <SID>Delete("")<CR>
10983 command! -buffer OpenLog :call <SID>OpenLog()
10984 nnoremap <silent> <buffer> <Plug>OpenLog :call <SID>OpenLog()<CR>
10985 command! -buffer TexLog :call <SID>TexLog()
10986 nnoremap <silent> <buffer> <Plug>TexLog :call <SID>TexLog()<CR>
10987 command! -buffer PdfFonts :call <SID>PdfFonts()
10988 nnoremap <silent> <buffer> <Plug>PdfFonts :call <SID>PdfFonts()<CR>
10989 command! -complete=custom,<SID>ListPrinters -buffer -nargs=* SshPrint :call <SID>SshPrint("", <f-args>)
10990 nnoremap <buffer> <Plug>SshPrint :SshPrint
10991 command! -buffer Lpstat :call <SID>Lpstat()
10992 nnoremap <silent> <buffer> <Plug>Lpstat :call <SID>Lpstat()<CR>
10993 command! -buffer ListPrinters :echo <SID>ListPrinters("", "", "")
10995 command! -buffer ShowPackages :let b:atp_PackageList = atplib#GrepPackageList() | echo join(b:atp_PackageList, "\n")
10996 command! -buffer -nargs=? -complete=buffer ToDo :call ToDo('\c\<to\s*do\>','\s*%\c.*\<note\>',<f-args>)
10997 command! -buffer -nargs=? -complete=buffer Note :call ToDo('\c\<note\>','\s*%\c.*\<to\s*do\>',<f-args>)
10998 " vim:fdm=marker:tw=85:ff=unix:noet:ts=8:sw=4:fdc=1
10999 ftplugin/ATP_files/helpfunctions.vim [[[1
11001 " Author: Marcin Szamotulski
11002 " Description: This file contains help commands and variables (for mappings used by ATP)
11003 " Note: This file is a part of Automatic Tex Plugin for Vim.
11004 " URL: https://launchpad.net/automatictexplugin
11007 let s:sourced = !exists("s:loaded") ? 0 : 1
11010 " {{{1 Help Math IMAPS
11011 function! <SID>HelpMathIMaps()
11013 if exists("g:no_plugin_maps") || exists("g:no_atp_maps")
11014 echomsg "ATP maps are turned off"
11018 let infty_leader = (g:atp_imap_first_leader == "#" ? "\\" : g:atp_imap_first_leader )
11020 let g:help_mathimaps = ''
11022 \."\n <maplocalleader> has value g:atp_imap_first_leader"
11023 \."\n ".g:atp_imap_first_leader."a \\alpha ".g:atp_imap_first_leader."b \\beta"
11024 \."\n ".g:atp_imap_first_leader."g \\gamma ".g:atp_imap_first_leader."d \\delta"
11025 \."\n ".g:atp_imap_first_leader."e \\epsilon ".g:atp_imap_first_leader."ve \\varepsilon"
11026 \."\n ".g:atp_imap_first_leader."z \\zeta ".g:atp_imap_first_leader."h \\eta"
11027 \."\n ".g:atp_imap_first_leader."o \\theta ".g:atp_imap_first_leader."vo \\vartheta"
11028 \."\n ".g:atp_imap_first_leader."i \\iota ".g:atp_imap_first_leader."k \\kappa"
11029 \."\n ".g:atp_imap_first_leader."l \\lambda ".g:atp_imap_first_leader."m \\mu"
11030 \."\n ".g:atp_imap_first_leader."n \\nu ".g:atp_imap_first_leader."x \\xi"
11031 \."\n ".g:atp_imap_first_leader."p \\pi ".g:atp_imap_first_leader."r \\rho"
11032 \."\n ".g:atp_imap_first_leader."s \\sigma ".g:atp_imap_first_leader."vs \\varsigma"
11033 \."\n ".g:atp_imap_first_leader."t \\tau ".g:atp_imap_first_leader."u \\upsilon"
11034 \."\n ".g:atp_imap_first_leader."f \\phi ".g:atp_imap_first_leader."c \\chi"
11035 \."\n ".g:atp_imap_first_leader."y \\psi ".g:atp_imap_first_leader."w \\omega"
11037 \."\n ".g:atp_imap_first_leader."G \\Gamma ".g:atp_imap_first_leader."D \\Delta"
11038 \."\n ".g:atp_imap_first_leader."Z \\mathrm{Z} ".g:atp_imap_first_leader."O \\Theta"
11039 \."\n ".g:atp_imap_first_leader."L \\Lambda ".g:atp_imap_first_leader."M \\Mu"
11040 \."\n ".g:atp_imap_first_leader."N \\Nu ".g:atp_imap_first_leader."P \\Pi"
11041 \."\n ".g:atp_imap_first_leader."S \\Sigma ".g:atp_imap_first_leader."U \\Upsilon"
11042 \."\n ".g:atp_imap_first_leader."F \\Phi ".g:atp_imap_first_leader."Y \\Psi"
11043 \."\n ".g:atp_imap_first_leader."W \\Omega"
11045 \."\n ".g:atp_imap_first_leader."+ \\bigcup ".g:atp_imap_first_leader."- \\setminus"
11046 \."\n ".infty_leader."8 \\infty ".g:atp_imap_first_leader."& \\wedge"
11047 \."\n ". "^^ ^{} ". "__ _{}"
11048 \."\n ".g:atp_imap_third_leader."m \\(\\) ".g:atp_imap_third_leader."M \\[\\] <maplocalleader> has value g:atp_imap_third_leader"
11049 return g:help_mathimaps
11051 silent call <SID>HelpMathIMaps()
11053 " {{{1 Help Environment IMAPS
11054 function! <SID>HelpEnvIMaps()
11056 if exists("g:no_plugin_maps") || exists("g:no_atp_maps")
11057 echomsg "ATP maps are turned off"
11061 let g:help_envimaps = ''
11062 \."\n ENVIRONMENT IMAPS"
11063 \."\n <maplocalleader> has value g:atp_imap_third_leader"
11064 \."\n ".g:atp_imap_third_leader."b \\begin{} ".g:atp_imap_third_leader."e \\end{}"
11065 \."\n ".g:atp_imap_third_leader."t theorem ".g:atp_imap_third_leader."d definition"
11066 \."\n ".g:atp_imap_third_leader."p proposition ".g:atp_imap_third_leader."l lemma"
11067 \."\n ".g:atp_imap_third_leader."r remark ".g:atp_imap_third_leader."C corollary"
11068 \."\n ".g:atp_imap_third_leader."p proof ".g:atp_imap_third_leader."x example"
11069 \."\n ".g:atp_imap_third_leader."n note "
11071 \."\n ".g:atp_imap_third_leader."E enumerate ".g:atp_imap_third_leader."I itemize"
11072 \."\n ".g:atp_imap_third_leader."i \\item"
11074 \."\n ".g:atp_imap_third_leader."a align ".g:atp_imap_third_leader."e equation"
11076 \."\n ".g:atp_imap_third_leader."L flushleft ".g:atp_imap_third_leader."R flushright"
11077 \."\n ".g:atp_imap_third_leader."c center"
11079 \."\n ".g:atp_imap_third_leader."T tikzpicture"
11081 \."\n ".g:atp_imap_third_leader."f frame"
11082 return g:help_envimaps
11084 silent call <SID>HelpEnvIMaps()
11087 function! <SID>HelpVMaps()
11089 if exists("g:no_plugin_maps") || exists("g:no_atp_maps")
11090 echomsg "ATP maps are turned off"
11094 " Substitute <LocalLeader> with maplocalleader
11095 if !exists("maplocalleader")
11096 let maplocalleader = "\\"
11098 let l:atp_vmap_text_font_leader = ( g:atp_vmap_text_font_leader == "<LocalLeader>" ? maplocalleader : g:atp_vmap_text_font_leader )
11099 let l:atp_vmap_environment_leader = ( g:atp_vmap_environment_leader == "<LocalLeader>" ? maplocalleader : g:atp_vmap_environment_leader )
11100 let l:atp_vmap_bracket_leader = ( g:atp_vmap_bracket_leader == "<LocalLeader>" ? maplocalleader : g:atp_vmap_bracket_leader )
11101 let l:atp_vmap_big_bracket_leader = ( g:atp_vmap_big_bracket_leader =~ "<LocalLeader>" ? substitute(g:atp_vmap_big_bracket_leader, '<LocalLeader>', maplocalleader, '') : g:atp_vmap_big_bracket_leader )
11103 let g:help_vmaps = ''
11104 \."\n <maplocalleader> has value g:atp_vmap_text_font_leader"
11105 \."\n KEYMAP TEXT MODE MATH MODE"
11106 \."\n ".l:atp_vmap_text_font_leader."rm \\textrm{} \\mathrm{}"
11107 \."\n ".l:atp_vmap_text_font_leader."em \\emph{} \\mathit{}"
11108 \."\n ".l:atp_vmap_text_font_leader."it \\textit{} \\mathit{}"
11109 \."\n ".l:atp_vmap_text_font_leader."sf \\textsf{} \\mathsf{}"
11110 \."\n ".l:atp_vmap_text_font_leader."tt \\texttt{} \\mathtt{}"
11111 \."\n ".l:atp_vmap_text_font_leader."bf \\textbf{} \\mathbf{}"
11112 \."\n ".l:atp_vmap_text_font_leader."bb \\textbf{} \\mathbb{}"
11113 \."\n ".l:atp_vmap_text_font_leader."bb \\textbf{} \\mathbb{}"
11114 \."\n ".l:atp_vmap_text_font_leader."sl \\textsl{}"
11115 \."\n ".l:atp_vmap_text_font_leader."sc \\textsc{}"
11116 \."\n ".l:atp_vmap_text_font_leader."up \\textup{}"
11117 \."\n ".l:atp_vmap_text_font_leader."md \\textmd{}"
11118 \."\n ".l:atp_vmap_text_font_leader."un \\underline{} \\underline{}"
11119 \."\n ".l:atp_vmap_text_font_leader."ov \\overline{} \\overline{}"
11120 \."\n ".l:atp_vmap_text_font_leader."no \\textnormal{} \\mathnormal{}"
11121 \."\n ".l:atp_vmap_text_font_leader."cal \\mathcal{}"
11123 \."\n MODE INDEPENDENT VMAPS:"
11124 \."\n <maplocalleader> has value g:atp_vmap_environment_leader"
11125 \."\n ".l:atp_vmap_environment_leader."C wrap in center environment"
11126 \."\n ".l:atp_vmap_environment_leader."L wrap in flushleft environment"
11127 \."\n ".l:atp_vmap_environment_leader."R wrap in flushright environment"
11129 \."\n <maplocalleader> has value g:atp_vmap_bracket_leader"
11130 \."\n ".l:atp_vmap_bracket_leader."( (:) ".l:atp_vmap_bracket_leader.") (:)"
11131 \."\n ".l:atp_vmap_bracket_leader."[ [:] ".l:atp_vmap_bracket_leader."] [:]"
11132 \."\n ".l:atp_vmap_bracket_leader."{ {:} ".l:atp_vmap_bracket_leader."} {:}"
11133 \."\n ".l:atp_vmap_bracket_leader."\\{ \\{:\\} ".l:atp_vmap_bracket_leader."\\} \\{:\\}"
11134 \."\n m \\(:\\) M \\[:\\] "
11136 \."\n <maplocalleader> has value g:atp_vmap_big_bracket_leader"
11137 \."\n ".l:atp_vmap_big_bracket_leader."( \\left(:\\right) ".l:atp_vmap_big_bracket_leader.") \\left(:\\right)"
11138 \."\n ".l:atp_vmap_big_bracket_leader."[ \\left[:\\right] ".l:atp_vmap_big_bracket_leader."] \\left[:\\right]"
11139 \."\n ".l:atp_vmap_big_bracket_leader."{ \\left{:\\right} ".l:atp_vmap_big_bracket_leader."} \\left{:\\right}"
11140 \."\n ".l:atp_vmap_big_bracket_leader."\\{ \\left\\{:\\right\\} ".l:atp_vmap_big_bracket_leader."\\} \\left\\{:\\right\\}"
11142 \."\n ".l:atp_vmap_text_font_leader."f \\usefont{".g:atp_font_encoding."}{}{}{}\\selectfont"
11143 return g:help_vmaps
11145 silent call <SID>HelpVMaps()
11147 " function! <SID>HelpIMaps()
11148 " let tc_imap = maparg("<Tab> ", 'i') =~# 'atplib#TabCompletion' ? '<Tab>' :
11149 " \ maparg("<F7> ", 'i') =~# 'atplib#TabCompletion' ? '<F7>' : ""
11150 " let netc_imap = tc_imap == "<Tab>" ? "<S-Tab>" : tc_imap == "<F7>" ? "<S-F7>" : ""
11151 " let g:help_imaps = ''
11152 " \."\n <maplocalleader> has value g:atp_vmap_text_font_leader"
11153 " \."\n ".tc_imap." "."Completion (expert mode)"
11154 " \."\n ".netc_imap." "."Completion (non-expert mode)"
11156 " silent call <SID>HelpIMaps()
11157 " command! -buffer HelpIMaps :echo <SID>HelpIMaps()
11162 command! -buffer HelpMathIMaps :echo <SID>HelpMathIMaps()
11163 command! -buffer HelpEnvIMaps :echo <SID>HelpEnvIMaps()
11164 command! -buffer HelpVMaps :echo <SID>HelpVMaps()
11165 ftplugin/ATP_files/vimcomplete.bst [[[1
11168 { address author booktitle chapter doi edition editor eid howpublished institution isbn issn journal key month note number organization pages publisher school series title type volume year }
11180 FUNCTION {fin.entry}
11201 FUNCTION {field.or.null}
11202 { duplicate$ empty$
11208 FUNCTION {capitalize}
11209 { "u" change.case$ "t" change.case$ }
11211 FUNCTION {space.word}
11212 { " " swap$ * " " * }
11214 FUNCTION {bbl.and} { "&"}
11215 FUNCTION {bbl.etal} { "et al." }
11217 INTEGERS { nameptr namesleft numnames }
11221 FUNCTION {format.names}
11222 { duplicate$ empty$ 'skip$ {
11226 s num.names$ 'numnames :=
11227 numnames 'namesleft :=
11230 %"{vv~}{ll}{, f.}{, jj}"
11239 s nameptr "{ll}" format.name$ duplicate$ "others" =
11257 nameptr #1 + 'nameptr :=
11258 namesleft #1 - 'namesleft :=
11264 FUNCTION {format.authors}
11266 {editor format.names} {author format.names}
11270 FUNCTION {format.title}
11272 duplicate$ empty$ 'skip$
11273 { "t" change.case$ }
11276 FUNCTION {output.label}
11278 %"{" cite$ * write$
11284 FUNCTION {format.date}
11288 year duplicate$ empty$
11290 { "there's a month but no year in " cite$ * warning$ }
11305 FUNCTION {output.entry}
11309 format.authors output
11311 format.title output
11315 FUNCTION {default.type} {"?" output.entry}
11317 FUNCTION {article} {"a" output.entry}
11318 FUNCTION {book} {"B" output.entry}
11319 FUNCTION {booklet} {"k" output.entry}
11320 FUNCTION {conference} {"f" output.entry}
11321 FUNCTION {inbook} {"b" output.entry}
11322 FUNCTION {incollection} {"c" output.entry}
11323 FUNCTION {inproceedings} {"p" output.entry}
11324 FUNCTION {manual} {"m" output.entry}
11325 FUNCTION {mastersthesis} {"Master" output.entry}
11326 FUNCTION {misc} {"-" output.entry}
11327 FUNCTION {phdthesis} {"PhD" output.entry}
11328 FUNCTION {proceedings} {"P" output.entry}
11329 FUNCTION {techreport} {"r" output.entry}
11330 FUNCTION {unpublished} {"u" output.entry}
11339 FUNCTION {chop.word}
11342 s #1 len substring$ =
11343 { s len #1 + global.max$ substring$ }
11347 FUNCTION {sort.format.names}
11351 s num.names$ 'numnames :=
11352 numnames 'namesleft :=
11355 "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}"
11360 namesleft #1 = t "others" = and
11367 nameptr #1 + 'nameptr :=
11368 namesleft #1 - 'namesleft :=
11373 FUNCTION {sort.format.title}
11377 "The " #4 t chop.word
11381 #1 global.max$ substring$
11383 FUNCTION {author.sort}
11386 { "to sort, need author or key in " cite$ * warning$
11392 { author sort.format.names }
11395 FUNCTION {author.editor.sort}
11399 { "to sort, need author, editor, or key in " cite$ * warning$
11405 { editor sort.format.names }
11408 { author sort.format.names }
11411 FUNCTION {author.organization.sort}
11413 { organization empty$
11415 { "to sort, need author, organization, or key in " cite$ * warning$
11421 { "The " #4 organization chop.word sortify }
11424 { author sort.format.names }
11427 FUNCTION {editor.organization.sort}
11429 { organization empty$
11431 { "to sort, need editor, organization, or key in " cite$ * warning$
11437 { "The " #4 organization chop.word sortify }
11440 { editor sort.format.names }
11447 'author.editor.sort
11448 { type$ "proceedings" =
11449 'editor.organization.sort
11451 'author.organization.sort
11460 year field.or.null sortify
11464 title field.or.null
11467 #1 entry.max$ substring$
11472 ITERATE {call.type$}
11473 ftplugin/bibsearch_atp.vim [[[1
11475 " Vim filetype plugin file
11477 " Maintainer: Marcin Szamotulski
11478 " Last Changed: 2010 July 3
11479 " Note: This file is a part of Automatic Tex Plugin for Vim.
11480 " URL: https://launchpad.net/automatictexplugin
11484 if exists("b:did_ftplugin") | finish | endif
11485 let b:did_ftplugin = 1
11489 function! ATPBibStatus() "{{{
11490 return "Bibsearch: " . substitute(expand("%"),"___","","g")
11492 setlocal statusline=%{ATPBibStatus()}
11497 if !exists("no_plugin_maps") && !exists("no_atp_bibsearch_maps")
11498 map <buffer> c :call BibChoose()<CR>
11499 map <buffer> y :call BibChoose()<CR>
11500 map <buffer> p :call BibChoose()<CR>
11501 map <buffer> q :hide<CR>
11502 command! -buffer -nargs=* BibChoose :call BibChoose(<f-args>)
11507 function! BibChoose(...)" {{{
11509 let which = input("Which entry? ( <Number><reg name><Enter>, <Number><Enter> or <Enter> for none) ")
11513 let g:which = which
11517 if which =~ '^\d*$'
11518 let start = stridx(b:ListOfBibKeys[which],'{')+1
11519 let choice = substitute(strpart(b:ListOfBibKeys[which], start), ',\s*$', '', '')
11520 let g:choice = choice
11522 " Goto right buffer
11523 let winbufnr = bufwinnr(b:BufNr)
11525 exe "normal ".winbufnr."
\x17w"
11527 if bufexist(b:BufNr)
11528 exe "normal buffer ".winbufnr
11531 echo "Buffer was deleted"
11537 let LineNr = line(".")
11538 let ColNr = col(".")
11539 call setline(LineNr, strpart(getline(LineNr), 0, ColNr) . choice . strpart(getline(LineNr), ColNr))
11540 call cursor(LineNr, len(strpart(getline(LineNr), 0, ColNr) . choice)+1)
11542 elseif which =~ '^\d*\(\a\|+\| . "*" .\)$'
11543 let letter=substitute(which,'\d','','g')
11544 let g:letter = letter
11545 let which=substitute(which,'\a\|+\|' . "*",'','g')
11546 let start=stridx(b:ListOfBibKeys[which],'{')+1
11547 let choice=substitute(strpart(b:ListOfBibKeys[which], start), ',', '', '')
11550 elseif letter == 'b'
11552 elseif letter == 'c'
11554 elseif letter == 'd'
11556 elseif letter == 'e'
11558 elseif letter == 'f'
11560 elseif letter == 'g'
11562 elseif letter == 'h'
11564 elseif letter == 'i'
11566 elseif letter == 'j'
11568 elseif letter == 'k'
11570 elseif letter == 'l'
11572 elseif letter == 'm'
11574 elseif letter == 'n'
11576 elseif letter == 'o'
11578 elseif letter == 'p'
11580 elseif letter == 'q'
11582 elseif letter == 'r'
11584 elseif letter == 's'
11586 elseif letter == 't'
11588 elseif letter == 'u'
11590 elseif letter == 'v'
11592 elseif letter == 'w'
11594 elseif letter == 'x'
11596 elseif letter == 'y'
11598 elseif letter == 'z'
11600 elseif letter == '*'
11602 elseif letter == '+'
11604 elseif letter == '-'
11607 echohl WarningMsg | echomsg "Choice yanekd to the register '" . letter . "'" | echohl None
11610 ftplugin/fd_atp.vim [[[1
11612 " Vim filetype plugin file
11614 " Maintainer: Marcin Szamotulski
11615 " Last Changed: 2010 July 9
11616 " Note: This file is a part of Automatic Tex Plugin for Vim.
11617 " URL: https://launchpad.net/automatictexplugin
11619 if exists("b:did_ftplugin") | finish | endif
11620 let b:did_ftplugin = 1
11623 if !exists("*OpenFile")
11624 function! OpenFile()
11625 let line = max([line("."), '2'])-2
11626 let file = g:fd_matches[line]
11628 " The list of fd files starts at second line.
11629 let openbuffer = "topleft split! +setl\\ nospell\\ ft=fd_atp\\ noro " . fnameescape(file)
11630 silent exe openbuffer
11636 function! ShowFonts(fd_file)
11638 let font_commands = atplib#ShowFonts(a:fd_file)
11641 for fcom in font_commands
11642 let message .= "\n".fcom
11644 let message="Fonts Declared:".message
11645 call confirm(message)
11649 augroup ATP_fd_list
11650 au CursorHold fd_list* :echo get(g:fd_matches, max([line("."),'2'])-2, "")
11654 function! Preview(keep_tex)
11656 let keep_tex = ( a:keep_tex == "!" ? 1 : 0 )
11658 let b_pos = getpos("'<")[1]
11659 let e_pos = getpos("'>")[1]
11661 if getpos("'<") != [0, 0, 0, 0] && getpos("'<") != [0, 0, 0, 0]
11662 let fd_files = filter(copy(g:fd_matches),'index(g:fd_matches,v:val)+1 >= b_pos-1 && index(g:fd_matches,v:val)+1 <= e_pos-1')
11664 let fd_files = [g:fd_matches[(max([line("."),'2'])-2)]]
11667 call atplib#Preview(fd_files, keep_tex)
11672 if bufname("%") =~ 'fd_list'
11673 command! -buffer -bang -nargs=? -range Preview :call Preview(<q-bang>, <f-args>)
11674 command! -buffer ShowFonts :call ShowFonts(g:fd_matches[(max([line("."),'2'])-2)])
11675 map <buffer> <Enter> :call OpenFile()<CR>
11676 map <buffer> <Tab> :call ShowFonts(g:fd_matches[(max([line("."),'2'])-2)])<CR>
11678 command! -buffer -nargs=1 Preview :call atplib#Preview(["buffer"],<f-args>)
11682 map <buffer> P :Preview! <CR>
11683 map <buffer> p :Preview <CR>
11684 vmap <buffer> P :Preview! <CR>
11685 vmap <buffer> p :Preview <CR>
11686 map <buffer> Q :bd!<CR>
11687 map <buffer> q :q!<CR>R
11689 ftplugin/plaintex_atp.vim [[[1
11691 " Maintainer: Marcin Szamotulski
11692 " Note: This file is a part of Automatic Tex Plugin for Vim.
11693 " URL: https://launchpad.net/automatictexplugin
11695 " b:atp_TexFlavor will be set to plaintex automatically
11696 source $HOME/.vim/ftplugin/tex_atp.vim
11697 ftplugin/tex_atp.vim [[[1
11699 " Title: Vim filetype plugin file
11700 " Author: Marcin Szamotulski
11701 " Email: mszamot [AT] gmail [DOT] com
11702 " URL: https://launchpad.net/automatictexplugin
11703 " BUG Trucer: https://bugs.launchpad.net/automatictexplugin
11705 " Last Changed: 7 October 2010
11706 " GetLatestVimScripts: 2945 50 :AutoInstall: tex_atp.vim
11707 " GetLatestVimScripts: 884 1 :AutoInstall: AutoAlign.vim
11708 " Copyright Statement:
11709 " This file is part of Automatic Tex Plugin for Vim.
11711 " Automatic Tex Plugin for Vim is free software: you can redistribute it
11712 " and/or modify it under the terms of the GNU General Public License as
11713 " published by the Free Software Foundation, either version 3 of the
11714 " License, or (at your option) any later version.
11716 " Automatic Tex Plugin for Vim is distributed in the hope that it will be
11717 " useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11718 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11719 " General Public License for more details.
11721 " You should have received a copy of the GNU General Public License along
11722 " with Automatic Tex Plugin for Vim. If not, see <http://www.gnu.org/licenses/>.
11724 " This licence applies to all files shipped with Automatic Tex Plugin.
11726 let b:did_ftplugin = 1
11728 let g:atp_debugMainScript = 0
11729 " This gives loading time information for debuging purposes.
11730 " The sourcing of vim scripts is more complicated than this but,
11731 " at least, this gives some info.
11732 " Loading times are also acessible using
11733 " vim --startuptime /tmp/time
11734 " see :h --startuptime
11735 if g:atp_debugMainScript
11736 redir! >> /tmp/ATP_log
11737 silent! echo "+++ FILE: " . expand("%")
11738 let time = reltime()
11742 if &cpoptions =~ '<'
11744 echo "ATP is removing < from cpoptions"
11748 let rtp = join(map(split(&rtp, ','), 'fnameescape(v:val)'), ',')
11751 " Execute the atprc file.
11752 " They override cached variables
11753 if filereadable(globpath($HOME, '/.atprc.vim', 1)) && has("unix")
11755 " Note: in $HOME/.atprc file the user can set all the local buffer
11756 " variables without using autocommands
11757 let path = fnameescape(globpath($HOME, '/.atprc.vim', 1))
11758 execute 'source ' . path
11761 let path = get(split(globpath(&rtp, "**/ftplugin/ATP_files/atprc.vim"), '\n'), 0, "")
11763 execute 'source ' . path
11767 if g:atp_debugMainScript
11768 let g:atprc_loadtime=str2float(reltimestr(reltime(time)))
11769 silent echo "rc loadtime: " . string(g:atprc_loadtime)
11772 " Source Project Script
11773 let s:project_src = findfile("ftplugin/ATP_files/project.vim", rtp)
11774 execute 'source ' . fnameescape(s:project_src)
11776 if g:atp_debugMainScript
11777 let g:atphist_loadtime=str2float(reltimestr(reltime(time)))-g:atprc_loadtime
11778 silent echo "project loadtime: " . string(g:atphist_loadtime)
11781 " Functions needed before setting options.
11782 let s:common_src = findfile("ftplugin/ATP_files/common.vim", rtp)
11783 execute 'source ' . fnameescape(s:common_src)
11785 if g:atp_debugMainScript
11786 let g:atpcom_loadtime=str2float(reltimestr(reltime(time)))-g:atprc_loadtime
11787 silent echo "com loadtime: " . string(g:atpcom_loadtime)
11790 " Options, global and local variables, autocommands.
11791 let s:options_src = findfile("ftplugin/ATP_files/options.vim", rtp)
11792 execute 'source ' . fnameescape(s:options_src)
11794 if g:atp_debugMainScript
11795 let g:atpopt_loadtime=str2float(reltimestr(reltime(time)))-g:atpcom_loadtime
11796 silent echo "opt loadtime: " . string(g:atpopt_loadtime)
11800 " Compilation related stuff.
11801 let s:compiler_src = findfile("ftplugin/ATP_files/compiler.vim", rtp)
11802 execute 'source ' . fnameescape(s:compiler_src)
11804 if g:atp_debugMainScript
11805 let g:atpcomp_loadtime=str2float(reltimestr(reltime(time)))-g:atpopt_loadtime
11806 silent echo "comp loadtime: " . string(g:atpcomp_loadtime)
11809 " let compiler_file = findfile('compiler/tex_atp.vim', &rtp)
11811 " execute 'source ' . fnameescape(compiler_file)
11814 " LatexBox addons (by D.Munger, with some modifications).
11817 let s:LatexBox_common_src = findfile("ftplugin/ATP_files/LatexBox_common.vim", rtp)
11818 execute 'source ' . fnameescape(s:LatexBox_common_src)
11820 let s:LatexBox_complete_src = findfile("ftplugin/ATP_files/LatexBox_complete.vim", rtp)
11821 execute 'source ' . fnameescape(s:LatexBox_complete_src)
11823 let s:LatexBox_motion_src = findfile("ftplugin/ATP_files/LatexBox_motion.vim", rtp)
11824 execute 'source ' . fnameescape(s:LatexBox_motion_src)
11826 let s:LatexBox_latexmk_src = findfile("ftplugin/ATP_files/LatexBox_latexmk.vim", rtp)
11827 execute 'source ' . fnameescape(s:LatexBox_latexmk_src)
11830 if g:atp_debugMainScript
11831 let g:atpLB_loadtime=str2float(reltimestr(reltime(time)))-g:atpcomp_loadtime
11832 silent echo "LB loadtime: " . string(g:atpLB_loadtime)
11836 let s:motion_src = findfile("ftplugin/ATP_files/motion.vim", rtp)
11837 execute 'source ' . fnameescape(s:motion_src)
11839 if g:atp_debugMainScript
11840 let g:atpmot_loadtime=str2float(reltimestr(reltime(time)))-g:atpLB_loadtime
11841 silent echo "mot loadtime: " . string(g:atpmot_loadtime)
11844 let s:search_src = findfile("ftplugin/ATP_files/search.vim", rtp)
11845 execute 'source ' . fnameescape(s:search_src)
11847 if g:atp_debugMainScript
11848 let g:atpsea_loadtime=str2float(reltimestr(reltime(time)))-g:atpmot_loadtime
11849 silent echo "sea loadtime: " . string(g:atpsea_loadtime)
11852 let s:various_src = findfile("ftplugin/ATP_files/various.vim", rtp)
11853 execute 'source ' . fnameescape(s:various_src)
11855 if g:atp_debugMainScript
11856 let g:atpvar_loadtime=str2float(reltimestr(reltime(time)))-g:atpsea_loadtime
11857 silent echo "var loadtime: " . string(g:atpvar_loadtime)
11861 " Source maps and menu files.
11862 let s:mappings_src = findfile("ftplugin/ATP_files/mappings.vim", rtp)
11863 execute 'source ' . fnameescape(s:mappings_src)
11867 " LatexBox mappings.
11868 let s:LatexBox_mappings_src = findfile("ftplugin/ATP_files/LatexBox_mappings.vim", rtp)
11869 execute 'source ' . fnameescape(s:LatexBox_mappings_src)
11873 if g:atp_debugMainScript
11874 let g:atpmap_loadtime=str2float(reltimestr(reltime(time)))-g:atpvar_loadtime
11875 silent echo "map loadtime: " . string(g:atpmap_loadtime)
11879 let s:menu_src = findfile("ftplugin/ATP_files/menu.vim", rtp)
11880 execute 'source ' . fnameescape(s:menu_src)
11882 if g:atp_debugMainScript
11883 let g:atpmenu_loadtime=str2float(reltimestr(reltime(time)))-g:atpmap_loadtime
11884 silent echo "menu loadtime: " . string(g:atpmenu_loadtime)
11888 let s:help_src = findfile("ftplugin/ATP_files/helpfunctions.vim", rtp)
11889 execute 'source ' . fnameescape(s:help_src)
11891 if g:atp_debugMainScript
11892 let g:atphelp_loadtime=str2float(reltimestr(reltime(time)))-g:atpmenu_loadtime
11893 silent echo "help loadtime: " . string(g:atphelp_loadtime)
11897 if g:atp_debugMainScript
11898 let g:atp_loadtime = str2float(reltimestr(reltime(time)))
11899 silent echo "LOADTIME: " . string(g:atp_loadtime)
11905 " vim:fdm=marker:ff=unix:noet:ts=4:sw=4
11906 ftplugin/toc_atp.vim [[[1
11908 " Vim filetype plugin file
11910 " Maintainer: Marcin Szamotulski
11911 " Last Changed: 2010 May 31
11912 " Note: This file is a part of Automatic Tex Plugin for Vim.
11913 " URL: https://launchpad.net/automatictexplugin
11915 " if exists("b:did_ftplugin") | finish | endif
11916 let b:did_ftplugin = 1
11918 function! ATP_TOC_StatusLine() " {{{
11919 let l:return = ( expand("%") == "__ToC__" ? "Table of Contents" : 0 )
11920 let l:return = ( expand("%") == "__Labels__" ? "List of Labels" : l:return )
11923 setlocal statusline=%{ATP_TOC_StatusLine()}
11926 " {{{ s:getlinenr(...)
11927 " a:1 line number to get, if not given the current line
11928 " a:2 0/1 0 (default) return linenr as for toc/labels
11929 function! Getlinenr(...)
11930 let line = a:0 >= 1 ? a:1 : line('.')
11931 let labels = a:0 >= 2 ? a:2 : expand("%") == "__Labels__" ? 1 : 0
11935 return get(b:atp_Toc, line, ["", ""])[1]
11937 return get(b:atp_Labels, line, ["", ""])[1]
11940 function! s:getlinenr(...)
11941 let line = a:0 >= 1 ? a:1 : line('.')
11942 let labels = a:0 >= 2 ? a:2 : expand("%") == "__Labels__" ? 1 : 0
11945 return get(b:atp_Toc, line, ["", ""])[1]
11947 return get(b:atp_Labels, line, ["", ""])[1]
11950 command! -buffer GetLine :echo <SID>getlinenr(line("."))
11953 function! s:getsectionnr(...) "{{{
11954 let line = a:0 == 0 ? getline('.') : getline(a:1)
11955 return matchstr(l:line,'^\s*\d\+\s\+\zs\%(\d\|\.\)\+\ze\D')
11959 " Get the file name and its path from the LABELS/ToC list.
11960 function! s:file() "{{{
11961 let labels = expand("%") == "__Labels__" ? 1 : 0
11964 return get(b:atp_Toc, line("."), ["", ""])[0]
11966 return get(b:atp_Labels, line("."), ["", ""])[0]
11969 command! -buffer File :echo s:file()
11973 "---------------------------------------------------------------------
11975 " (1) choose window with matching buffer name
11976 " (2) choose among those which were edited last
11978 " --N-> choose this window
11981 " | --Y-> choose that window
11982 " --go from where you come-->| Does there exist another open window
11983 " | with the right buffer name?
11985 " --Y-> use this window
11986 " Does the window have
11989 " This function returns the window number to which we will eventually go.
11990 function! s:gotowinnr()
11991 let labels_window = expand("%") == "__Labels__" ? 1 : 0
11993 " This is the line number to which we will go.
11994 let l:nr=s:getlinenr(line("."), labels_window)
11996 " t:atp_winnr were set by TOC(), they should also be set by
11998 let l:bufname=s:file()
12001 " Find labels window to go in Labels window
12002 if bufwinnr(t:atp_bufname) != -1
12003 let l:gotowinnr=t:atp_winnr
12008 " Find labels window to go in ToC window
12009 if t:atp_bufname == l:bufname
12010 " if t:atp_bufname agree with that found in ToC
12011 " if the t:atp_winnr is still open
12012 if bufwinnr(t:atp_bufname) != -1
12013 let l:gotowinnr=t:atp_winnr
12018 if bufwinnr("^" . l:bufname . "$") != 0
12019 " if not but there is a window with buffer l:bufname
12020 let l:gotowinnr=bufwinnr("^" . l:bufname . "$")
12022 " if not and there is no window with buffer l:bufname
12023 let l:gotowinnr=t:atp_winnr
12031 command! -buffer GotoWinNr :echo s:gotowinnr()
12034 function! GotoLine(closebuffer) "{{{
12035 let labels_window = expand("%") == "__Labels__" ? 1 : 0
12037 " if under help lines do nothing:
12038 let toc = getbufline("%",1,"$")
12039 let h_line = index(reverse(copy(toc)),'')+1
12040 if line(".") > len(toc)-h_line
12046 " remember the ToC window number
12047 let tocbufnr= bufnr("")
12050 let nr = s:getlinenr(line("."), labels_window)
12053 let gotowinnr= s:gotowinnr()
12056 exe gotowinnr . " wincmd w"
12057 if fnamemodify(buf, ":p") != fnamemodify(bufname("%"), ":p")
12058 exe "e " . fnameescape(buf)
12061 exe gotowinnr . " wincmd w"
12062 exe "e " . fnameescape(buf)
12065 "if we were asked to close the window
12066 if a:closebuffer == 1
12067 exe "bdelete " . tocbufnr
12070 "finally, set the position
12071 call setpos('.', [0, nr, 1, 0])
12077 function! <SID>yank(arg) " {{{
12078 let labels_window = expand("%") == "__Labels__" ? 1 : 0
12080 let l:toc=getbufline("%",1,"$")
12081 let l:h_line=index(reverse(copy(l:toc)),'')+1
12082 if line(".") > len(l:toc)-l:h_line
12086 let l:cbufnr=bufnr("")
12087 let file_name=s:file()
12090 if exists("t:atp_labels") || get(t:atp_labels, file_name, "nofile") != "nofile"
12091 " set t:atp_labels variable
12092 call atplib#generatelabels(getbufvar(s:file(), 'atp_MainFile'), 0)
12095 let line = s:getlinenr(line("."), labels_window)
12096 let choice = get(get(filter(get(deepcopy(t:atp_labels), file_name, []), 'v:val[0] == line'), 0, []), 1 , 'nokey')
12098 if exists("t:atp_labels") || get(t:atp_labels, file_name, "nofile") != "nofile"
12099 let line_nr = s:getlinenr(line("."), labels_window)
12100 let choice_list = filter(get(deepcopy(t:atp_labels), file_name), "v:val[0] == line_nr" )
12101 " There should be just one element in the choice list
12102 " unless there are two labels in the same line.
12103 let choice = choice_list[0][1]
12105 let choice = "nokey"
12109 if choice == "nokey"
12110 " in TOC, if there is a key we will give it back if not:
12111 au! CursorHold __ToC__
12112 echomsg "There is no key."
12114 au CursorHold __ToC__ :call EchoLine()
12118 let l:letter=input("To which register? <reg name><Enter> or empty for none ")
12119 silent if l:letter == 'a'
12121 elseif l:letter == 'b'
12123 elseif l:letter == 'c'
12125 elseif l:letter == 'd'
12127 elseif l:letter == 'e'
12129 elseif l:letter == 'f'
12131 elseif l:letter == 'g'
12133 elseif l:letter == 'h'
12135 elseif l:letter == 'i'
12137 elseif l:letter == 'j'
12139 elseif l:letter == 'k'
12141 elseif l:letter == 'l'
12143 elseif l:letter == 'm'
12145 elseif l:letter == 'n'
12147 elseif l:letter == 'o'
12149 elseif l:letter == 'p'
12151 elseif l:letter == 'q'
12153 elseif l:letter == 'r'
12155 elseif l:letter == 's'
12157 elseif l:letter == 't'
12159 elseif l:letter == 'u'
12161 elseif l:letter == 'v'
12163 elseif l:letter == 'w'
12165 elseif l:letter == 'x'
12167 elseif l:letter == 'y'
12169 elseif l:letter == 'z'
12171 elseif l:letter == '*'
12173 elseif l:letter == '+'
12175 elseif l:letter == '-'
12178 elseif a:arg == 'p'
12180 let l:gotowinnr=s:gotowinnr()
12181 exe l:gotowinnr . " wincmd w"
12183 " delete the buffer
12184 " exe "bdelete " . l:cbufnr
12187 let l:line=getline('.')
12188 let l:colpos=getpos('.')[2]
12190 let l:bline=strpart(l:line, 0, l:colpos)
12191 let l:eline=strpart(l:line, l:colpos)
12193 let l:bline=strpart(l:line, 0, l:colpos-1)
12194 let l:eline=strpart(l:line, l:colpos-1)
12196 call setline('.',l:bline . choice . l:eline)
12197 call setpos('.',[getpos('.')[0],getpos('.')[1],getpos('.')[2]+len(choice),getpos('.')[3]])
12201 command! -buffer P :call Yank("p")
12204 if !exists("*YankToReg")
12205 function! YankToReg()
12206 call <SID>yank("@")
12210 if !exists("*Paste")
12212 call <SID>yank("p")
12215 command! -buffer -nargs=1 Y :call YankToReg(<f-arg>)
12217 " Show Label Context
12218 " {{{1 ShowLabelContext
12219 if !exists("*ShowLabelContext")
12220 function! ShowLabelContext()
12221 let labels_window = expand("%") == "__Labels__" ? 1 : 0
12223 let toc = getbufline("%",1,"$")
12224 let h_line = index(reverse(copy(toc)),'')+1
12225 if line(".") > len(toc)-h_line
12229 let cbuf_name = bufname('%')
12230 let buf_name = s:file()
12231 let buf_nr = bufnr("^" . buf_name . "$")
12232 let win_nr = bufwinnr(buf_name)
12233 let g:buf_name = buf_name
12234 let g:win_nr = win_nr
12235 let line = s:getlinenr(line("."), labels_window)
12236 if !exists("t:atp_labels")
12237 let t:atp_labels=UpdateLabels(buf_name)
12239 exe win_nr . " wincmd w"
12241 " exe "e #" . buf_nr
12243 exe "split #" . buf_nr
12244 call setpos('.', [0, line, 1, 0])
12250 if !exists("*EchoLine")
12251 function! EchoLine()
12253 " If we are not on a toc/label line
12255 if !s:getlinenr(line("."))
12259 let labels_window = expand("%") == "__Labels__" ? 1 : 0
12261 let toc = getbufline("%",1,"$")
12262 let h_line = index(reverse(copy(toc)),'')+1
12263 " if line(".") > len(toc)-h_line
12267 let buf_name = s:file()
12268 let buf_nr = bufnr("^" . buf_name . "$")
12269 if !exists("t:atp_labels")
12270 let t:atp_labels[buf_name] = UpdateLabels(buf_name)[buf_name]
12272 let line = s:getlinenr(line("."), labels_window)
12273 let sec_line = join(getbufline(buf_name,line))
12274 let g:sec_line = sec_line
12277 if sec_line =~ '\\subparagraph[^\*]'
12278 let sec_type="subparagraph "
12279 elseif sec_line =~ '\\subparagraph\*'
12280 let sec_type="subparagraph* "
12281 elseif sec_line =~ '\\paragraph[^\*]'
12282 let sec_type="paragraph "
12283 elseif sec_line =~ '\\paragraph\*'
12284 let sec_type="paragraph* "
12285 elseif sec_line =~ '\\subsubsection[^\*]'
12286 let sec_type="subsubsection "
12287 elseif sec_line =~ '\\subsubsection\*'
12288 let sec_type="subsubsection*"
12289 elseif sec_line =~ '\\subsection[^\*]'
12290 let sec_type="subsection "
12291 elseif sec_line =~ '\\subsection\*'
12292 let sec_type="subsection* "
12293 elseif sec_line =~ '\\section[^\*]'
12294 let sec_type="section "
12295 elseif sec_line =~ '\\section\*'
12296 let sec_type="section* "
12297 elseif sec_line =~ '\\chapter[^\*]'
12298 let sec_type="chapter "
12299 elseif sec_line =~ '\\chapter\*'
12300 let sec_type="chapter* "
12301 elseif sec_line =~ '\\part[^\*]'
12302 let sec_type="part "
12303 elseif sec_line =~ '\\part\*'
12304 let sec_type="part* "
12305 elseif sec_line =~ '\\bibliography'
12306 let sec_type="bibliography "
12307 elseif sec_line =~ '\\abstract\|\\begin\s*{\s*abstract\s*}'
12308 let sec_type="abstract "
12309 elseif sec_line =~ '\\documentclass'
12310 let sec_type="preambule "
12312 let sec_type = toupper(sec_type)
12313 if expand("%") == "__Labels__"
12314 let sec_type="TYPE "
12317 let label = matchstr(sec_line,'\\label\s*{\zs[^}]*\ze}')
12318 let section = strpart(sec_line,stridx(sec_line,'{')+1,stridx(sec_line,'}')-stridx(sec_line,'{')-1)
12319 if section != "" && label != ""
12320 echo sec_type . " : '" . section . "'\t label : " . label
12321 elseif section != ""
12322 echo sec_type . " : '" . section . "'"
12329 setl updatetime=200
12331 au CursorHold __ToC__ :call EchoLine()
12335 " Compare Numbers Function {{{1
12336 function! s:CompareNumbers(i1, i2)
12337 return str2nr(a:i1) == str2nr(a:i2) ? 0 : str2nr(a:i1) > str2nr(a:i2) ? 1 : -1
12340 " DeleteSection, PasteSection, SectionStack, Undo
12342 " Stack of sections that were removed but not yet paste
12343 " each entry is a list [ section title , list of deleted lines, section_nr ]
12344 " where the section title is the one from t:atp_toc[filename][2]
12345 " section_nr is the section number before deletion
12346 " the recent positions are put in the front of the list
12347 if expand("%") == "__ToC__"
12348 if !exists("t:atp_SectionStack")
12349 let t:atp_SectionStack = []
12352 function! s:DeleteSection()
12354 " if under help lines do nothing:
12355 let toc_line = getbufline("%",1,"$")
12356 let h_line = index(reverse(copy(toc_line)),'')+1
12357 if line(".") > len(toc_line)-h_line
12361 let s:deleted_section = toc_line
12363 " Get the name and path of the file
12365 let file_name = s:file()
12367 let begin_line = s:getlinenr()
12368 let section_nr = s:getsectionnr()
12369 let toc = deepcopy(t:atp_toc[file_name])
12370 let type = toc[begin_line][0]
12372 " Only some types are supported:
12373 if count(['bibliography', 'subsubsection', 'subsection', 'section', 'chapter', 'part'], type) == 0
12374 echo type . " is not supported"
12379 " Find the end of the section:
12380 " part is ended by part
12381 " chapter is ended by part or chapter
12382 " section is ended by part or chapter or section
12384 " bibliography is ended by like subsubsection.
12386 let type_pattern = 'part\|bibliography'
12387 elseif type == 'chapter'
12388 let type_pattern = 'chapter\|part\|bibliography'
12389 elseif type == 'section'
12390 let type_pattern = '\%(sub\)\@<!section\|chapter\|part\|bibliography'
12391 elseif type == 'subsection'
12392 let type_pattern = '\%(sub\)\@<!\%(sub\)\=section\|chapter\|part\|bibliography'
12393 elseif type == 'subsubsection' || type == 'bibliography'
12394 let type_pattern = '\%(sub\)*section\|chapter\|part\|bibliography'
12396 let title = toc[begin_line][2]
12397 call filter(toc, 'str2nr(v:key) > str2nr(begin_line)')
12399 let bibliography = 0
12401 for line in sort(keys(toc), "s:CompareNumbers")
12402 if toc[line][0] =~ type_pattern
12403 let end_line = line-1
12404 if toc[line][0] =~ 'bibliography'
12405 let bibliography = 1
12411 if end_line == -1 && &l:filetype == "plaintex"
12412 echomsg "ATP can not delete last section in plain tex files :/"
12418 let gotowinnr = s:gotowinnr()
12421 exe gotowinnr . " wincmd w"
12423 exe gotowinnr . " wincmd w"
12424 exe "e " . fnameescape(file_name)
12427 "finally, set the position
12428 call setpos('.',[0,begin_line,1,0])
12430 if end_line != -1 && !bibliography
12431 call setpos('.',[0, end_line, 1, 0])
12432 elseif bibliography
12433 call setpos('.',[0, end_line, 1, 0])
12434 let end_line = search('^\s*$', 'cbnW')-1
12435 elseif end_line == -1
12436 let end_line = search('\ze\\end\s*{\s*document\s*}')
12441 let deleted_section = split(@*, '\n')
12442 if deleted_section[0] !~ '^\s*$'
12443 call extend(deleted_section, [' '], 0)
12446 " Update the Table of Contents
12447 call remove(t:atp_toc[file_name], begin_line)
12449 for line in keys(t:atp_toc[file_name])
12450 if str2nr(line) < str2nr(begin_line)
12451 call extend(new_toc, { line : t:atp_toc[file_name][line] })
12453 call extend(new_toc, { line-len(deleted_section) : t:atp_toc[file_name][line] })
12456 let t:atp_toc[file_name] = new_toc
12457 " Being still in the tex file make backup:
12458 if exists("g:atp_SectionBackup")
12459 call extend(g:atp_SectionBackup, [[title, type, deleted_section, section_nr, expand("%:p")]], 0)
12461 let g:atp_SectionBackup = [[title, type, deleted_section, section_nr, expand("%:p")]]
12466 " Update the stack of deleted sections
12467 call extend(t:atp_SectionStack, [[title, type, deleted_section, section_nr]],0)
12469 command! -buffer DeleteSection :call <SID>DeleteSection()
12470 " nnoremap dd :call <SID>DeleteSection()<CR>
12472 " Paste the section from the stack
12473 " just before where the next section starts.
12474 " type = p/P like paste p/P.
12475 " a:1 - the number of the section in the stack (from 1,...)
12476 " - by default it is the last one.
12477 function! s:PasteSection(type, ...)
12479 let stack_number = a:0 >= 1 ? a:1-1 : 0
12480 let g:stack_number = stack_number
12482 if !len(t:atp_SectionStack)
12484 echomsg "The stack of deleted sections is empty"
12488 let buffer = s:file()
12491 if a:type ==# "P" || line(".") == 1
12493 let g:line = line(".")
12494 let begin_line = s:getlinenr((line(".")))
12497 let g:line = line(".")+1
12498 let begin_line = s:getlinenr((line(".")+1))
12499 if begin_line == ""
12500 let begin_line = "last_line"
12503 let g:begin_line = begin_line
12506 let gotowinnr = s:gotowinnr()
12509 exe gotowinnr . " wincmd w"
12511 exe gotowinnr . " wincmd w"
12512 exe "e " . fnameescape(buffer)
12515 if begin_line != ""
12516 if begin_line != "last_line"
12517 call setpos(".", begin_line-1)
12519 keepjumps call setpos(".", [0, line("$"), 1, 0])
12520 keepjumps exe "normal $"
12521 keepjumps call search('\n.*\\end\s*{\s*document\s*}', 'bW')
12522 let begin_line = line(".")
12523 let g:linenr = line(".")
12525 elseif &l:filetype != 'plaintex'
12526 keepjumps let begin_line = search('\\end\s*{\s*document\s*}', 'nw')
12528 echo "Pasting at the end is not supported for plain tex documents"
12531 let number = len(t:atp_SectionStack)-1
12532 " Append the section
12533 call append(begin_line-1, t:atp_SectionStack[stack_number][2])
12534 " Set the cursor position to the begining of moved section and add it to
12536 call setpos(".", [0, begin_line, 1, 0])
12538 " Regenerate the Table of Contents:
12542 call remove(t:atp_SectionStack, stack_number)
12544 command! -buffer -nargs=? PasteSection :call <SID>PasteSection('p', <f-args>)
12546 " Lists title of sections in the t:atp_SectionStack
12547 function! s:SectionStack()
12548 if len(t:atp_SectionStack) == 0
12549 echomsg "Section stack is empty"
12554 echo "Stack Number/Type/Title"
12556 for section in t:atp_SectionStack
12557 call add(msg, i . "/" . section[1] . " " . section[3] . "/" . section[0])
12560 call input(join(msg + [ "Press <Enter>" ] , "\n"))
12562 command! -buffer SectionStack :call <SID>SectionStack()
12564 " Undo in the winnr under the cursor.
12565 " a:1 is one off u or U, default is u.
12566 function! s:Undo(...)
12567 let cmd = ( a:0 >= 1 && a:1 =~ '\cu\|g\%(-\|+\)' ? a:1 : 'u' )
12568 let winnr = s:gotowinnr()
12569 exe winnr . " wincmd w"
12570 exe "normal! " . cmd
12573 command! -buffer -nargs=? Undo :call <SID>Undo(<f-args>)
12574 nnoremap <buffer> u :call <SID>Undo('u')<CR>
12575 nnoremap <buffer> U :call <SID>Undo('U')<CR>
12576 nnoremap <buffer> g- :call <SID>Undo('g-')<CR>
12577 nnoremap <buffer> g+ :call <SID>Undo('g+')<CR>
12581 function! Help() " {{{1
12582 " Note: here they are not well indented, but in the output they are :)
12583 echo "Available Mappings:"
12584 echo "q close ToC window"
12585 echo "<CR> go to and close"
12586 echo "<space> go to"
12587 echo "c or y yank the label to a register"
12588 echo "p or P yank and paste the label (in the source file)"
12589 echo "e echo the title to command line"
12590 if expand("%") == "__ToC__"
12591 echo ":DeleteSection Delete section under the cursor"
12592 echo ":PasteSection [<arg>] Paste section from section stack"
12593 echo ":SectionStack Show section stack"
12596 echo "<F1> this help message"
12599 function! s:CursorLine() "{{{1
12600 if s:getlinenr(line(".")) && !&l:cursorline
12602 elseif !s:getlinenr(line(".")) && &l:cursorline
12606 augroup ATP_CursorLine
12607 au CursorMoved,CursorMovedI __ToC__ call s:CursorLine()
12611 if !exists("no_plugin_maps") && !exists("no_atp_toc_maps")
12612 map <silent> <buffer> q :bdelete<CR>
12613 map <silent> <buffer> <CR> :call GotoLine(1)<CR>
12614 map <silent> <buffer> <space> :call GotoLine(0)<CR>
12615 " This does not work:
12616 " noremap <silent> <buffer> <LeftMouse> :call GotoLine(0)<CR>
12617 " when the cursor is in another buffer (and the option mousefocuse is not
12618 " set) it calles the command instead of the function, I could add a check if
12619 " mouse is over the right buffer. With mousefocuse it also do not works very
12621 map <silent> <buffer> c :call YankToReg()<CR>
12622 map <silent> <buffer> y :call YankToReg()<CR>
12623 map <silent> <buffer> p :call Paste()<CR>
12624 map <silent> <buffer> P :call <SID>yank("P")<CR>
12625 map <silent> <buffer> s :call ShowLabelContext()<CR>
12626 map <silent> <buffer> e :call EchoLine()<CR>
12627 map <silent> <buffer> <F1> :call Help()<CR>
12629 autoload/atplib.vim [[[1
12631 " Title: Vim library for ATP filetype plugin.
12632 " Author: Marcin Szamotulski
12633 " Email: mszamot [AT] gmail [DOT] com
12634 " Note: This file is a part of Automatic Tex Plugin for Vim.
12635 " URL: https://launchpad.net/automatictexplugin
12638 " Outdir: append to '/' to b:atp_OutDir if it is not present.
12639 function! atplib#outdir() "{{{1
12640 if has("win16") || has("win32") || has("win64") || has("win95")
12641 if b:atp_OutDir !~ "\/$"
12642 let b:atp_OutDir=b:atp_OutDir . "\\"
12645 if b:atp_OutDir !~ "\/$"
12646 let b:atp_OutDir=b:atp_OutDir . "/"
12649 return b:atp_OutDir
12652 " Return {path} relative to {rel}, if not under {rel} return {path}
12653 function! atplib#RelativePath(path, rel) "{{{1
12654 let current_dir = getcwd()
12656 let rel_path = fnamemodify(a:path, ':.')
12657 exe "cd " . current_dir
12662 function! atplib#FullPath(file_name) "{{{1
12664 if a:file_name =~ '^\s*\/'
12665 let file_path = a:file_name
12667 exe "lcd " . b:atp_ProjectDir
12668 let file_path = fnamemodify(a:file_name, ":p")
12675 " Toggle On/Off Completion
12676 " {{{1 atplib#OnOffComp
12677 function! atplib#OnOffComp(ArgLead, CmdLine, CursorPos)
12678 return filter(['on', 'off'], 'v:val =~ "^" . a:ArgLead')
12683 " a:1 - pattern or a file name
12684 " a:1 is regarded as a filename if filereadable(pattern) is non
12686 function! atplib#Open(bang, dir, TypeDict, ...)
12689 echomsg "You have to set g:atp_LibraryPath in your vimrc or atprc file."
12694 let pattern = ( a:0 >= 1 ? a:1 : "")
12695 let file = filereadable(pattern) ? pattern : ""
12698 if a:bang == "!" || !exists("g:atp_Library")
12699 let g:atp_Library = filter(split(globpath(a:dir, "*"), "\n"), 'count(keys(a:TypeDict), fnamemodify(v:val, ":e"))')
12700 let found = deepcopy(g:atp_Library)
12702 let found = deepcopy(g:atp_Library)
12704 call filter(found, "fnamemodify(v:val, ':t') =~ pattern")
12705 " Resolve symlinks:
12706 call map(found, "resolve(v:val)")
12707 " Remove double entries:
12708 call filter(found, "count(found, v:val) == 1")
12711 echo "Found files:"
12715 if len(map(copy(found), "v:val =~ escape(fnamemodify(file, ':t'), '~') . '$'")) == 1
12716 echo i . ") " . fnamemodify(file, ":t")
12718 echo i . ") " . pathshorten(fnamemodify(file, ":p"))
12722 let choice = input("Which file to open? ")-1
12726 let file = found[choice]
12727 elseif len(found) == 1
12728 let file = found[0]
12731 echomsg "Nothing found."
12737 let ext = fnamemodify(file, ":e")
12738 let viewer = get(a:TypeDict, ext, 0)
12742 echomsg "Filetype: " . ext . " is not supported, add an entry to g:atp_OpenTypeDict"
12745 if viewer !~ '^\s*cat\s*$' && viewer !~ '^\s*g\=vim\s*$' && viewer !~ '^\s*edit\s*$' && viewer !~ '^\s*tabe\s*$' && viewer !~ '^\s*split\s*$'
12746 call system(viewer . " '" . file . "' &")
12747 elseif viewer =~ '^\s*g\=vim\s*$' || viewer =~ '^\s*tabe\s*$'
12748 exe "tabe " . fnameescape(file)
12750 elseif viewer =~ '^\s*edit\s*$' || viewer =~ '^\s*split\s*$'
12751 exe viewer . " " . fnameescape(file)
12753 elseif viewer == '^\s*cat\s*'
12756 echo "cat '" . file . "'"
12758 echo system(viewer . " '" . file . "' &")
12760 " if fnamemodify(file, ":t") != "" && count(g:atp_open_completion, fnamemodify(file, ":t")) == 0
12761 " call extend(g:atp_open_completion, [fnamemodify(file, ":t")], 0)
12763 " This removes the hit Enter vim prompt.
12764 call feedkeys("<CR>")
12769 " Find Vim Server: find server 'hosting' a file and move to the line.
12770 " {{{1 atplib#FindAndOpen
12771 " Can be used to sync gvim with okular.
12772 " just set in okular:
12773 " settings>okular settings>Editor
12774 " Editor Custom Text Editor
12775 " Command gvim --servername GVIM --remote-expr "atplib#FindAndOpen('%f','%l')"
12776 " You can also use this with vim but you should start vim with
12777 " vim --servername VIM
12778 " and use servername VIM in the Command above.
12779 function! atplib#FindAndOpen(file, line)
12780 let file = fnamemodify(a:file, ":p:r") . ".tex"
12781 let server_list = split(serverlist(), "\n")
12782 for server in server_list
12783 if remote_expr(server, "bufexists('".file."')")
12784 let use_server = server
12787 let use_server = "GVIM"
12790 call system("gvim --servername " . use_server . " --remote-wait +" . a:line . " " . file . " &")
12791 return "File:".file." line:".line. " server name:".use_server." Hitch-hiking server:".v:servername
12795 " Labels Tools: GrepAuxFile, SrotLabels, generatelabels and showlabes.
12797 " the argument should be: resolved full path to the file:
12798 " resove(fnamemodify(bufname("%"),":p"))
12800 " {{{2 --------------- atplib#GrepAuxFile
12801 function! atplib#GrepAuxFile(...)
12802 " Aux file to read:
12803 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
12804 let aux_filename = a:0 == 0 ? fnamemodify(atp_MainFile, ":r") . ".aux" : a:1
12806 if !filereadable(aux_filename)
12807 " We should worn the user that there is no aux file
12808 " /this is not visible ! only after using the command 'mes'/
12810 echomsg "There is no aux file. Run ".b:atp_TexCompiler." first."
12813 " CALL BACK is not working
12814 " I can not get output of: vim --servername v:servername --remote-expr v:servername
12816 " Here we should run latex to produce auxfile
12817 " echomsg "Running " . b:atp_TexCompiler . " to get aux file."
12818 " let labels = system(b:atp_TexCompiler . " -interaction nonstopmode " . atp_MainFile . " 1&>/dev/null 2>1 ; " . " vim --servername ".v:servername." --remote-expr 'atplib#GrepAuxFile()'")
12821 " let aux_file = readfile(aux_filename)
12823 let saved_llist = getloclist(0)
12825 silent execute 'lvimgrep /\\newlabel\s*{/j ' . fnameescape(aux_filename)
12828 let loc_list = getloclist(0)
12829 call setloclist(0, saved_llist)
12830 call map(loc_list, ' v:val["text"]')
12833 " for line in aux_file
12834 for line in loc_list
12835 " if line =~ '^\\newlabel'
12836 " line is of the form:
12837 " \newlabel{<label>}{<rest>}
12838 " where <rest> = {<label_number}{<title>}{<counter_name>.<counter_number>}
12839 " <counter_number> is usually equal to <label_number>.
12841 " Document classes: article, book, amsart, amsbook, review:
12842 " NEW DISCOVERY {\zs\%({[^}]*}\|[^}]\)*\ze} matches for inner part of
12843 " { ... { ... } ... } / only one level of being recursive /
12844 " The order inside the main \%( \| \) is important.
12845 "This is in the case that the author put in the title a command,
12846 "for example \mbox{...}, but not something more difficult :)
12847 if line =~ '^\\newlabel{[^}]*}{{[^}]*}{[^}]*}{\%({[^}]*}\|[^}]\)*}{[^}]*}'
12848 let label = matchstr(line, '^\\newlabel\s*{\zs[^}]*\ze}')
12849 let rest = matchstr(line, '^\\newlabel\s*{[^}]*}\s*{\s*{\zs.*\ze}\s*$')
12853 let l:count = rest[i] == '{' ? l:count+1 : rest[i] == '}' ? l:count-1 : l:count
12856 let number = substitute(strpart(rest,0,i-1), '{\|}', '', 'g')
12857 let rest = strpart(rest,i)
12858 let rest = substitute(rest, '^{[^}]*}{', '', '')
12862 let l:count = rest[i] == '{' ? l:count+1 : rest[i] == '}' ? l:count-1 : l:count
12865 let counter = substitute(strpart(rest,i-1), '{\|}', '', 'g')
12866 let counter = strpart(counter, 0, stridx(counter, '.'))
12868 " Document classes: article, book, amsart, amsbook, review
12869 " (sometimes the format is a little bit different)
12870 elseif line =~ '\\newlabel{[^}]*}{{\d\%(\d\|\.\)*{\d\%(\d\|\.\)*}}{\d*}{\%({[^}]*}\|[^}]\)*}{[^}]*}'
12871 let list = matchlist(line,
12872 \ '\\newlabel{\([^}]*\)}{{\(\d\%(\d\|\.\)*{\d\%(\d\|\.\)*\)}}{\d*}{\%({[^}]*}\|[^}]\)*}{\([^}]*\)}')
12873 let [ label, number, counter ] = [ list[1], list[2], list[3] ]
12874 let number = substitute(number, '{\|}', '', 'g')
12875 let counter = matchstr(counter, '^\w\+')
12877 " Document class: article
12878 elseif line =~ '\\newlabel{[^}]*}{{\d\%(\d\|\.\)*}{\d\+}}'
12879 let list = matchlist(line, '\\newlabel{\([^}]*\)}{{\(\d\%(\d\|\.\)*\)}{\d\+}}')
12880 let [ label, number, counter ] = [ list[1], list[2], "" ]
12882 " Memoir document class uses '\M@TitleReference' command
12883 " which doesn't specify the counter number.
12884 elseif line =~ '\\M@TitleReference'
12885 let label = matchstr(line, '^\\newlabel\s*{\zs[^}]*\ze}')
12886 let number = matchstr(line, '\\M@TitleReference\s*{\zs[^}]*\ze}')
12890 elseif line =~ '\\newlabel{[^}]*}{{\d\%(\d\|.\)*{\d\%(\d\|.\)*}{[^}]*}}'
12891 let label = matchstr(line, '\\newlabel{\zs[^}]*\ze}{{\d\%(\d\|.\)*{\d\%(\d\|.\)*}{[^}]*}}')
12892 let number = matchstr(line, '\\newlabel{\zs[^}]*\ze}{{\zs\d\%(\d\|.\)*{\d\%(\d\|.\)*\ze}{[^}]*}}')
12893 let number = substitute(number, '{\|}', '', 'g')
12897 elseif line =~ '\\newlabel{[^}]*}{{[^}]*}{[^}]*}}'
12898 let list = matchlist(line, '\\newlabel{\([^}]*\)}{{\([^}]*\)}{\([^}]*\)}}')
12899 let [ label, number ] = [ list[1], list[2] ]
12902 " AMSBook uses \newlabel for tocindent
12903 " which we filter out here.
12905 let label = "nolabel"
12907 if label != 'nolabel'
12908 call add(labels, [ label, number, counter])
12916 " Sorting function used to sort labels.
12917 " {{{2 --------------- atplib#SortLabels
12918 " It compares the first component of lists (which is line number)
12919 " This should also use the bufnr.
12920 function! atplib#SortLabels(list1, list2)
12921 if a:list1[0] == a:list2[0]
12923 elseif str2nr(a:list1[0]) > str2nr(a:list2[0])
12930 " Function which find all labels and related info (label number, lable line
12931 " number, {bufnr} <= TODO )
12932 " {{{2 --------------- atplib#generatelabels
12933 " This function runs in two steps:
12934 " (1) read lables from aux files using GrepAuxFile()
12935 " (2) search all input files (TreeOfFiles()) for labels to get the line
12937 " [ this is done using :vimgrep which is fast, when the buffer are not loaded ]
12938 function! atplib#generatelabels(filename, ...)
12940 let bufname = fnamemodify(a:filename,":t")
12941 let auxname = fnamemodify(a:filename,":p:r") . ".aux"
12942 let return_ListOfFiles = a:0 >= 1 ? a:1 : 1
12947 let aux_labels = atplib#GrepAuxFile(auxname)
12949 let saved_pos = getpos(".")
12952 let [ TreeofFiles, ListOfFiles, DictOfFiles, LevelDict ] = TreeOfFiles(a:filename, '\\\(input\|include\)\s*{')
12953 if count(ListOfFiles, a:filename) == 0
12954 call add(ListOfFiles, a:filename)
12956 let saved_llist = getloclist(0)
12957 call setloclist(0, [])
12959 " Look for labels in all input files.
12960 for file in ListOfFiles
12961 let file = atplib#FullPath(file)
12962 silent! execute "lvimgrepadd /\\label\s*{/j " . fnameescape(file)
12964 let loc_list = getloclist(0)
12965 " call setloclist(0, saved_llist)
12966 call map(loc_list, '[ v:val["lnum"], v:val["text"], v:val["bufnr"] ]')
12970 for label in aux_labels
12971 let dict = filter(copy(loc_list), "v:val[1] =~ '\\label\s*{\s*'.escape(label[0], '*\/$.') .'\s*}'")
12972 let line = get(get(dict, 0, []), 0, "")
12973 let bufnr = get(get(dict, 0, []), 2, "")
12974 let bufname = fnamemodify(bufname(bufnr), ":p")
12975 if get(labels, bufname, []) == []
12976 let labels[bufname] = [ [line, label[0], label[1], label[2], bufnr ] ]
12978 call add(labels[bufname], [line, label[0], label[1], label[2], bufnr ])
12982 for bufname in keys(labels)
12983 call sort(labels[bufname], "atplib#SortLabels")
12987 " while i < len(texfile)
12988 " if texfile[i] =~ '\\label\s*{'
12989 " let lname = matchstr(texfile[i], '\\label\s*{.*', '')
12990 " let start = stridx(lname, '{')+1
12991 " let lname = strpart(lname, start)
12992 " let end = stridx(lname, '}')
12993 " let lname = strpart(lname, 0, end)
12994 " "This can be extended to have also the whole environment which
12996 " call extend(s:labels, { i+1 : lname })
13001 if exists("t:atp_labels")
13002 call extend(t:atp_labels, labels, "force")
13004 let t:atp_labels = labels
13006 keepjumps call setpos(".", saved_pos)
13007 if return_ListOfFiles
13008 return [ t:atp_labels, ListOfFiles ]
13010 return t:atp_labels
13014 " This function opens a new window and puts the results there.
13015 " {{{2 --------------- atplib#showlabels
13016 " the argument is [ t:atp_labels, ListOfFiles ]
13017 " where ListOfFiles is the list returne by TreeOfFiles()
13018 function! atplib#showlabels(labels)
13020 " the argument a:labels=t:atp_labels[bufname("")] !
13021 let l:cline=line(".")
13023 let saved_pos = getpos(".")
13025 " Open new window or jump to the existing one.
13026 let l:bufname = bufname("")
13027 let l:bufpath = fnamemodify(resolve(fnamemodify(bufname("%"),":p")),":h")
13028 let BufFullName = fnamemodify(l:bufname, ":p")
13030 let l:bname="__Labels__"
13032 let l:labelswinnr=bufwinnr("^" . l:bname . "$")
13033 let t:atp_labelswinnr=winnr()
13034 let t:atp_labelsbufnr=bufnr("^" . l:bname . "$")
13035 let l:labelswinnr=bufwinnr(t:atp_labelsbufnr)
13038 for file in a:labels[1]
13039 let dict = get(a:labels[0], file, [])
13040 let tabstop = max([tabstop, max(map(copy(dict), "len(v:val[2])")) + 1])
13043 let g:tabstop = tabstop " DEBUG
13044 let g:labelswinnr = l:labelswinnr
13045 let saved_view = winsaveview()
13047 if l:labelswinnr != -1
13048 " Jump to the existing window.
13049 exe l:labelswinnr . " wincmd w"
13050 if l:labelswinnr != t:atp_labelswinnr
13051 silent exe "%delete"
13053 echoerr "ATP error in function s:showtoc, TOC/LABEL buffer
13054 \ and the tex file buffer agree."
13059 " Open new window if its width is defined (if it is not the code below
13060 " will put lab:cels in the current buffer so it is better to return.
13061 if !exists("t:atp_labels_window_width")
13062 echoerr "t:atp_labels_window_width not set"
13066 " tabstop option is set to be the longest counter number + 1
13067 let l:openbuffer= t:atp_labels_window_width . "vsplit +setl\\ tabstop=" . tabstop . "\\ nowrap\\ buftype=nofile\\ filetype=toc_atp\\ syntax=labels_atp __Labels__"
13068 keepalt silent exe l:openbuffer
13069 silent call atplib#setwindow()
13070 let t:atp_labelsbufnr=bufnr("")
13072 unlockvar b:atp_Labels
13073 let b:atp_Labels = {}
13076 for file in a:labels[1]
13077 call setline("$", fnamemodify(file, ":t") . " (" . fnamemodify(file, ":h") . ")")
13078 call extend(b:atp_Labels, { 1 : [ file, 0 ]})
13079 for label in get(a:labels[0], file, [])
13080 " Set line in the format:
13081 " /<label_numberr> \t[<counter>] <label_name> (<label_line_nr>)/
13082 " if the <counter> was given in aux file (see the 'counter' variable in atplib#GrepAuxFile())
13084 " /it is more complecated because I want to make it as tight as
13085 " possible and as nice as possible :)
13086 " the first if checks if there are counters, then counter type is
13087 " printed, then the tabs are set./
13088 " let slen = winwidth(0)-tabstop-5-5
13089 " let space_len = max([1, slen-len(label[1])])
13090 if tabstop+(len(label[3][0])+3)+len(label[1])+(len(label[0])+2) < winwidth(0)
13091 let space_len = winwidth(0)-(tabstop+(len(label[3][0])+3)+len(label[1])+(len(label[0])+2))
13095 let space = join(map(range(space_len), '" "'), "")
13096 let set_line = label[2] . "\t[" . label[3][0] . "] " . label[1] . space . "(" . label[0] . ")"
13097 call setline(line_nr, set_line )
13098 cal extend(b:atp_Labels, { line_nr : [ file, label[0] ]})
13102 lockvar 3 b:atp_Labels
13104 " set the cursor position on the correct line number.
13105 call search(l:bufname, 'w')
13108 for label in get(a:labels[0], BufFullName, [])
13109 if l:cline >= label[0]
13110 " echo "1 " . label[0]
13111 keepjumps call cursor(line(".")+1, col("."))
13112 elseif l:number == 1 && l:cline < label[0]
13113 " echo "2 " . label[0]
13114 keepjumps call cursor(line(".")+1, col("."))
13122 " Various Comparing Functions:
13123 "{{{1 atplib#CompareNumbers
13124 function! atplib#CompareNumbers(i1, i2)
13125 return str2nr(a:i1) == str2nr(a:i2) ? 0 : str2nr(a:i1) > str2nr(a:i2) ? 1 : -1
13128 " {{{1 atplib#CompareCoordinates
13129 " Each list is an argument with two values:
13130 " listA=[ line_nrA, col_nrA] usually given by searchpos() function
13131 " listB=[ line_nrB, col_nrB]
13132 " returns 1 iff A is smaller than B
13133 fun! atplib#CompareCoordinates(listA,listB)
13134 if a:listA[0] < a:listB[0] ||
13135 \ a:listA[0] == a:listB[0] && a:listA[1] < a:listB[1] ||
13137 " the meaning of the last is that if the searchpos() has not found the
13138 " beginning (a:listA) then it should return 1 : the env is not started.
13145 " {{{1 atplib#CompareCoordinates_leq
13146 " Each list is an argument with two values!
13147 " listA=[ line_nrA, col_nrA] usually given by searchpos() function
13148 " listB=[ line_nrB, col_nrB]
13149 " returns 1 iff A is smaller or equal to B
13150 function! atplib#CompareCoordinates_leq(listA,listB)
13151 if a:listA[0] < a:listB[0] ||
13152 \ a:listA[0] == a:listB[0] && a:listA[1] <= a:listB[1] ||
13154 " the meaning of the last is that if the searchpos() has not found the
13155 " beginning (a:listA) then it should return 1 : the env is not started.
13162 " ReadInputFile function reads finds a file in tex style and returns the list
13164 " {{{1 atplib#ReadInputFile
13165 " this function looks for an input file: in the list of buffers, under a path if
13166 " it is given, then in the b:atp_OutDir.
13167 " directory. The last argument if equal to 1, then look also
13169 function! atplib#ReadInputFile(ifile,check_texmf)
13171 let l:input_file = []
13173 " read the buffer or read file if the buffer is not listed.
13174 if buflisted(fnamemodify(a:ifile,":t"))
13175 let l:input_file=getbufline(fnamemodify(a:ifile,":t"),1,'$')
13176 " if the ifile is given with a path it should be tried to read from there
13177 elseif filereadable(a:ifile)
13178 let l:input_file=readfile(a:ifile)
13179 " if not then try to read it from b:atp_OutDir
13180 elseif filereadable(b:atp_OutDir . fnamemodify(a:ifile,":t"))
13181 let l:input_file=readfile(filereadable(b:atp_OutDir . fnamemodify(a:ifile,":t")))
13182 " the last chance is to look for it in the g:texmf directory
13183 elseif a:check_texmf && filereadable(findfile(a:ifile,g:texmf . '**'))
13184 let l:input_file=readfile(findfile(a:ifile,g:texmf . '**'))
13187 return l:input_file
13192 " These are all bibsearch realted variables and functions.
13194 "{{{ atplib#variables
13195 let atplib#bibflagsdict={ 't' : ['title', 'title '] , 'a' : ['author', 'author '],
13196 \ 'b' : ['booktitle', 'booktitle '], 'c' : ['mrclass', 'mrclass '],
13197 \ 'e' : ['editor', 'editor '], 'j' : ['journal', 'journal '],
13198 \ 'f' : ['fjournal', 'fjournal '], 'y' : ['year', 'year '],
13199 \ 'n' : ['number', 'number '], 'v' : ['volume', 'volume '],
13200 \ 's' : ['series', 'series '], 'p' : ['pages', 'pages '],
13201 \ 'P' : ['publisher', 'publisher '], 'N' : ['note', 'note '],
13202 \ 'S' : ['school', 'school '], 'h' : ['howpublished', 'howpublished '],
13203 \ 'o' : ['organization', 'organization '], 'I' : ['institution' , 'institution '],
13204 \ 'u' : ['url', 'url '],
13205 \ 'H' : ['homepage', 'homepage '], 'i' : ['issn', 'issn '],
13206 \ 'k' : ['key', 'key '], 'R' : ['mrreviewer', 'mrreviewer ']}
13207 " they do not work in the library script :(
13208 " using g:bibflags... .
13209 " let atplib#bibflagslist=keys(atplib#bibflagsdict)
13210 " let atplib#bibflagsstring=join(atplib#bibflagslist,'')
13212 " This functions finds bibfiles defined in the tex source file.
13213 "{{{ atplib#searchbib
13214 " ToDo should not search in comment lines.
13216 " To make it work after kpsewhich is searching for bib path.
13217 " let s:bibfiles=FindBibFiles(bufname('%'))
13218 function! atplib#searchbib(pattern, ...)
13220 call atplib#outdir()
13221 " for tex files this should be a flat search.
13222 let flat = &filetype == "plaintex" ? 1 : 0
13223 let bang = a:0 >=1 ? a:1 : ""
13224 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
13226 " Caching bibfiles saves 0.27sec.
13227 if !exists("b:ListOfFiles") || !exists("b:TypeDict") || bang == "!"
13228 let [ TreeOfFiles, ListOfFiles, TypeDict, LevelDict ] = TreeOfFiles(atp_MainFile, '^[^%]*\\bibliography\s*{', flat)
13230 let [ ListOfFiles, TypeDict ] = deepcopy([ b:ListOfFiles, b:TypeDict ])
13232 let s:bibfiles = []
13233 for f in ListOfFiles
13234 " let f = atplib#FullPath(f)
13235 if TypeDict[f] == 'bib'
13236 call add(s:bibfiles, f)
13239 let b:atp_BibFiles = deepcopy(s:bibfiles)
13242 " Make a pattern which will match for the elements of the list g:bibentries
13243 let pattern = '^\s*@\%(\<'.g:bibentries[0].'\>'
13244 for bibentry in g:bibentries['1':len(g:bibentries)]
13245 let pattern = pattern . '\|\<' . bibentry . '\>'
13247 let pattern = pattern . '\)'
13248 " This pattern matches all entry lines: author = \| title = \| ...
13249 let pattern_b = '^\s*\%('
13250 for bibentry in keys(g:bibflagsdict)
13251 let pattern_b = pattern_b . '\|\<' . g:bibflagsdict[bibentry][0] . '\>'
13253 let pattern_b.='\)\s*='
13256 redir! >> /tmp/ATP_log
13257 silent! echo "==========atplib#searchbib==================="
13258 silent! echo "atplib#searchbib_bibfiles=" . string(s:bibfiles)
13259 silent! echo "a:pattern=" . a:pattern
13260 silent! echo "pattern=" . pattern
13261 silent! echo "pattern_b=" . pattern_b
13262 silent! echo "bang=" . bang
13263 silent! echo "flat=" . flat
13268 let b:bibentryline={}
13270 " READ EACH BIBFILE IN TO DICTIONARY s:bibdict, WITH KEY NAME BEING THE bibfilename
13273 for l:f in s:bibfiles
13274 let s:bibdict[l:f]=[]
13276 " read the bibfile if it is in b:atp_OutDir or in g:atp_raw_bibinputs directory
13277 " ToDo: change this to look in directories under g:atp_raw_bibinputs.
13278 " (see also ToDo in FindBibFiles 284)
13279 " for l:path in split(g:atp_raw_bibinputs, ',')
13280 " " it might be problem when there are multiple libraries with the
13281 " " same name under different locations (only the last one will
13283 " let s:bibdict[l:f]=readfile(fnameescape(findfile(atplib#append(l:f,'.bib'), atplib#append(l:path,"/") . "**")))
13285 let s:bibdict[l:f]=readfile(l:f)
13286 let l:bibdict[l:f]=copy(s:bibdict[l:f])
13287 " clear the s:bibdict values from lines which begin with %
13288 call filter(l:bibdict[l:f], ' v:val !~ "^\\s*\\%(%\\|@\\cstring\\)"')
13292 redir! >> /tmp/ATP_log
13293 silent! echo "values(l:bibdict) len(l:bibdict[v:val]) = " . string(map(deepcopy(l:bibdict), "len(v:val)"))
13298 for l:f in s:bibfiles
13301 for l:line in l:bibdict[l:f]
13303 " if the line matches find the beginning of this bib field and add its
13304 " line number to the list l:list
13305 " remove ligatures and brackets {,} from the line
13306 let line_without_ligatures = substitute(substitute(l:line,'\C{\|}\|\\\%("\|`\|\^\|=\|\.\|c\|\~\|v\|u\|d\|b\|H\|t\)\s*','','g'), "\\\\'\\s*", '', 'g')
13307 let line_withouf_ligatures = substitute(line_without_ligatures, '\C\\oe', 'oe', 'g')
13308 let line_withouf_ligatures = substitute(line_without_ligatures, '\C\\OE', 'OE', 'g')
13309 let line_withouf_ligatures = substitute(line_without_ligatures, '\C\\ae', 'ae', 'g')
13310 let line_withouf_ligatures = substitute(line_without_ligatures, '\C\\AE', 'AE', 'g')
13311 let line_withouf_ligatures = substitute(line_without_ligatures, '\C\\o', 'o', 'g')
13312 let line_withouf_ligatures = substitute(line_without_ligatures, '\C\\O', 'O', 'g')
13313 let line_withouf_ligatures = substitute(line_without_ligatures, '\C\\i', 'i', 'g')
13314 let line_withouf_ligatures = substitute(line_without_ligatures, '\C\\j', 'j', 'g')
13315 let line_withouf_ligatures = substitute(line_without_ligatures, '\C\\l', 'l', 'g')
13316 let line_withouf_ligatures = substitute(line_without_ligatures, '\C\\L', 'L', 'g')
13318 if line_without_ligatures =~? a:pattern
13321 redir! >> /tmp/ATP_log
13322 silent! echo "line_without_ligatures that matches " . line_without_ligatures
13323 silent! echo "____________________________________"
13333 redir! >> /tmp/ATP_log
13334 silent! echo " l:tnr=" . string(l:tnr) . " l:bibdict[". string(l:f) . "][" . string(l:tnr-1) . "]=" . string(l:bibdict[l:f][l:tnr-1])
13338 " go back until the line will match pattern (which
13339 " should be the beginning of the bib field.
13340 if l:bibdict[l:f][l:tnr-1] =~? pattern && l:tnr >= 0
13342 let l:list=add(l:list,l:tnr)
13353 redir! >> /tmp/ATP_log
13354 silent! echo "A l:list=" . string(l:list)
13358 " CLEAR THE l:list FROM ENTRIES WHICH APPEAR TWICE OR MORE --> l:clist
13359 let l:pentry="A" " We want to ensure that l:entry (a number) and l:pentry are different
13360 for l:entry in l:list
13361 if l:entry != l:pentry
13362 if count(l:list,l:entry) > 1
13363 while count(l:list,l:entry) > 1
13364 let l:eind=index(l:list,l:entry)
13365 call remove(l:list,l:eind)
13368 let l:pentry=l:entry
13372 " This is slower than the algorithm above!
13373 " call sort(filter(l:list, "count(l:list, v:val) == 1"), "atplib#CompareNumbers")
13376 redir! >> /tmp/ATP_log
13377 silent! echo "B l:list=" . string(l:list)
13381 let b:bibentryline=extend(b:bibentryline,{ l:f : l:list })
13384 redir! >> /tmp/ATP_log
13385 silent! echo "atplib#bibsearch b:bibentryline= (pattern != '') " . string(b:bibentryline)
13391 " CHECK EACH BIBFILE
13392 let l:bibresults={}
13393 " if the pattern was empty make it faster.
13395 for l:bibfile in keys(l:bibdict)
13396 let l:bibfile_len=len(l:bibdict[l:bibfile])
13399 while l:nr < l:bibfile_len
13400 let l:line=l:bibdict[l:bibfile][l:nr]
13401 if l:line =~ pattern
13403 let s:lbibd["bibfield_key"]=l:line
13404 let l:beg_line=l:nr+1
13406 let l:line=l:bibdict[l:bibfile][l:nr]
13408 while l:line !~ pattern && l:nr < l:bibfile_len
13409 let l:line=l:bibdict[l:bibfile][l:nr]
13410 let l:lkey=tolower(
13412 \ strpart(l:line,0,
13413 \ stridx(l:line,"=")
13416 " CONCATENATE LINES IF IT IS NOT ENDED
13419 let s:lbibd[l:lkey]=l:line
13420 " IF THE LINE IS SPLIT ATTACH NEXT LINE
13421 " echomsg "l:nr=".l:nr. " line=".l:line
13422 let l:nline=get(l:bibdict[l:bibfile],l:nr+l:y)
13423 while l:nline !~ '=' &&
13424 \ l:nline !~ pattern &&
13425 \ (l:nr+l:y) < l:bibfile_len
13426 let s:lbibd[l:lkey]=substitute(s:lbibd[l:lkey],'\s*$','','') . " ". substitute(get(l:bibdict[l:bibfile],l:nr+l:y),'^\s*','','')
13427 let l:line=get(l:bibdict[l:bibfile],l:nr+l:y)
13428 " echomsg "l:nr=".l:nr. " l:y=".l:y." line=".l:line
13430 let l:nline=get(l:bibdict[l:bibfile],l:nr+l:y)
13432 echoerr "ATP-Error /see :h atp-errors-bibsearch/, missing '}', ')' or '\"' in bibentry (check line " . l:nr . ") in " . l:f . " line=".l:line
13436 if l:nline =~ pattern
13437 " echomsg "BREAK l:nr=".l:nr. " l:y=".l:y." nline=".l:nline
13445 call extend(s:bibd, { l:beg_line : s:lbibd })
13450 let l:bibresults[l:bibfile]=s:bibd
13451 let g:bibresults=l:bibresults
13453 let g:bibresults=l:bibresults
13456 redir! >> /tmp/ATP_log
13457 silent! echo "atplib#searchbib_bibresults A =" . l:bibresults
13461 return l:bibresults
13463 " END OF NEW CODE: (up)
13465 for l:bibfile in keys(b:bibentryline)
13466 let l:f=l:bibfile . ".bib"
13467 "s:bibdict[l:f]) CHECK EVERY STARTING LINE (we are going to read bibfile from starting
13468 " line till the last matching }
13470 for l:linenr in b:bibentryline[l:bibfile]
13472 " new algorithm is on the way, using searchpair function
13475 " let b:pair1=searchpair('(','',')','b')
13476 " let b:pair2=searchpair('{','','}','b')
13477 " let l:true=b:pair1+b:pair2
13478 " while l:true == 0
13479 " let b:pair1p=b:pair1
13480 " let b:pair1=searchpair('(','',')','b')
13481 " let b:pair2p=b:pair2
13482 " let b:pair2=searchpair('{','','}','b')
13485 " let l:bfieldline=l:time
13487 let l:nr=l:linenr-1
13488 let l:i=atplib#count(get(l:bibdict[l:bibfile],l:linenr-1),"{")-atplib#count(get(l:bibdict[l:bibfile],l:linenr-1),"}")
13489 let l:j=atplib#count(get(l:bibdict[l:bibfile],l:linenr-1),"(")-atplib#count(get(l:bibdict[l:bibfile],l:linenr-1),")")
13491 let s:lbibd["bibfield_key"]=get(l:bibdict[l:bibfile],l:linenr-1)
13493 " we go from the first line of bibentry, i.e. @article{ or @article(, until the { and (
13494 " will close. In each line we count brackets.
13495 while l:i>0 || l:j>0
13496 let l:tlnr=l:x+l:linenr
13497 let l:pos=atplib#count(get(l:bibdict[l:bibfile],l:tlnr-1),"{")
13498 let l:neg=atplib#count(get(l:bibdict[l:bibfile],l:tlnr-1),"}")
13499 let l:i+=l:pos-l:neg
13500 let l:pos=atplib#count(get(l:bibdict[l:bibfile],l:tlnr-1),"(")
13501 let l:neg=atplib#count(get(l:bibdict[l:bibfile],l:tlnr-1),")")
13502 let l:j+=l:pos-l:neg
13503 let l:lkey=tolower(
13505 \ strpart(get(l:bibdict[l:bibfile],l:tlnr-1),0,
13506 \ stridx(get(l:bibdict[l:bibfile],l:tlnr-1),"=")
13510 let s:lbibd[l:lkey]=get(l:bibdict[l:bibfile],l:tlnr-1)
13512 " IF THE LINE IS SPLIT ATTACH NEXT LINE
13513 if get(l:bibdict[l:bibfile],l:tlnr-1) !~ '\%()\|}\|"\)\s*,\s*\%(%.*\)\?$'
13514 " \ get(l:bibdict[l:bibfile],l:tlnr) !~ pattern_b
13515 let l:lline=substitute(get(l:bibdict[l:bibfile],l:tlnr+l:y-1),'\\"\|\\{\|\\}\|\\(\|\\)','','g')
13516 let l:pos=atplib#count(l:lline,"{")
13517 let l:neg=atplib#count(l:lline,"}")
13518 let l:m=l:pos-l:neg
13519 let l:pos=atplib#count(l:lline,"(")
13520 let l:neg=atplib#count(l:lline,")")
13521 let l:n=l:pos-l:neg
13522 let l:o=atplib#count(l:lline,"\"")
13523 " this checks if bracets {}, and () and "" appear in pairs in the current line:
13524 if l:m>0 || l:n>0 || l:o>l:o/2*2
13525 while l:m>0 || l:n>0 || l:o>l:o/2*2
13526 let l:pos=atplib#count(get(l:bibdict[l:bibfile],l:tlnr+l:y),"{")
13527 let l:neg=atplib#count(get(l:bibdict[l:bibfile],l:tlnr+l:y),"}")
13528 let l:m+=l:pos-l:neg
13529 let l:pos=atplib#count(get(l:bibdict[l:bibfile],l:tlnr+l:y),"(")
13530 let l:neg=atplib#count(get(l:bibdict[l:bibfile],l:tlnr+l:y),")")
13531 let l:n+=l:pos-l:neg
13532 let l:o+=atplib#count(get(l:bibdict[l:bibfile],l:tlnr+l:y),"\"")
13533 " Let's append the next line:
13534 let s:lbibd[l:lkey]=substitute(s:lbibd[l:lkey],'\s*$','','') . " ". substitute(get(l:bibdict[l:bibfile],l:tlnr+l:y),'^\s*','','')
13537 echoerr "ATP-Error /see :h atp-errors-bibsearch/, missing '}', ')' or '\"' in bibentry at line " . l:linenr . " (check line " . l:tlnr . ") in " . l:f
13544 " we have to go line by line and we could skip l:y+1 lines, but we have to
13545 " keep l:m, l:o values. It do not saves much.
13548 echoerr "ATP-Error /see :h atp-errors-bibsearch/, missing '}', ')' or '\"' in bibentry at line " . l:linenr . " in " . l:f
13555 let s:bibd[l:linenr]=s:lbibd
13558 let l:bibresults[l:bibfile]=s:bibd
13560 let g:bibresults=l:bibresults
13563 redir! >> /tmp/ATP_log
13564 silent! echo "atplib#searchbib_bibresults A =" . string(l:bibresults)
13568 return l:bibresults
13571 " This is the main search engine.
13572 " {{{ atplib#SearchBibItems
13573 " the argument should be b:atp_MainFile but in any case it is made in this way.
13574 " it specifies in which file to search for include files.
13575 function! atplib#SearchBibItems(name)
13577 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
13578 " we are going to make a dictionary { citekey : label } (see :h \bibitem)
13579 let l:citekey_label_dict={}
13581 " make a list of include files.
13582 let l:inputfile_dict=FindInputFiles(a:name,0)
13583 let l:includefile_list=[]
13584 for l:key in keys(l:inputfile_dict)
13585 if l:inputfile_dict[l:key][0] =~# '^\%(include\|input\|includeonly\)$'
13586 call add(l:includefile_list,atplib#append(l:key,'.tex'))
13589 call add(l:includefile_list, atp_MainFile)
13590 " let b:ifl=l:includefile_list
13592 " search for bibitems in all include files.
13593 for l:ifile in l:includefile_list
13595 let l:input_file = atplib#ReadInputFile(l:ifile,0)
13597 " search for bibitems and make a dictionary of labels and citekeys
13598 for l:line in l:input_file
13599 if l:line =~# '\\bibitem'
13600 let l:label=matchstr(l:line,'\\bibitem\s*\[\zs[^]]*\ze\]')
13601 let l:key=matchstr(l:line,'\\bibitem\s*\%(\[[^]]*\]\)\?\s*{\zs[^}]*\ze}')
13602 " if l:label =~ 'bibitem'
13606 call extend(l:citekey_label_dict, { l:key : l:label }, 'error')
13612 return l:citekey_label_dict
13616 "{{{ atplib#showresults
13618 " for currently supported flags see ':h atp_bibflags'
13639 function! atplib#showresults(bibresults, flags, pattern)
13641 "if nothing was found inform the user and return:
13642 if len(a:bibresults) == count(a:bibresults, {})
13643 echo "BibSearch: no bib fields matched."
13645 redir! >> /tmp/ATP_log
13646 silent! echo "==========atplib#showresults================="
13647 silent! echo "atplib#showresults return A - no bib fields matched. "
13651 elseif g:atp_debugBS
13652 redir! >> /tmp/ATP_log
13653 silent! echo "==========atplib#showresults================="
13654 silent! echo "atplib#showresults return B - found something. "
13659 function! s:showvalue(value)
13660 return substitute(strpart(a:value,stridx(a:value,"=")+1),'^\s*','','')
13665 let l:listofkeys={}
13666 "--------------SET UP FLAGS--------------------------
13669 let l:kwflagslist=[]
13671 let g:aflags = a:flags
13673 " flags o and i are synonims: (but refer to different entry keys):
13674 if a:flags =~# 'i' && a:flags !~# 'o'
13675 let l:flags=substitute(a:flags,'i','io','')
13676 elseif a:flags !~# 'i' && a:flags =~# 'o'
13677 let l:flags=substitute(a:flags,'o','oi','')
13679 if a:flags !~# 'All'
13681 " if strpart(a:flags,0,1) != '+'
13682 " let l:flags=b:atp_LastBibFlags . substitute(a:flags, 'L', '', 'g')
13684 let l:flags=b:atp_LastBibFlags . substitute(a:flags, 'L', '', 'g')
13686 let g:flags_a= deepcopy(l:flags)
13687 let g:atp_LastBibFlags = deepcopy(b:atp_LastBibFlags)
13690 let l:flags=g:defaultbibflags
13691 elseif strpart(a:flags,0,1) != '+' && a:flags !~ 'All'
13692 let l:flags=a:flags
13693 elseif strpart(a:flags,0,1) == '+' && a:flags !~ 'All'
13694 let l:flags=g:defaultbibflags . strpart(a:flags,1)
13697 let g:flags = flags
13698 let b:atp_LastBibFlags=substitute(l:flags,'+\|L','','g')
13700 let l:expr='\C[' . g:bibflagsstring . ']'
13701 while len(l:flags) >=1
13702 let l:oneflag=strpart(l:flags,0,1)
13703 " if we get a flag from the variable g:bibflagsstring we copy it to the list l:flagslist
13704 if l:oneflag =~ l:expr
13705 let l:flagslist=add(l:flagslist, l:oneflag)
13706 let l:flags=strpart(l:flags,1)
13707 " if we get '@' we eat ;) two letters to the list l:kwflagslist
13708 elseif l:oneflag == '@'
13709 let l:oneflag=strpart(l:flags,0,2)
13710 if index(keys(g:kwflagsdict),l:oneflag) != -1
13711 let l:kwflagslist=add(l:kwflagslist,l:oneflag)
13713 let l:flags=strpart(l:flags,2)
13714 " remove flags which are not defined
13715 elseif l:oneflag !~ l:expr && l:oneflag != '@'
13716 let l:flags=strpart(l:flags,1)
13721 " if the flag 'All' was specified.
13722 let l:flagslist=split(g:defaultallbibflags, '\zs')
13723 let l:af=substitute(a:flags,'All','','g')
13724 for l:kwflag in keys(g:kwflagsdict)
13725 if a:flags =~ '\C' . l:kwflag
13726 call extend(l:kwflagslist,[l:kwflag])
13731 let g:flagslist = deepcopy(l:flagslist)
13733 "NEW: if there are only keyword flags append default flags
13734 if len(l:kwflagslist) > 0 && len(l:flagslist) == 0
13735 let l:flagslist=split(g:defaultbibflags,'\zs')
13738 " Open a new window.
13739 let l:bufnr=bufnr("___" . a:pattern . "___" )
13741 let l:bdelete=l:bufnr . "bwipeout"
13745 let l:openbuffer=" +setl\\ buftype=nofile\\ filetype=bibsearch_atp " . fnameescape("___" . a:pattern . "___")
13747 let l:openbuffer="vsplit " . l:openbuffer
13750 let l:openbuffer="split " . l:openbuffer
13754 let BufNr = bufnr("%")
13755 let LineNr = line(".")
13756 let ColNr = col(".")
13757 silent exe l:openbuffer
13759 " set the window options
13760 silent call atplib#setwindow()
13761 " make a dictionary of clear values, which we will fill with found entries.
13762 " the default value is no<keyname>, which after all is matched and not showed
13764 let l:values={'bibfield_key' : 'nokey'}
13765 for l:flag in g:bibflagslist
13766 let l:values_clear=extend(l:values,{ g:bibflagsdict[l:flag][0] : 'no' . g:bibflagsdict[l:flag][0] })
13770 let l:kwflag_pattern="\\C"
13771 let l:len_kwflgslist=len(l:kwflagslist)
13772 let l:kwflagslist_rev=reverse(deepcopy(l:kwflagslist))
13773 for l:lkwflag in l:kwflagslist
13774 if index(l:kwflagslist_rev,l:lkwflag) == 0
13775 let l:kwflag_pattern.=g:kwflagsdict[l:lkwflag]
13777 let l:kwflag_pattern.=g:kwflagsdict[l:lkwflag].'\|'
13780 " let b:kwflag_pattern=l:kwflag_pattern
13782 for l:bibfile in keys(a:bibresults)
13783 if a:bibresults[l:bibfile] != {}
13784 call setline(l:ln, "Found in " . l:bibfile )
13787 for l:linenr in copy(sort(keys(a:bibresults[l:bibfile]), "atplib#CompareNumbers"))
13788 let l:values=deepcopy(l:values_clear)
13789 let b:values=l:values
13790 " fill l:values with a:bibrsults
13791 let l:values["bibfield_key"]=a:bibresults[l:bibfile][l:linenr]["bibfield_key"]
13792 " for l:key in keys(l:values)
13793 " if l:key != 'key' && get(a:bibresults[l:bibfile][l:linenr],l:key,"no" . l:key) != "no" . l:key
13794 " let l:values[l:key]=a:bibresults[l:bibfile][l:linenr][l:key]
13797 call extend(l:values,a:bibresults[l:bibfile][l:linenr],'force')
13799 " ----------------------------- SHOW ENTRIES -------------------------
13800 " first we check the keyword flags, @a,@b,... it passes if at least one flag
13803 " for l:lkwflag in l:kwflagslist
13804 " let l:kwflagpattern= '\C' . g:kwflagsdict[l:lkwflag]
13805 " if l:values['bibfield_key'] =~ l:kwflagpattern
13809 if l:values['bibfield_key'] =~ l:kwflag_pattern
13812 if l:check == 1 || len(l:kwflagslist) == 0
13813 let l:linenumber=index(s:bibdict[l:bibfile],l:values["bibfield_key"])+1
13814 call setline(l:ln,s:z . ". line " . l:linenumber . " " . l:values["bibfield_key"])
13816 let l:c0=atplib#count(l:values["bibfield_key"],'{')-atplib#count(l:values["bibfield_key"],'(')
13819 " this goes over the entry flags:
13820 for l:lflag in l:flagslist
13821 " we check if the entry was present in bibfile:
13822 if l:values[g:bibflagsdict[l:lflag][0]] != "no" . g:bibflagsdict[l:lflag][0]
13823 " if l:values[g:bibflagsdict[l:lflag][0]] =~ a:pattern
13824 call setline(l:ln, l:skip . g:bibflagsdict[l:lflag][1] . " = " . s:showvalue(l:values[g:bibflagsdict[l:lflag][0]]))
13827 " call setline(l:ln, l:skip . g:bibflagsdict[l:lflag][1] . " = " . s:showvalue(l:values[g:bibflagsdict[l:lflag][0]]))
13832 let l:lastline=getline(line('$'))
13833 let l:c1=atplib#count(l:lastline,'{')-atplib#count(l:lastline,'}')
13834 let l:c2=atplib#count(l:lastline,'(')-atplib#count(l:lastline,')')
13835 let l:c3=atplib#count(l:lastline,'\"')
13836 if l:c0 == 1 && l:c1 == -1
13837 call setline(line('$'),substitute(l:lastline,'}\s*$','',''))
13838 call setline(l:ln,'}')
13840 elseif l:c0 == 1 && l:c1 == 0
13841 call setline(l:ln,'}')
13843 elseif l:c0 == -1 && l:c2 == -1
13844 call setline(line('$'),substitute(l:lastline,')\s*$','',''))
13845 call setline(l:ln,')')
13847 elseif l:c0 == -1 && l:c1 == 0
13848 call setline(l:ln,')')
13851 let l:listofkeys[s:z]=l:values["bibfield_key"]
13857 let g:pattern = a:pattern
13859 let pattern_tomatch = substitute(a:pattern, '\Co', 'oe\\=', 'g')
13860 let pattern_tomatch = substitute(pattern_tomatch, '\CO', 'OE\\=', 'g')
13861 let pattern_tomatch = substitute(pattern_tomatch, '\Ca', 'ae\\=', 'g')
13862 let pattern_tomatch = substitute(pattern_tomatch, '\CA', 'AE\\=', 'g')
13864 let g:pm = pattern_tomatch
13866 let pattern_tomatch = join(split(pattern_tomatch, '\zs\\\@!\\\@<!'), '[''"{\}]\{,3}')
13868 let g:pattern_tomatch = pattern_tomatch
13870 silent! call matchadd("Search", '\c' . pattern_tomatch)
13871 let @/=pattern_tomatch
13872 " return l:listofkeys which will be available in the bib search buffer
13873 " as b:ListOfKeys (see the BibSearch function below)
13874 let b:ListOfBibKeys = l:listofkeys
13875 let b:BufNr = BufNr
13877 return l:listofkeys
13882 " This function sets the window options common for toc and bibsearch windows.
13883 "{{{1 atplib#setwindow
13884 " this function sets the options of BibSearch, ToC and Labels windows.
13885 function! atplib#setwindow()
13886 " These options are set in the command line
13887 " +setl\\ buftype=nofile\\ filetype=bibsearch_atp
13888 " +setl\\ buftype=nofile\\ filetype=toc_atp\\ nowrap
13889 " +setl\\ buftype=nofile\\ filetype=toc_atp\\ syntax=labels_atp
13891 setlocal winfixwidth
13892 setlocal noswapfile
13894 setlocal nobuflisted
13895 if &filetype == "bibsearch_atp"
13896 " setlocal winwidth=30
13898 elseif &filetype == "toc_atp"
13899 " setlocal winwidth=20
13901 setlocal cursorline
13903 " nnoremap <expr> <buffer> <C-W>l "keepalt normal
\x17l"
13904 " nnoremap <buffer> <C-W>h "keepalt normal
\x17h"
13907 " {{{1 atplib#count
13908 function! atplib#count(line,keyword,...)
13910 let method = ( a:0 == 0 || a:1 == 0 ) ? 0 : 1
13915 while stridx(line, a:keyword) != '-1'
13916 let line = strpart(line, stridx(line, a:keyword)+1)
13920 let line=escape(line, '\\')
13921 while match(line, a:keyword . '\zs.*') != '-1'
13922 let line=strpart(line, match(line, a:keyword . '\zs.*'))
13929 " Used to append / at the end of a directory name
13930 " {{{1 atplib#append
13931 fun! atplib#append(where, what)
13932 return substitute(a:where, a:what . '\s*$', '', '') . a:what
13935 " Used to append extension to a filename (if there is no extension).
13936 " {{{1 atplib#append_ext
13937 " extension has to be with a dot.
13938 fun! atplib#append_ext(fname, ext)
13939 return substitute(a:fname, a:ext . '\s*$', '', '') . a:ext
13944 " This functions cheks if an environment is closed/opened.
13945 " atplib#CheckClosed {{{1
13946 " check if last bpat is closed.
13947 " starting from the current line, limits the number of
13948 " lines to search. It returns 0 if the environment is not closed or the line
13949 " number where it is closed (an env is cannot be closed in 0 line)
13951 " ToDo: the two function should only check not commented lines!
13953 " Method 0 makes mistakes if the pattern is \begin:\end, if
13954 " \begin{env_name}:\end{env_names} rather no (unless there are nested
13955 " environments in the same name.
13956 " Method 1 doesn't make mistakes and thus is preferable.
13957 " after testing I shall remove method 0
13958 function! atplib#CheckClosed(bpat, epat, line, limit,...)
13960 " NOTE: THIS IS MUCH FASTER !!! or SLOWER !!! ???
13962 " let l:pos_saved=getpos(".")
13963 " let l:cline=line(".")
13964 " if a:line != l:cline
13965 " let l:col=len(getline(a:line))
13966 " keepjumps call setpos(".",[0,a:line,l:col,0])
13968 " let l:line=searchpair(a:bpat,'',a:epat,'nWr','',max([(a:line+a:limit),1]))
13969 " if a:line != l:cline
13970 " keepjumps call setpos(".",l:pos_saved)
13975 if a:0 == 0 || a:1 == 0
13981 let l:len=len(getbufline(bufname("%"),1,'$'))
13984 if a:limit == "$" || a:limit == "-1"
13985 let l:limit=l:len-a:line
13987 let l:limit=a:limit
13991 while l:nr <= a:line+l:limit
13992 let l:line=getline(l:nr)
13995 if strpart(l:line,getpos(".")[2]-1) =~ '\%(' . a:bpat . '.*\)\@<!' . a:epat
13999 if l:line =~ '\%(' . a:epat . '.*\)\@<!' . a:bpat
14001 elseif l:line =~ '\%(' . a:bpat . '.*\)\@<!' . a:epat
14012 let l:begin_line=getline(a:line)
14013 let l:begin_line_nr=line(a:line)
14014 while l:nr <= a:line+l:limit
14015 let l:line=getline(l:nr)
14016 " I assume that the env is opened in the line before!
14017 let l:bpat_count+=atplib#count(l:line,a:bpat,1)
14018 let l:epat_count+=atplib#count(l:line,a:epat,1)
14019 if (l:bpat_count+1) == l:epat_count && l:begin_line !~ a:bpat
14021 elseif l:bpat_count == l:epat_count && l:begin_line =~ a:bpat
14030 " atplib#CheckOpened {{{1
14031 " Usage: By default (a:0 == 0 || a:1 == 0 ) it returns line number where the
14032 " environment is opened if the environment is opened and is not closed (for
14033 " completion), else it returns 0. However, if a:1 == 1 it returns line number
14034 " where the environment is opened, if we are inside an environment (it is
14035 " opened and closed below the starting line or not closed at all), it if a:1
14036 " = 2, it just check if env is opened without looking if it is closed (
14037 " cursor position is important).
14038 " a:1 == 0 first non closed
14039 " a:1 == 2 first non closed by counting.
14041 " this function doesn't check if sth is opened in lines which begins with '\\def\>'
14042 " (some times one wants to have a command which opens an environment.
14044 " Todo: write a faster function using searchpairpos() which returns correct
14046 function! atplib#CheckOpened(bpat,epat,line,limit,...)
14049 " this is almost good:
14050 " let l:line=searchpair(a:bpat,'',a:epat,'bnWr','',max([(a:line-a:limit),1]))
14053 if a:0 == 0 || a:1 == 0
14054 let l:check_mode = 0
14056 let l:check_mode = 1
14058 let l:check_mode = 2
14061 let l:len=len(getbufline(bufname("%"),1,'$'))
14064 if a:limit == "^" || a:limit == "-1"
14065 let l:limit=a:line-1
14067 let l:limit=a:limit
14070 if l:check_mode == 0 || l:check_mode == 1
14071 while l:nr >= a:line-l:limit && l:nr >= 1
14072 let l:line=getline(l:nr)
14074 if substitute(strpart(l:line,0,getpos(".")[2]), a:bpat . '.\{-}' . a:epat,'','g')
14079 if l:check_mode == 0
14080 if substitute(l:line, a:bpat . '.\{-}' . a:epat,'','g')
14082 " check if it is closed up to the place where we start. (There
14083 " is no need to check after, it will be checked anyway
14084 " b a serrate call in TabCompletion.
14085 if !atplib#CheckClosed(a:bpat,a:epat,l:nr,a:limit,0)
14086 " LAST CHANGE 1->0 above
14087 " let b:cifo_return=2 . " " . l:nr
14091 elseif l:check_mode == 1
14092 if substitute(l:line, a:bpat . '.\{-}' . a:epat,'','g')
14093 \ =~ '\%(\\def\|\%(re\)\?newcommand\)\@<!' . a:bpat
14094 let l:check=atplib#CheckClosed(a:bpat,a:epat,l:nr,a:limit,1)
14095 " if env is not closed or is closed after a:line
14096 if l:check == 0 || l:check >= a:line
14097 " let b:cifo_return=2 . " " . l:nr
14105 elseif l:check_mode == 2
14108 let l:begin_line=getline(".")
14110 while l:nr >= a:line-l:limit && l:nr >= 1
14111 let l:line=getline(l:nr)
14112 " I assume that the env is opened in line before!
14113 " let l:line=strpart(l:line,getpos(".")[2])
14114 let l:bpat_count+=atplib#count(l:line,a:bpat,1)
14115 let l:epat_count+=atplib#count(l:line,a:epat,1)
14116 if l:bpat_count == (l:epat_count+1+l:c) && l:begin_line != line(".")
14117 let l:env_name=matchstr(getline(l:nr),'\\begin{\zs[^}]*\ze}')
14118 let l:check=atplib#CheckClosed('\\begin{' . l:env_name . '}', '\\end{' . l:env_name . '}',1,a:limit,1)
14124 elseif l:bpat_count == l:epat_count && l:begin_line == line(".")
14133 " This functions makes a test if inline math is closed. This works well with
14134 " \(:\) and \[:\] but not yet with $:$ and $$:$$.
14135 " {{{1 atplib#CheckInlineMath
14136 " a:mathZone = texMathZoneV or texMathZoneW or texMathZoneX or texMathZoneY
14137 " The function return 1 if the mathZone is not closed
14138 function! atplib#CheckInlineMath(mathZone)
14139 let synstack = map(synstack(line("."), max([1, col(".")-1])), "synIDattr( v:val, 'name')")
14142 \ 'texMathZoneV' : [ '\\\@<!\\(', '\\\@<!\\)' ],
14143 \ 'texMathZoneW' : [ '\\\@<!\\\[', '\\\@<!\\\]' ]}
14144 " Limit the search to the first \par or a blank line, if not then search
14145 " until the end of document:
14146 let stop_line = search('\\par\|^\s*$', 'nW') - 1
14147 let stop_line = ( stop_line == -1 ? line('$') : stop_line )
14149 " \(:\), \[:\], $:$ and $$:$$ do not accept blank lines, thus we can limit
14150 " searching/counting.
14152 " For \(:\) and \[:\] we use searchpair function to test if it is closed or
14154 if (a:mathZone == 'texMathZoneV' || a:mathZone == 'texMathZoneW') && atplib#CheckSyntaxGroups(['texMathZoneV', 'texMathZoneW'])
14155 if index(synstack, a:mathZone) != -1
14156 let condition = searchpair( patterns[a:mathZone][0], '', patterns[a:mathZone][1], 'cnW', '', stop_line)
14157 let check = ( !condition ? 1 : check )
14160 " $:$ and $$:$$ we are counting $ untill blank line or \par
14161 " to test if it is closed or not,
14162 " then we return the number of $ modulo 2.
14163 elseif ( a:mathZone == 'texMathZoneX' || a:mathZone == 'texMathZoneY' ) && atplib#CheckSyntaxGroups(['texMathZoneX', 'texMathZoneY'])
14164 let saved_pos = getpos(".")
14165 let line = line(".")
14167 " count \$ if it is under the cursor
14168 if search('\\\@<!\$', 'Wc', stop_line)
14171 while line <= stop_line && line != 0
14172 keepjumps let line = search('\\\@<!\$', 'W', stop_line)
14175 keepjumps call setpos(".", saved_pos)
14176 let check = l:count%2
14181 " {{{1 atplib#CheckSyntaxGroups
14182 " This functions returns one if one of the environment given in the list
14183 " a:zones is present in they syntax stack at line a:1 and column a:0.
14184 " a:zones = a list of zones
14185 " a:1 = line nr (default: current cursor line)
14186 " a:2 = column nr (default: column before the current cursor position)
14187 " The function doesn't make any checks if the line and column supplied are
14188 " valid /synstack() function returns 0 rather than [] in such a case/.
14189 function! atplib#CheckSyntaxGroups(zones,...)
14190 let line = a:0 >= 2 ? a:1 : line(".")
14191 let col = a:0 >= 2 ? a:2 : col(".")-1
14192 let col = max([1, col])
14193 let zones = copy(a:zones)
14195 let synstack = map(synstack( line, col), 'synIDattr(v:val, "name")')
14196 let g:synstack = synstack
14198 return max(map(zones, "count(synstack, v:val)"))
14200 " atplib#CopyIndentation {{{1
14201 function! atplib#CopyIndentation(line)
14202 let raw_indent = split(a:line,'\s\zs')
14204 for char in raw_indent
14205 if char =~ '^\%(\s\|\t\)'
14215 " Tab Completion Related Functions:
14216 " atplib#SearchPackage {{{1
14218 " This function searches if the package in question is declared or not.
14219 " Returns the line number of the declaration or 0 if it was not found.
14221 " It was inspired by autex function written by Carl Mueller, math at carlm e4ward c o m
14222 " and made work for project files using lvimgrep.
14224 " This function doesn't support plaintex files (\\input{})
14225 " ATP support plaintex input lines in a different way (but not that flexible
14226 " as this: for plaintex I use atplib#GrepPackageList on startup (only!) and
14227 " then match input name with the list).
14229 " name = package name (tikz library name)
14230 " a:1 = stop line (number of the line \\begin{document}
14231 " a:2 = pattern matching the command (without '^[^%]*\\', just the name)
14232 " to match \usetikzlibrary{...,..., -
14233 function! atplib#SearchPackage(name,...)
14235 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
14236 if !filereadable(atp_MainFile)
14237 silent echomsg "atp_MainFile : " . atp_MainFile . " is not readable "
14241 if exists("b:atp_ProjectDir") && getcwd() != b:atp_ProjectDir
14242 exe "cd " . b:atp_ProjectDir
14245 if getbufvar("%", "atp_MainFile") == ""
14246 call SetProjectName()
14247 let g:PName = 0 . " " . atp_MainFile
14249 let g:PName = 1 . " " . atp_MainFile
14252 " let time = reltime()
14254 " if bufloaded("^" . a:file . "$")
14255 " let file=getbufline("^" . a:file . "$", "1", "$")
14257 " let file=readfile(a:filename)
14261 let stop_line = a:1
14263 if expand("%:p") == atp_MainFile
14264 let saved_pos=getpos(".")
14265 keepjumps call setpos(".", [0,1,1,0])
14266 keepjumps let stop_line=search('\\begin\s*{\s*document\s*}','nW')
14268 if &l:filetype == 'tex'
14269 let saved_loclist = getloclist(0)
14270 silent! execute '1lvimgrep /\\begin\s*{\s*document\s*}/j ' . fnameescape(atp_MainFile)
14271 let stop_line = get(get(getloclist(0), 0, {}), 'lnum', 0)
14272 call setloclist(0, saved_loclist)
14279 let com = a:0 >= 2 ? a:2 : 'usepackage\s*\%(\[[^]]*]\)\?'
14281 " If the current file is the atp_MainFile
14282 if expand("%:p") == atp_MainFile
14284 if !exists("saved_pos")
14285 let saved_pos=getpos(".")
14289 keepjumps call setpos(".",[0,1,1,0])
14290 keepjumps let ret = search('^[^%]*\\'.com."\s*{[^}]*".a:name,'ncW', stop_line)
14291 keepjump call setpos(".",saved_pos)
14293 " echo reltimestr(reltime(time))
14299 keepjumps call setpos(".",[0,1,1,0])
14300 keepjumps let ret = search('^[^%]*\\'.com."\s*{[^}]*".a:name,'ncW')
14301 keepjump call setpos(".", saved_pos)
14303 " echo reltimestr(reltime(time))
14309 " If the current file is not the mainfile
14311 " Cache the Preambule / it is not changing so this is completely safe /
14312 if !exists("s:Preambule")
14313 let s:Preambule = readfile(atp_MainFile)
14315 silent! call remove(s:Preambule, stop_line+1, -1)
14318 let g:preambule = s:Preambule
14320 for line in s:Preambule
14321 if line =~ '^[^%]*\\'.com."\s*{[^}]*".a:name
14323 " echo reltimestr(reltime(time))
14331 " echo reltimestr(reltime(time))
14333 " If the package was not found return 0
14339 "{{{1 atplib#GrepPackageList()
14340 " This function returns list of packages declared in the b:atp_MainFile (or
14341 " a:2). If the filetype is plaintex it returns list of all \input{} files in
14342 " the b:atp_MainFile.
14343 " I'm not shure if this will be OK for project files written in plaintex: Can
14344 " one declare a package in the middle of document? probably yes. So it might
14345 " be better to use TreeOfFiles in that case.
14347 " This takes =~ 0.02 s. This is too long to call it in TabCompletion.
14348 function! atplib#GrepPackageList(...)
14349 " let time = reltime()
14350 let file = a:0 >= 2 ? a:2 : getbufvar("%", "atp_MainFile")
14351 let pat = a:0 >= 1 ? a:1 : ''
14356 let ftype = getbufvar(file, "&filetype")
14358 if ftype =~ '^\(ams\)\=tex$'
14359 let pat = '\\usepackage\s*\(\[[^]]*\]\)\=\s*{'
14360 elseif ftype == 'plaintex'
14361 let pat = '\\input\s*{'
14363 " echoerr "ATP doesn't recognize the filetype " . &l:filetype . ". Using empty list of packages."
14368 let saved_loclist = getloclist(0)
14370 silent execute 'lvimgrep /^[^%]*'.pat.'/j ' . fnameescape(file)
14372 call setloclist(0, [{'text' : 'empty' }])
14374 let loclist = getloclist(0)
14375 call setloclist(0, saved_loclist)
14377 let pre = map(loclist, 'v:val["text"]')
14380 let package_l = matchstr(line, pat.'\zs[^}]*\ze}')
14381 call add(pre_l, package_l)
14384 " We make a string of packages separeted by commas and the split it
14385 " (compatibility with \usepackage{package_1,package_2,...})
14386 let pre_string = join(pre_l, ',')
14387 let pre_list = split(pre_string, ',')
14388 call filter(pre_list, "v:val !~ '^\s*$'")
14390 " echo reltimestr(reltime(time))
14393 " atplib#DocumentClass {{{1
14394 function! atplib#DocumentClass(file)
14396 let saved_loclist = getloclist(0)
14398 silent execute 'lvimgrep /\\documentclass/j ' . fnameescape(a:file)
14401 let line = get(get(getloclist(0), 0, "no_document_class"), 'text')
14402 call setloclist(0, saved_loclist)
14405 if line != 'no_document_class'
14406 return substitute(l:line,'.*\\documentclass\s*\%(\[.*\]\)\?{\(.*\)}.*','\1','')
14413 " Searching Tools: (kpsewhich)
14414 " {{{1 atplib#KpsewhichGlobPath
14415 " a:format is the format as reported by kpsewhich --help
14416 " a:path path if set to "", then kpse which will find the path.
14417 " The default is what 'kpsewhich -show-path tex' returns
14418 " with "**" appended.
14419 " a:name can be "*" then finds all files with the given extension
14420 " or "*.cls" to find all files with a given extension.
14421 " a:1 modifiers (the default is ":t:r")
14422 " a:2 filters path names matching the pattern a:1
14423 " a:3 filters out path names not matching the pattern a:2
14425 " Argument a:path was added because it takes time for kpsewhich to return the
14426 " path (usually ~0.5sec). ATP asks kpsewhich on start up
14427 " (g:atp_kpsewhich_tex) and then locks the variable (this will work
14428 " unless sb is reinstalling tex (with different personal settings,
14429 " changing $LOCALTEXMF) during vim session - not that often).
14431 " Example: call atplib#KpsewhichGlobPath('tex', '', '*', ':p', '^\(\/home\|\.\)','\%(texlive\|kpsewhich\|generic\)')
14432 " gives on my system only the path of current dir (/.) and my localtexmf.
14433 " this is done in 0.13s. The long pattern is to
14435 " atp#KpsewhichGlobPath({format}, {path}, {expr=name}, [ {mods}, {pattern_1}, {pattern_2}])
14436 function! atplib#KpsewhichGlobPath(format, path, name, ...)
14437 " let time = reltime()
14438 let modifiers = a:0 == 0 ? ":t:r" : a:1
14440 let path = substitute(substitute(system("kpsewhich -show-path ".a:format ),'!!','','g'),'\/\/\+','\/','g')
14441 let path = substitute(path,':\|\n',',','g')
14442 let path_list = split(path, ',')
14443 let idx = index(path_list, '.')
14445 let dot = remove(path_list, index(path_list,'.')) . ","
14449 call map(path_list, 'v:val . "**"')
14451 let path = dot . join(path_list, ',')
14455 " If a:2 is non zero (if not given it is assumed to be 0 for compatibility
14457 if get(a:000, 1, 0) != "0"
14458 let path_list = split(path, ',')
14459 call filter(path_list, 'v:val =~ a:2')
14460 let path = join(path_list, ',')
14462 if get(a:000, 2, 0) != "0"
14463 let path_list = split(path, ',')
14464 call filter(path_list, 'v:val !~ a:3')
14465 let path = join(path_list, ',')
14468 let list = split(globpath(path, a:name),'\n')
14469 call map(list, 'fnamemodify(v:val, modifiers)')
14470 " echomsg "TIME:" . join(reltime(time), ".")
14474 " {{{1 atplib#KpsewhichFindFile
14475 " the arguments are similar to atplib#KpsewhichGlob except that the a:000 list
14478 " if set to "" then kpsewhich finds the path.
14479 " a:2 = count (as for findfile())
14481 " a:4 = positive filter for path (see KpsewhichGLob a:1)
14482 " a:5 = negative filter for path (see KpsewhichFind a:2)
14484 " needs +path_extra vim feature
14486 " atp#KpsewhichFindFile({format}, {expr=name}, [{path}, {count}, {mods}, {pattern_1}, {pattern_2}])
14487 function! atplib#KpsewhichFindFile(format, name, ...)
14489 " Unset the suffixadd option
14490 let saved_sua = &l:suffixesadd
14493 " let time = reltime()
14494 let path = a:0 >= 1 ? a:1 : ""
14495 let l:count = a:0 >= 2 ? a:2 : 0
14496 let modifiers = a:0 >= 3 ? a:3 : ""
14497 " This takes most of the time!
14499 let path = substitute(substitute(system("kpsewhich -show-path ".a:format ),'!!','','g'),'\/\/\+','\/','g')
14500 let path = substitute(path,':\|\n',',','g')
14501 let path_list = split(path, ',')
14502 let idx = index(path_list, '.')
14504 let dot = remove(path_list, index(path_list,'.')) . ","
14508 call map(path_list, 'v:val . "**"')
14510 let path = dot . join(path_list, ',')
14515 " If a:2 is non zero (if not given it is assumed to be 0 for compatibility
14517 if get(a:000, 3, 0) != 0
14518 let path_list = split(path, ',')
14519 call filter(path_list, 'v:val =~ a:4')
14520 let path = join(path_list, ',')
14522 if get(a:000, 4, 0) != 0
14523 let path_list = split(path, ',')
14524 call filter(path_list, 'v:val !~ a:5')
14525 let path = join(path_list, ',')
14530 let result = findfile(a:name, path, l:count)
14531 elseif l:count == 0
14532 let result = findfile(a:name, path)
14534 let result = findfile(a:name, path, -1)
14538 if l:count >= 0 && modifiers != ""
14539 let result = fnamemodify(result, modifiers)
14540 elseif l:count < 0 && modifiers != ""
14541 call map(result, 'fnamemodify(v:val, modifiers)')
14543 " echomsg "TIME:" . join(reltime(time), ".")
14545 let &l:sua = saved_sua
14551 " atplib#Extend {{{1
14552 " arguments are the same as for extend(), but it adds only the entries which
14554 function! atplib#Extend(list_a,list_b,...)
14555 let list_a=deepcopy(a:list_a)
14556 let list_b=deepcopy(a:list_b)
14557 let diff=filter(list_b,'count(l:list_a,v:val) == 0')
14559 return extend(list_a,diff)
14561 return extend(list_a,diff, a:1)
14566 function! atplib#Add(list,what)
14568 for element in a:list
14569 call add(new,element . a:what)
14575 " Close Environments And Brackets:
14576 " Close Last Environment
14577 " atplib#CloseLastEnvironment {{{1
14578 " a:1 = i (append before, so the cursor will be after - the dafult)
14580 " a:2 = math the pairs \(:\), $:$, \[:\] or $$:$$ (if filetype is
14581 " plaintex or b:atp_TexFlavor="plaintex")
14583 " by the way, treating the math pairs together is very fast.
14584 " a:3 = environment name (if present and non zero sets a:2 = environment)
14585 " if one wants to find an environment name it must be 0 or "" or not
14587 " a:4 = line and column number (in a vim list) where environment is opened
14588 " ToDo: Ad a highlight to messages!!! AND MAKE IT NOT DISAPPEAR SOME HOW?
14589 " (redrawing doesn't help) CHECK lazyredraw.
14590 " Note: this function tries to not double the checks what to close if it is
14591 " given in the arguments, and find only the information that is not given
14592 " (possibly all the information as all arguments can be omitted).
14593 function! atplib#CloseLastEnvironment(...)
14595 let l:com = a:0 >= 1 ? a:1 : 'i'
14596 let l:close = a:0 >= 2 && a:2 != "" ? a:2 : 0
14598 let l:env_name = a:3 == "" ? 0 : a:3
14599 let l:close = ( a:3 != '' ? "environment" : l:close )
14603 let l:bpos_env = a:0 >= 4 ? a:4 : [0, 0]
14606 let g:args = l:com . " " . l:close . " " . l:env_name . " " . string(l:bpos_env)
14608 let g:close = l:close
14609 let g:env_name = l:env_name
14610 let g:bpos_env = l:bpos_env
14613 " {{{2 find the begining line of environment to close (if we are closing
14615 if l:env_name == 0 && ( l:close == "environment" || l:close == 0 ) && l:close != "math"
14617 let filter = 'strpart(getline(''.''), 0, col(''.'') - 1) =~ ''\\\@<!%'''
14619 " Check if and environment is opened (\begin:\end):
14620 " This is the slow part :( 0.4s)
14621 " Find the begining line if it was not given.
14622 if l:bpos_env == [0, 0]
14623 " Find line where the environment is opened and not closed:
14624 let l:bpos_env = searchpairpos('\\begin\s*{', '', '\\end\s*{', 'bnW', 'searchpair("\\\\begin\s*{\s*".matchstr(getline("."),"\\\\begin\s*{\\zs[^}]*\\ze\}"), "", "\\\\end\s*{\s*".matchstr(getline("."), "\\\\begin\s*{\\zs[^}]*\\ze}"), "nW", "", "line(".")+g:atp_completion_limits[2]")',max([ 1, (line(".")-g:atp_completion_limits[2])]))
14627 let l:env_name = matchstr(strpart(getline(l:bpos_env[0]),l:bpos_env[1]-1), '\\begin\s*{\s*\zs[^}]*\ze*\s*}')
14629 " if a:3 (environment name) was given:
14630 elseif l:env_name != "0" && l:close == "environment"
14632 let l:bpos_env = searchpairpos('\\begin\s*{'.l:env_name.'}', '', '\\end\s*{'.l:env_name.'}', 'bnW', '',max([1,(line(".")-g:atp_completion_limits[2])]))
14636 " {{{2 if a:2 was not given (l:close = 0) we have to check math modes as
14638 if ( l:close == "0" || l:close == "math" ) && l:bpos_env == [0, 0]
14640 let stopline = search('^\s*$\|\\par\>', 'bnW')
14642 " Check if one of \(:\), \[:\], $:$, $$:$$ is opened using syntax
14643 " file. If it is fined the starting position.
14645 let synstack = map(synstack(line("."),max([1, col(".")-1])), 'synIDattr(v:val, "name")')
14647 let g:synstackCLE = deepcopy(synstack)
14648 let g:openCLE = getline(".")[col(".")-1] . getline(".")[col(".")]
14650 let bound_1 = getline(".")[col(".")-1] . getline(".")[col(".")] =~ '^\\\%((\|)\)$'
14651 let math_1 = (index(synstack, 'texMathZoneV') != -1 && !bound_1 ? 1 : 0 )
14653 if l:bpos_env == [0, 0]
14654 let bpos_math_1 = searchpos('\%(\%(\\\)\@<!\\\)\@<!\\(', 'bnW', stopline)
14656 let bpos_math_1 = l:bpos_env
14658 let l:begin_line= bpos_math_1[0]
14659 let math_mode = "texMathZoneV"
14662 let bound_2 = getline(".")[col(".")-1] . getline(".")[col(".")] =~ '^\\\%(\[\|\]\)$'
14663 let math_2 = (index(synstack, 'texMathZoneW') != -1 && !bound_2 ? 1 : 0 )
14665 if l:bpos_env == [0, 0]
14666 let bpos_math_2 = searchpos('\%(\%(\\\)\@<!\\\)\@<!\\[', 'bnW', stopline)
14668 let bpos_math_2 = l:bpos_env
14670 let l:begin_line= bpos_math_2[0]
14671 let math_mode = "texMathZoneW"
14674 let bound_3 = getline(".")[col(".")-1] =~ '^\$$'
14675 let math_3 = (index(synstack, 'texMathZoneX') != -1 && !bound_3 ? 1 : 0 )
14677 if l:bpos_env == [0, 0]
14678 let bpos_math_3 = searchpos('\%(\%(\\\)\@<!\\\)\@<!\$\{1,1}', 'bnW', stopline)
14680 let bpos_math_3 = l:bpos_env
14682 let l:begin_line= bpos_math_3[0]
14683 let math_mode = "texMathZoneX"
14686 let bound_4 = getline(".")[col(".")-1] . getline(".")[col(".")] =~ '^\$\$$'
14687 let math_4 = (index(synstack, 'texMathZoneY') != -1 && !bound_4 ? 1 : 0 )
14689 if l:bpos_env == [0, 0]
14690 let bpos_math_4 = searchpos('\%(\%(\\\)\@<!\\\)\@<!\$\{2,2}', 'bnW', stopline)
14692 let bpos_math_4 = l:bpos_env
14694 let l:begin_line= bpos_math_4[0]
14695 let math_mode = "texMathZoneY"
14700 let g:math_mode = math_mode
14702 let g:begin_line = ( exists("begin_line") ? begin_line : 0 )
14703 let g:bound_{i} = bound_{i}
14704 call add(g:bound, bound_{i})
14705 let g:math_{i} = math_{i}
14706 call add(g:math, math_{i})
14709 elseif ( l:close == "0" || l:close == "math" )
14710 let string = getline(l:bpos_env[0])[l:bpos_env[1]-2] . getline(l:bpos_env[0])[l:bpos_env[1]-1] . getline(l:bpos_env[0])[l:bpos_env[1]]
14711 let stop_line = search('\\par\|^\s*$\|\\\%(begin\|end\)\s*{', 'n')
14712 let [ math_1, math_2, math_3, math_4 ] = [ 0, 0, 0, 0 ]
14713 let saved_pos = getpos(".")
14714 if string =~ '\\\@<!\\('
14715 call cursor(l:bpos_env)
14717 let math_1 = searchpair('\\(', '', '\\)', 'n', '', stop_line)
14719 let math_mode = "texMathZoneV"
14721 elseif string =~ '\\\@<!\\\['
14722 call cursor(l:bpos_env)
14724 let math_2 = searchpair('\\\[', '', '\\\]', 'n', '', stop_line)
14726 let math_mode = "texMathZoneW"
14728 elseif string =~ '\%(\\\|\$\)\@<!\$\$\@!'
14729 " Check if closed: not implemented
14731 let math_mode = "texMathZoneX"
14732 elseif string =~ '\\\@<!\$\$'
14733 " Check if closed: not implemented
14735 let math_mode = "texMathZoneY"
14737 call cursor([ saved_pos[1], saved_pos[2] ])
14739 if exists("math_mode")
14740 let g:math_mode = math_mode
14743 let g:string = string
14745 let g:begin_line = ( exists("begin_line") ? begin_line : 0 )
14746 let g:math_{i} = math_{i}
14747 call add(g:math, math_{i})
14750 if exists("math_mode")
14751 let l:begin_line = l:bpos_env[0]
14753 return " Given coordinates are closed."
14757 "{{{2 set l:close if a:1 was not given.
14759 " let l:begin_line=max([ l:begin_line_env, l:begin_line_imath, l:begin_line_dmath ])
14760 " now we can set what to close:
14761 " the synstack never contains two of the math zones: texMathZoneV,
14762 " texMathZoneW, texMathZoneX, texMathZoneY.
14763 if math_1 + math_2 + math_3 + math_4 >= 1
14764 let l:close = 'math'
14765 elseif l:begin_line_env
14766 let l:close = 'environment'
14770 let g:close = l:close
14772 let l:env=l:env_name
14775 if l:close == "0" || l:close == 'math' && !exists("begin_line")
14776 return "there was nothing to close"
14778 if ( &filetype != "plaintex" && b:atp_TexFlavor != "plaintex" && exists("math_4") && math_4 )
14780 echomsg "$$:$$ in LaTeX are deprecated (this breaks some LaTeX packages)"
14781 echomsg "You can set b:atp_TexFlavor = 'plaintex', and ATP will ignore this. "
14785 if l:env_name =~ '^\s*document\s*$'
14788 let l:cline = getline(".")
14789 let l:pos = getpos(".")
14790 if l:close == "math"
14791 let l:line = getline(l:begin_line)
14792 elseif l:close == "environment"
14793 let l:line = getline(l:bpos_env[0])
14797 let g:line = exists("l:line") ? l:line : 0
14800 " Copy the indentation of what we are closing.
14801 let l:eindent=atplib#CopyIndentation(l:line)
14802 "{{{2 close environment
14803 if l:close == 'environment'
14806 " silent echomsg "Closing " . l:env_name . " from line " . l:bpos_env[0]
14809 " env & \[ \]: close in the same line
14810 " unless it starts in a serrate line,
14811 " \( \): close in the same line.
14812 "{{{3 close environment in the same line
14813 if l:line !~ '^\s*\%(\$\|\$\$\|[^\\]\\(\|\\\@<!\\\[\)\?\s*\\begin\s*{[^}]*}\s*\%(([^)]*)\s*\|{[^}]*}\s*\|\[[^\]]*\]\s*\)\{,3}\%(\\label\s*{[^}]*}\s*\)\?$'
14814 " This pattern matches:
14819 " ^ (one of above or space) \begin { env_name } ( args1 ) [ args2 ] { args3 } \label {label}
14820 " There are at most 3 args of any type with any order \label is matched optionaly.
14821 " Any of these have to be followd by white space up to end of line.
14823 " The line above cannot contain "\|^\s*$" pattern! Then the
14824 " algorithm for placing the \end in right place is not called.
14826 " THIS WILL BE NEEDED LATER!
14827 " \ (l:close == 'display_math' && l:line !~ '^\s*[^\\]\\\[\s*$') ||
14828 " \ (l:close == 'inline_math' && (l:line !~ '^\s*[^\\]\\(\s*$' || l:begin_line == line("."))) ||
14829 " \ (l:close == 'dolar_math' && l:cline =~ '\$')
14831 " the above condition matches for the situations when we have to
14832 " complete in the same line in four cases:
14833 " l:close == environment, display_math, inline_math or
14836 " do not complete environments which starts in a definition.
14837 " let b:cle_debug= (getline(l:begin_line) =~ '\\def\|\%(re\)\?newcommand') . " " . (l:begin_line != line("."))
14838 " if getline(l:begin_line) =~ '\\def\|\%(re\)\?newcommand' && l:begin_line != line(".")
14839 " let b:cle_return="def"
14840 " return b:cle_return
14842 if index(g:atp_no_complete, l:env) == '-1' &&
14843 \ !atplib#CheckClosed('\%(%.*\)\@<!\\begin\s*{' . l:env,'\%(%.*\)\@<!\\end\s*{' . l:env,line("."),g:atp_completion_limits[2])
14845 call setline(line("."), strpart(l:cline,0,getpos(".")[2]) . '\end{'.l:env.'}' . strpart(l:cline,getpos(".")[2]))
14846 let l:pos=getpos(".")
14847 let l:pos[2]=len(strpart(l:cline,0,getpos(".")[2]) . '\end{'.l:env.'}')+1
14848 keepjumps call setpos(".",l:pos)
14849 elseif l:cline =~ '^\s*$'
14850 call setline(line("."), l:eindent . '\end{'.l:env.'}' . strpart(l:cline,getpos(".")[2]-1))
14851 let l:pos=getpos(".")
14852 let l:pos[2]=len(strpart(l:cline,0,getpos(".")[2]-1) . '\end{'.l:env.'}')+1
14853 keepjumps call setpos(".",l:pos)
14855 call setline(line("."), strpart(l:cline,0,getpos(".")[2]-1) . '\end{'.l:env.'}' . strpart(l:cline,getpos(".")[2]-1))
14856 let l:pos=getpos(".")
14857 let l:pos[2]=len(strpart(l:cline,0,getpos(".")[2]-1) . '\end{'.l:env.'}')+1
14858 keepjumps call setpos(".",l:pos)
14861 "{{{3 close environment in a new line
14864 " do not complete environments which starts in a definition.
14867 let l:prev_line_nr="-1"
14868 let l:cenv_lines=[]
14871 let l:line_nr=line(".")
14872 " l:line_nr number of line which we complete
14873 " l:cenv_lines list of closed environments (we complete after
14874 " line number maximum of these numbers.
14876 let l:pos=getpos(".")
14877 let l:pos_saved=deepcopy(l:pos)
14879 while l:line_nr >= 0
14880 let l:line_nr=search('\%(%.*\)\@<!\\begin\s*{','bW')
14881 " match last environment openned in this line.
14882 " ToDo: afterwards we can make it works for multiple openned
14884 let l:env_name=matchstr(getline(l:line_nr),'\%(%.*\)\@<!\\begin\s*{\zs[^}]*\ze}\%(.*\\begin\s*{[^}]*}\)\@!')
14885 if index(g:atp_long_environments,l:env_name) != -1
14890 let l:close_line_nr=atplib#CheckClosed('\%(%.*\)\@<!\\begin\s*{' . l:env_name,
14891 \ '\%(%.*\)\@<!\\end\s*{' . l:env_name,
14892 \ l:line_nr,g:atp_completion_limits[l:limit],1)
14894 if l:close_line_nr != 0
14895 call add(l:cenv_lines,l:close_line_nr)
14902 keepjumps call setpos(".",l:pos)
14904 if getline(l:line_nr) =~ '\%(%.*\)\@<!\%(\\def\|\%(re\)\?newcommand\)' && l:line_nr != line(".")
14905 " let b:cle_return="def"
14909 " get all names of environments which begin in this line
14911 let l:line=getline(l:line_nr)
14912 while l:line =~ '\\begin\s*{'
14913 let l:cenv_begins = match(l:line,'\%(%.*\)\@<!\\begin{\zs[^}]*\ze}\%(.*\\begin\s{\)\@!')
14914 let l:cenv_name = matchstr(l:line,'\%(%.*\)\@<!\\begin{\zs[^}]*\ze}\%(.*\\begin\s{\)\@!')
14915 let l:cenv_len=len(l:cenv_name)
14916 let l:line=strpart(l:line,l:cenv_begins+l:cenv_len)
14917 call add(l:env_names,l:cenv_name)
14919 " let g:env_names=l:env_names
14920 " let g:line=l:line
14921 " let g:cenv_begins=l:cenv_begins
14922 " let g:cenv_name=l:cenv_name
14924 " thus we have a list of env names.
14926 " make a dictionary of lines where they closes.
14927 " this is a list of pairs (I need the order!)
14930 " list of closed environments
14931 let l:cenv_names=[]
14933 for l:uenv in l:env_names
14934 let l:uline_nr=atplib#CheckClosed('\%(%.*\)\@<!\\begin\s*{' . l:uenv . '}',
14935 \ '\%(%.*\)\@<!\\end\s*{' . l:uenv . '}', l:line_nr, g:atp_completion_limits[2])
14936 call extend(l:env_dict,[ l:uenv, l:uline_nr])
14937 if l:uline_nr != '0'
14938 call add(l:cenv_names,l:uenv)
14942 " close unclosed environment
14944 " check if at least one of them is closed
14945 if len(l:cenv_names) == 0
14947 for l:uenv in l:env_names
14948 if index(g:atp_no_complete,l:uenv) == '-1'
14949 let l:str.='\end{' . l:uenv .'}'
14952 " l:uenv will remain the last environment name which
14954 " Do not append empty lines (l:str is empty if all l:uenv
14955 " belongs to the g:atp_no_complete list.
14959 let l:eindent=atplib#CopyIndentation(getline(l:line_nr))
14960 let l:pos=getpos(".")
14961 if len(l:cenv_lines) > 0
14963 let l:max=max(l:cenv_lines)
14964 let l:pos[1]=l:max+1
14965 " find the first closed item below the last closed
14966 " pair (below l:pos[1]). (I assume every env is in
14968 let l:end=atplib#CheckClosed('\%(%.*\)\@<!\\begin\s*{','\%(%.*\)\@<!\\end\s*{',l:line_nr,g:atp_completion_limits[2],1)
14969 " let g:info= " l:max=".l:max." l:end=".l:end." line('.')=".line(".")." l:line_nr=".l:line_nr
14970 " if the line was found append just befor it.
14972 if line(".") <= l:max
14973 if line(".") <= l:end
14974 call append(l:max, l:eindent . l:str)
14975 echomsg "Closing " . l:env_name . " from line " . l:bpos_env[0] . " at line " . l:end+1
14976 call setpos(".",[0,l:max+1,len(l:eindent.l:str)+1,0])
14978 call append(l:end-1, l:eindent . l:str)
14979 echomsg "Closing " . l:env_name . " from line " . l:bpos_env[0] . " at line " . l:end+1
14980 call setpos(".",[0,l:end,len(l:eindent.l:str)+1,0])
14982 elseif line(".") < l:end
14983 let [ lineNr, pos_lineNr ] = getline(".") =~ '^\s*$' ? [ line(".")-1, line(".")] : [ line("."), line(".")+1 ]
14984 call append(lineNr, l:eindent . l:str)
14985 echomsg "Closing " . l:env_name . " from line " . l:bpos_env[0] . " at line " . line(".")+1
14986 call setpos(".",[0, pos_lineNr,len(l:eindent.l:str)+1,0])
14987 elseif line(".") >= l:end
14988 call append(l:end-1, l:eindent . l:str)
14989 echomsg "Closing " . l:env_name . " from line " . l:bpos_env[0] . " at line " . l:end
14990 call setpos(".",[0,l:end,len(l:eindent.l:str)+1,0])
14993 if line(".") >= l:max
14994 call append(l:pos_saved[1], l:eindent . l:str)
14995 keepjumps call setpos(".",l:pos_saved)
14996 echomsg "Closing " . l:env_name . " from line " . l:bpos_env[0] . " at line " . line(".")+1
14997 call setpos(".",[0,l:pos_saved[1]+1,len(l:eindent.l:str)+1,0])
14998 elseif line(".") < l:max
14999 call append(l:max, l:eindent . l:str)
15000 echomsg "Closing " . l:env_name . " from line " . l:bpos_env[0] . " at line " . l:max+1
15001 call setpos(".",[0,l:max+1,len(l:eindent.l:str)+1,0])
15005 let l:pos[1]=l:line_nr
15007 " put cursor at the end of the line where not closed \begin was
15009 keepjumps call setpos(".",[0,l:line_nr,len(getline(l:line_nr)),0])
15010 let l:cline = getline(l:pos_saved[1])
15011 let g:cline = l:cline
15012 let g:line = l:pos_saved[1]
15013 let l:iline=searchpair('\\begin{','','\\end{','nW')
15014 if l:iline > l:line_nr && l:iline <= l:pos_saved[1]
15015 call append(l:iline-1, l:eindent . l:str)
15016 echomsg "Closing " . l:env_name . " from line " . l:bpos_env[0] . " at line " . l:iline
15017 let l:pos_saved[2]+=len(l:str)
15018 call setpos(".",[0,l:iline,len(l:eindent.l:str)+1,0])
15020 if l:cline =~ '\\begin{\%('.l:uenv.'\)\@!'
15021 call append(l:pos_saved[1]-1, l:eindent . l:str)
15022 echomsg "Closing " . l:env_name . " from line " . l:bpos_env[0] . " at line " . l:pos_saved[1]
15023 let l:pos_saved[2]+=len(l:str)
15024 call setpos(".",[0,l:pos_saved[1],len(l:eindent.l:str)+1,0])
15025 elseif l:cline =~ '^\s*$'
15026 call append(l:pos_saved[1]-1, l:eindent . l:str)
15027 echomsg "Closing " . l:env_name . " from line " . l:bpos_env[0] . " at line " . l:pos_saved[1]
15028 let l:pos_saved[2]+=len(l:str)
15029 call setpos(".",[0,l:pos_saved[1]+1,len(l:eindent.l:str)+1,0])
15031 call append(l:pos_saved[1], l:eindent . l:str)
15032 echomsg "Closing " . l:env_name . " from line " . l:bpos_env[0] . " at line " . l:pos_saved[1]+1
15033 let l:pos_saved[2]+=len(l:str)
15034 call setpos(".",[0,l:pos_saved[1]+1,len(l:eindent.l:str)+1,0])
15040 return "this is too hard?"
15044 unlet! l:cenv_names
15047 " if getline('.') =~ '^\s*$'
15051 "{{{2 close math: texMathZoneV, texMathZoneW, texMathZoneX, texMathZoneY
15053 "{{{3 Close math in the current line
15054 echomsg "Closing math from line " . l:begin_line
15055 if math_mode == 'texMathZoneV' && l:line !~ '^\s*\\(\s*$' ||
15056 \ math_mode == 'texMathZoneW' && l:line !~ '^\s*\\\[\s*$' ||
15057 \ math_mode == 'texMathZoneX' && l:line !~ '^\s*\$\s*$' ||
15058 \ math_mode == 'texMathZoneY' && l:line !~ '^\s*\$\{2,2}\s*$'
15059 if math_mode == "texMathZoneW"
15061 if getline(l:begin_line) =~ '^\s*\\\[\s*$'
15062 call append(line("."),atplib#CopyIndentation(getline(l:begin_line)).'\]')
15064 call setline(line("."), strpart(l:cline,0,getpos(".")[2]) . '\]'. strpart(l:cline,getpos(".")[2]))
15067 if getline(l:begin_line) =~ '^\s*\\\[\s*$'
15068 call append(line("."),atplib#CopyIndentation(getline(l:begin_line)).'\]')
15070 call setline(line("."), strpart(l:cline,0,getpos(".")[2]-1) . '\]'. strpart(l:cline,getpos(".")[2]-1))
15071 " TODO: This could be optional: (but the option rather
15072 " should be an argument of this function rather than
15075 let l:pos=getpos(".")
15077 keepjumps call setpos(("."),l:pos)
15078 let b:cle_return="texMathZoneW"
15080 elseif math_mode == "texMathZoneV"
15082 call setline(line("."), strpart(l:cline,0,getpos(".")[2]) . '\)'. strpart(l:cline,getpos(".")[2]))
15084 call setline(line("."), strpart(l:cline,0,getpos(".")[2]-1) . '\)'. strpart(l:cline,getpos(".")[2]-1))
15085 call cursor(line("."),col(".")+2)
15086 let b:cle_return="V"
15088 elseif math_mode == "texMathZoneX"
15089 call setline(line("."), strpart(l:cline,0,getpos(".")[2]-1) . '$'. strpart(l:cline,getpos(".")[2]-1))
15090 call cursor(line("."),col(".")+1)
15091 elseif math_mode == "texMathZoneY"
15092 call setline(line("."), strpart(l:cline,0,getpos(".")[2]-1) . '$$'. strpart(l:cline,getpos(".")[2]-1))
15093 call cursor(line("."),col(".")+2)
15095 "{{{3 Close math in a new line, preserv the indentation.
15097 let l:eindent=atplib#CopyIndentation(l:line)
15098 if math_mode == 'texMathZoneW'
15099 let l:iline=line(".")
15100 " if the current line is empty append before it.
15101 if getline(".") =~ '^\s*$' && l:iline > 1
15104 call append(l:iline, l:eindent . '\]')
15105 echomsg "\[ closed in line " . l:iline
15106 " let b:cle_return=2 . " dispalyed math " . l:iline . " indent " . len(l:eindent) " DEBUG
15107 elseif math_mode == 'texMathZoneV'
15108 let l:iline=line(".")
15109 " if the current line is empty append before it.
15110 if getline(".") =~ '^\s*$' && l:iline > 1
15113 call append(l:iline, l:eindent . '\)')
15114 echomsg "\( closed in line " . l:iline
15115 " let b:cle_return=2 . " inline math " . l:iline . " indent " .len(l:eindent) " DEBUG
15116 elseif math_mode == 'texMathZoneX'
15117 let l:iline=line(".")
15118 " if the current line is empty append before it.
15119 if getline(".") =~ '^\s*$' && l:iline > 1
15122 let sindent=atplib#CopyIndentation(getline(search('\$', 'bnW')))
15123 call append(l:iline, sindent . '$')
15124 echomsg "$ closed in line " . l:iline
15125 elseif math_mode == 'texMathZoneY'
15126 let l:iline=line(".")
15127 " if the current line is empty append before it.
15128 if getline(".") =~ '^\s*$' && l:iline > 1
15131 let sindent=atplib#CopyIndentation(getline(search('\$\$', 'bnW')))
15132 call append(l:iline, sindent . '$$')
15133 echomsg "$ closed in line " . l:iline
15139 " imap <F7> <Esc>:call atplib#CloseLastEnvironment()<CR>
15141 " Close Last Bracket
15142 " {{{1 atplib#CloseLastBracket
15144 " The first function only tests if there is a bracket to be closed.
15145 " {{{2 atplib#CheckBracket
15146 " Returns a list [ l:open_line, l:open_col, l:open_bracket ]
15147 " l:open_col != 0 if any of brackets (in values(g:atp_bracket_dict) ) is
15148 " opened and not closed. l:open_bracket is the most recent such bracket
15149 " ([ l:open_line, l:open_col ] are its coordinates).
15151 " a:bracket_dict is a dictionary of brackets to use:
15152 " { open_bracket : close_bracket }
15153 function! atplib#CheckBracket(bracket_dict)
15155 let limit_line = max([1,(line(".")-g:atp_completion_limits[1])])
15156 let pos_saved = getpos(".")
15158 let ket_pattern = '\%(' . join(values(filter(copy(g:atp_sizes_of_brackets), "v:val != '\\'")), '\|') . '\)'
15161 " But maybe we shouldn't check if the bracket is closed sometimes one can
15162 " want to close closed bracket and delete the old one.
15164 let check_list = []
15166 let g:check_list = check_list
15169 " change the position! and then:
15170 " check the flag 'r' in searchpair!!!
15172 let bracket_list= keys(a:bracket_dict)
15173 for ket in bracket_list
15174 let pos = deepcopy(pos_saved)
15175 let pair_{i} = searchpairpos(escape(ket,'\[]'),'', escape(a:bracket_dict[ket], '\[]'). '\|'.ket_pattern.'\.' ,'bnW',"",limit_line)
15176 if g:atp_debugCB >= 2
15177 echomsg escape(ket,'\[]') . " pair_".i."=".string(pair_{i}) . " limit_line=" . limit_line
15179 let pos[1] = pair_{i}[0]
15180 let pos[2] = pair_{i}[1]
15181 " check_{i} is 1 if the bracket is closed
15182 let check_{i} = atplib#CheckClosed(escape(ket, '\[]'), escape(a:bracket_dict[ket], '\[]'), line("."), g:atp_completion_limits[0],1) == '0'
15183 " check_dot_{i} is 1 if the bracket is closed with a dot (\right.) .
15184 let check_dot_{i} = atplib#CheckClosed(escape(ket, '\'), '\\\%(right\|\cb\Cig\{1,2}\%(g\|l\)\@!r\=\)\s*\.',line("."),g:atp_completion_limits[0],1) == '0'
15185 if g:atp_debugCB >= 2
15186 echomsg escape(ket,'\[]') . " check_".i."=".string(check_{i}) . " check_dot_".i."=".string(check_dot_{i})
15188 let check_{i} = min([check_{i}, check_dot_{i}])
15189 call add(check_list, [ pair_{i}[0], (check_{i}*pair_{i}[1]), i ] )
15190 keepjumps call setpos(".",pos_saved)
15193 keepjumps call setpos(".", pos_saved)
15195 " Find opening line and column numbers
15196 call sort(check_list, "atplib#CompareCoordinates")
15197 let g:check_list = check_list
15198 let [ open_line, open_col, open_bracket_nr ] = check_list[0]
15199 let [ s:open_line, s:open_col, s:opening_bracket ] = [ open_line, open_col, bracket_list[open_bracket_nr] ]
15201 let [ g:open_lineCB, g:open_colCB, g:opening_bracketCB ] = [ open_line, open_col, bracket_list[open_bracket_nr] ]
15203 return [ open_line, open_col, bracket_list[open_bracket_nr] ]
15206 " The second function closes the bracket if it was not closed.
15207 " (as returned by atplib#CheckBracket or [ s:open_line, s:open_col, s:opening_bracket ])
15209 " It is not used to close \(:\) and \[:\] as CloseLastEnvironment has a better
15210 " way of doing that (preserving indentation)
15211 " {{{2 atplib#CloseLastBracket
15212 " a:bracket_dict is a dictionary of brackets to use:
15213 " { open_bracket : close_bracket }
15214 " a:1 = 1 just return the bracket
15215 " a:2 = 0 (default), 1 when used in TabCompletion
15216 " then s:open_line, s:open_col and s:opening_bracket are
15217 " used to avoid running twice atplib#CheckBracket():
15218 " once in TabCompletion and secondly in CloseLastBracket
15221 function! atplib#CloseLastBracket(bracket_dict, ...)
15223 let only_return = ( a:0 >= 1 ? a:1 : 0 )
15224 let tab_completion = ( a:0 >= 2 ? a:2 : 0 )
15228 let size_patterns = []
15229 for size in keys(g:atp_sizes_of_brackets)
15230 call add(size_patterns,escape(size,'\'))
15233 let pattern_b = '\C\%('.join(size_patterns,'\|').'\)'
15234 let pattern_o = '\%('.join(map(keys(a:bracket_dict),'escape(v:val,"\\[]")'),'\|').'\)'
15237 let g:pattern_b = pattern_b
15238 let g:pattern_o = pattern_o
15241 let limit_line = max([1,(line(".")-g:atp_completion_limits[1])])
15243 let pos_saved = getpos(".")
15246 " But maybe we shouldn't check if the bracket is closed sometimes one can
15247 " want to close closed bracket and delete the old one.
15249 let [ open_line, open_col, opening_bracket ] = ( tab_completion ?
15250 \ deepcopy([ s:open_line, s:open_col, s:opening_bracket ]) : atplib#CheckBracket(a:bracket_dict) )
15252 " Check and Close Environment:
15253 for env_name in g:atp_closebracket_checkenv
15254 " To Do: this should check for the most recent opened environment
15255 let limit_line = exists("open_line") ? open_line : search('\\\@<!\\\[\|\\\@<!\\(\|\$', 'bn')
15256 let open_env = searchpairpos('\\begin\s*{\s*'.env_name.'\s*}', '', '\\end\s*{\s*'.env_name.'\s*}', 'bnW', '', limit_line)
15257 let env_name = matchstr(strpart(getline(open_env[0]),open_env[1]-1), '\\begin\s*{\s*\zs[^}]*\ze*\s*}')
15258 if open_env[0] && atplib#CompareCoordinates([(exists("open_line") ? open_line : 0),(exists("open_line") ? open_col : 0)], open_env)
15259 call atplib#CloseLastEnvironment('i', 'environment', env_name, open_env)
15260 return 'closeing ' . env_name . ' at ' . string(open_env)
15266 let g:open_line = open_line
15267 let g:open_col = open_col
15271 " {{{3 main if statements
15273 if getline(open_line)[open_col-3] . getline(open_line)[open_col-2] . getline(open_line)[open_col-1] =~ '\\\@<!\\\%((\|\[\)'
15274 call atplib#CloseLastEnvironment('i', 'math', '', [ open_line, open_col ])
15276 let b:atp_debugCLB = "call atplib#CloseLastEnvironment('i', 'math', '', [ open_line, open_col ])"
15282 let line = getline(open_line)
15284 let bline = strpart(line,0,(open_col-1))
15285 let eline = strpart(line,open_col-1,2)
15287 let g:bline = bline
15288 let g:eline = eline
15291 let opening_size=matchstr(bline,'\zs'.pattern_b.'\ze\s*$')
15292 let closing_size=get(g:atp_sizes_of_brackets,opening_size,"")
15293 " let opening_bracket=matchstr(eline,'^'.pattern_o)
15294 " let opening_bracket=bracket_list[open_bracket_nr]
15296 if opening_size =~ '\\' && opening_bracket != '(' && opening_bracket != '['
15297 let bbline = strpart(bline, 0, len(bline)-1)
15298 let opening_size2 = matchstr(bbline,'\zs'.pattern_b.'\ze\s*$')
15299 let closing_size2 = get(g:atp_sizes_of_brackets,opening_size2,"")
15300 let closing_size = closing_size2.closing_size
15304 let g:bbline = bbline
15305 let g:opening_size2 = opening_size2
15306 let g:closing_size2 = closing_size2
15310 echomsg "Closing " . opening_size . opening_bracket . " from line " . open_line
15314 let g:o_bra = opening_bracket
15315 let g:o_size = opening_size
15316 let g:bline = bline
15318 let g:eline = eline
15319 let g:opening_size = opening_size
15320 let g:closing_size = closing_size
15323 let cline=getline(line("."))
15326 call setline(line("."), strpart(cline, 0, getpos(".")[2]-1).
15327 \ closing_size.get(a:bracket_dict, opening_bracket).
15328 \ strpart(cline,getpos(".")[2]-1))
15330 let l:return=closing_size.get(a:bracket_dict, opening_bracket)
15331 elseif mode() == 'n'
15333 call setline(line("."), strpart(cline,0,getpos(".")[2]).
15334 \ closing_size.get(a:bracket_dict,opening_bracket).
15335 \ strpart(cline,getpos(".")[2]))
15337 let l:return=closing_size.get(a:bracket_dict, opening_bracket)
15339 let pos=getpos(".")
15340 let pos[2]+=len(closing_size.get(a:bracket_dict, opening_bracket))
15341 keepjumps call setpos(".", pos)
15351 " atplib#TabCompletion {{{1
15352 " This is the main TAB COMPLITION function.
15354 " expert_mode = 1 (on) gives less completions in some cases (commands,...)
15355 " the matching pattern has to match at the beginning and
15356 " is case sensitive. Furthermode in expert mode, if
15357 " completing a command and found less than 1 match then
15358 " the function tries to close \(:\) or \[:\] (but not an
15359 " environment, before doing ToDo in line 3832 there is
15360 " no sense to make it).
15361 " <Tab> or <F7> (if g:atp_no_tab_map=1)
15362 " expert_mode = 0 (off) gives more matches but in some cases better ones, the
15363 " string has to match somewhare and is case in
15364 " sensitive, for example:
15365 " \arrow<Tab> will show all the arrows definded in tex,
15366 " in expert mode there would be no match (as there is no
15367 " command in tex which begins with \arrow).
15368 " <S-Tab> or <S-F7> (if g:atp_no_tab_map=1)
15370 " Completion Modes:
15371 " documentclass (\documentclass)
15372 " labels (\ref,\eqref)
15373 " packages (\usepackage)
15375 " environments (\begin,\(:\),\[:\])
15376 " brackets ((:),[:],{:}) preserves the size operators!
15377 " Always: check first brackets then environments. Bracket
15378 " funnction can call function which closes environemnts but not
15380 " bibitems (\cite\|\citep\|citet)
15381 " bibfiles (\bibliography)
15382 " bibstyle (\bibliographystyle)
15383 " end (close \begin{env} with \end{env})
15389 "ToDo: the completion should be only done if the completed text is different
15390 "from what it is. But it might be as it is, there are reasons to keep this.
15393 " Main tab completion function
15394 function! atplib#TabCompletion(expert_mode,...)
15395 let atp_MainFile = atplib#FullPath(b:atp_MainFile)
15396 " {{{2 Match the completed word
15400 let normal_mode=a:1
15403 " this specifies the default argument for atplib#CloseLastEnvironment()
15404 " in some cases it is better to append after than before.
15407 " Define string parts used in various completitons
15408 let l:pos = getpos(".")
15409 let l:pos_saved = deepcopy(l:pos)
15410 let l:line = join(getbufline("%",l:pos[1]))
15411 let l:nchar = strpart(l:line,l:pos[2]-1,1)
15412 " let l:rest = strpart(l:line,l:pos[2]-1)
15413 let l:l = strpart(l:line,0,l:pos[2]-1)
15414 let l:n = strridx(l:l,'{')
15415 let l:m = strridx(l:l,',')
15416 let l:o = strridx(l:l,'\')
15417 let l:s = strridx(l:l,' ')
15418 let l:p = strridx(l:l,'[')
15420 let l:nr=max([l:n,l:m,l:o,l:s,l:p])
15422 " this matches for \...
15423 let l:begin = strpart(l:l,l:nr+1)
15424 let l:cbegin = strpart(l:l,l:nr)
15425 " and this for '\<\w*$' (beginning of last started word) -- used in
15426 " tikzpicture completion method
15427 let l:tbegin = matchstr(l:l,'\zs\<\w*$')
15428 let l:obegin = strpart(l:l,l:o)
15430 " what we are trying to complete: usepackage, environment.
15431 let l:pline = strpart(l:l, 0, l:nr)
15432 " \cite[Theorem~1]{Abcd -> \cite[Theorem~]
15433 let l:ppline = strpart(l:l, 0, l:nr+1)
15434 " \cite[Theorem~1]{Abcd -> \cite[Theorem~]{
15436 let l:limit_line=max([1,(l:pos[1]-g:atp_completion_limits[1])])
15439 let g:nchar = l:nchar
15447 let g:line = l:line
15448 let g:tbegin = l:tbegin
15449 let g:cbegin = l:cbegin
15450 let g:obegin = l:obegin
15451 let g:begin = l:begin
15452 let g:pline = l:pline
15453 let g:ppline = l:ppline
15455 let g:limit_line=limit_line
15459 " {{{2 SET COMPLETION METHOD
15460 " {{{3 --------- command
15461 if l:o > l:n && l:o > l:s &&
15462 \ l:pline !~ '\%(input\|include\%(only\)\?\|[^\\]\\\\[^\\]$\)' &&
15463 \ l:pline !~ '\\\@<!\\$' &&
15464 \ l:begin !~ '{\|}\|,\|-\|\^\|\$\|(\|)\|&\|-\|+\|=\|#\|:\|;\|\.\|,\||\|?$' &&
15465 \ l:begin !~ '^\[\|\]\|-\|{\|}\|(\|)' &&
15466 \ l:cbegin =~ '^\\' && !normal_mode &&
15467 \ l:l !~ '\\\%(no\)\?cite[^}]*$'
15469 " in this case we are completing a command
15470 " the last match are the things which for sure do not ends any
15471 " command. The pattern '[^\\]\\\\[^\\]$' do not matches "\" and "\\\",
15472 " in which case the line contains "\\" and "\\\\" ( = line ends!)
15473 " (here "\" is one character \ not like in magic patterns '\\')
15474 " but matches "" and "\\" (i.e. when completing "\" or "\\\" [end line
15476 if index(g:atp_completion_active_modes, 'commands') != -1
15477 let l:completion_method='command'
15479 let b:comp_method='command'
15481 " let b:comp_method='command fast return'
15484 "{{{3 --------- environment names
15485 elseif (l:pline =~ '\%(\\begin\|\\end\)\s*$' && l:begin !~ '}.*$' && !normal_mode)
15486 if index(g:atp_completion_active_modes, 'environment names') != -1
15487 let l:completion_method='environment_names'
15489 let b:comp_method='environment_names'
15491 " let b:comp_method='environment_names fast return'
15494 "{{{3 --------- colors
15495 elseif l:l =~ '\\textcolor{[^}]*$'
15496 let l:completion_method='colors'
15498 let b:comp_method='colors'
15499 "{{{3 --------- label
15500 elseif l:pline =~ '\\\%(eq\)\?ref\s*$' && strpart(l:l, 0, col(".")) !~ '\\\%(eq\)\?ref\s*{[^}]*}$' && !normal_mode
15501 if index(g:atp_completion_active_modes, 'labels') != -1
15502 let l:completion_method='labels'
15504 let b:comp_method='label'
15506 let b:comp_method='label fast return'
15509 "{{{3 --------- bibitems
15510 elseif l:ppline =~ '\\\%(no\)\?cite\(\s*\[[^]]*\]\s*\)\={' && !normal_mode && l:l !~ '\\cite\s*{[^}]*}'
15511 if index(g:atp_completion_active_modes, 'bibitems') != -1
15512 let l:completion_method='bibitems'
15514 let b:comp_method='bibitems'
15516 let b:comp_method='bibitems fast return'
15519 "{{{3 --------- tikzpicture
15520 elseif search('\%(\\def\>.*\|\\\%(re\)\?newcommand\>.*\|%.*\)\@<!\\begin{tikzpicture}','bnW') > search('[^%]*\\end{tikzpicture}','bnW') ||
15521 \ !atplib#CompareCoordinates(searchpos('[^%]*\zs\\tikz{','bnw'),searchpos('}','bnw'))
15522 "{{{4 ----------- tikzpicture keywords
15523 if l:l =~ '\%(\s\|\[\|{\|}\|,\|\.\|=\|:\)' . l:tbegin . '$' && !normal_mode
15524 if index(g:atp_completion_active_modes, 'tikzpicture keywords') != -1
15526 let b:comp_method='tikzpicture keywords'
15527 let l:completion_method="tikzpicture keywords"
15529 let b:comp_method='tikzpicture keywords fast return'
15532 "{{{4 ----------- tikzpicture commands
15533 elseif l:l =~ '\\' . l:tbegin . '$' && !normal_mode
15534 if index(g:atp_completion_active_modes, 'tikzpicture commands') != -1
15536 let b:comp_method='tikzpicture commands'
15537 let l:completion_method="tikzpicture commands"
15539 let b:comp_method='tikzpicture commands fast return'
15542 "{{{4 ----------- close_env tikzpicture
15544 if (!normal_mode && index(g:atp_completion_active_modes, 'close environments') != -1 ) ||
15545 \ (normal_mode && index(g:atp_completion_active_modes_normal_mode, 'close environments') != -1 )
15547 let b:comp_method='close_env tikzpicture'
15548 let l:completion_method="close_env"
15550 let b:comp_method='close_env tikzpicture fast return'
15554 "{{{3 --------- package
15555 elseif l:pline =~ '\\usepackage\%([.*]\)\?\s*' && !normal_mode
15556 if index(g:atp_completion_active_modes, 'package names') != -1
15557 let l:completion_method='package'
15559 let b:comp_method='package'
15561 let b:comp_method='package fast return'
15564 "{{{3 --------- tikz libraries
15565 elseif l:pline =~ '\\usetikzlibrary\%([.*]\)\?\s*' && !normal_mode
15566 if index(g:atp_completion_active_modes, 'tikz libraries') != -1
15567 let l:completion_method='tikz libraries'
15569 let b:comp_method='tikz libraries'
15571 let b:comp_method='tikz libraries fast return'
15574 "{{{3 --------- inputfiles
15575 elseif ((l:pline =~ '\\input' || l:begin =~ 'input') ||
15576 \ (l:pline =~ '\\include' || l:begin =~ 'include') ||
15577 \ (l:pline =~ '\\includeonly' || l:begin =~ 'includeonly') ) && !normal_mode
15578 if l:begin =~ 'input'
15579 let l:begin=substitute(l:begin,'.*\%(input\|include\%(only\)\?\)\s\?','','')
15581 if index(g:atp_completion_active_modes, 'input files') != -1
15582 let l:completion_method='inputfiles'
15584 let b:comp_method='inputfiles'
15586 let b:comp_method='inputfiles fast return'
15589 "{{{3 --------- bibfiles
15590 elseif l:pline =~ '\\bibliography\%(style\)\@!' && !normal_mode
15591 if index(g:atp_completion_active_modes, 'bibfiles') != -1
15592 let l:completion_method='bibfiles'
15594 let b:comp_method='bibfiles'
15596 let b:comp_method='bibfiles fast return'
15599 "{{{3 --------- bibstyles
15600 elseif l:pline =~ '\\bibliographystyle' && !normal_mode
15601 if (index(g:atp_completion_active_modes, 'bibstyles') != -1 )
15602 let l:completion_method='bibstyles'
15603 let b:comp_method='bibstyles'
15605 let b:comp_method='bibstyles fast return'
15608 "{{{3 --------- documentclass
15609 elseif l:pline =~ '\\documentclass\>' && !normal_mode
15610 if index(g:atp_completion_active_modes, 'documentclass') != -1
15611 let l:completion_method='documentclass'
15612 let b:comp_method='documentclass'
15614 let b:comp_method='documentclass fast return'
15617 "{{{3 --------- font family
15618 elseif l:l =~ '\%(\\usefont{[^}]*}{\|\\DeclareFixedFont{[^}]*}{[^}]*}{\|\\fontfamily{\)[^}]*$' && !normal_mode
15619 if index(g:atp_completion_active_modes, 'font family') != -1
15620 let l:completion_method='font family'
15621 let b:comp_method='font family'
15623 let b:comp_method='font family fast return'
15626 "{{{3 --------- font series
15627 elseif l:l =~ '\%(\\usefont{[^}]*}{[^}]*}{\|\\DeclareFixedFont{[^}]*}{[^}]*}{[^}]*}{\|\\fontseries{\)[^}]*$' && !normal_mode
15628 if index(g:atp_completion_active_modes, 'font series') != -1
15629 let l:completion_method='font series'
15630 let b:comp_method='font series'
15632 let b:comp_method='font series fast return'
15635 "{{{3 --------- font shape
15636 elseif l:l =~ '\%(\\usefont{[^}]*}{[^}]*}{[^}]*}{\|\\DeclareFixedFont{[^}]*}{[^}]*}{[^}]*}{[^}]*}{\|\\fontshape{\)[^}]*$' && !normal_mode
15637 if index(g:atp_completion_active_modes, 'font shape') != -1
15638 let l:completion_method='font shape'
15639 let b:comp_method='font shape'
15641 let b:comp_method='font shape fast return'
15644 "{{{3 --------- font encoding
15645 elseif l:l =~ '\%(\\usefont{\|\\DeclareFixedFont{[^}]*}{\|\\fontencoding{\)[^}]*$' && !normal_mode
15646 if index(g:atp_completion_active_modes, 'font encoding') != -1
15647 let l:completion_method='font encoding'
15648 let b:comp_method='font encoding'
15650 let b:comp_method='font encoding fast return'
15653 "{{{3 --------- brackets
15654 elseif atplib#CheckBracket(g:atp_bracket_dict)[1] != 0
15655 if (!normal_mode && index(g:atp_completion_active_modes, 'brackets') != -1 ) ||
15656 \ (normal_mode && index(g:atp_completion_active_modes_normal_mode, 'brackets') != -1 )
15657 let b:comp_method='brackets'
15658 call atplib#CloseLastBracket(g:atp_bracket_dict, 0, 1)
15661 let b:comp_method='brackets fast return'
15664 "{{{3 --------- algorithmic
15665 elseif atplib#CheckBracket(g:atp_algorithmic_dict)[1] != 0
15666 if (!normal_mode && index(g:atp_completion_active_modes, 'algorithmic' ) != -1 ) ||
15667 \ (normal_mode && index(g:atp_completion_active_modes_normal_mode, 'algorithmic') != -1 )
15668 let b:comp_method='algorithmic'
15669 call atplib#CloseLastBracket(g:atp_algorithmic_dict, 0, 1)
15672 let b:comp_method='algorithmic fast return'
15675 "{{{3 --------- close environments
15677 if (!normal_mode && index(g:atp_completion_active_modes, 'close environments') != '-1' ) ||
15678 \ (normal_mode && index(g:atp_completion_active_modes_normal_mode, 'close environments') != '-1' )
15679 let l:completion_method='close_env'
15681 let b:comp_method='close_env a'
15683 let b:comp_method='close_env a fast return'
15687 " if the \[ is not closed, first close it and then complete the commands, it
15688 " is better as then automatic tex will have better file to operate on.
15689 " {{{2 close environments
15690 if l:completion_method=='close_env'
15692 " Close one line math
15693 if atplib#CheckInlineMath('texMathZoneV') ||
15694 \ atplib#CheckInlineMath('texMathZoneW') ||
15695 \ atplib#CheckInlineMath('texMathZoneX') ||
15696 \ b:atp_TexFlavor == 'plaintex' && atplib#CheckInlineMath('texMathZoneY')
15697 let b:tc_return = "close_env math"
15698 call atplib#CloseLastEnvironment(l:append, 'math')
15699 " Close environments
15701 let b:tc_return = "close_env environment"
15702 let stopline_forward = line(".") + g:atp_completion_limits[2]
15703 let stopline_backward = max([ 1, line(".") - g:atp_completion_limits[2]])
15705 let line_nr=line(".")
15706 while line_nr >= stopline_backward
15707 let line_nr = searchpair('\\begin\s*{', '', '\\end\s*{', 'bnW', 'strpart(getline("."), 0, col(".")-1) =~ "\\\\\\@<!%"', stopline_backward)
15708 if line_nr >= stopline_backward
15709 let env_name = matchstr(getline(line_nr), '\\begin\s*{\zs[^}]*}\ze}')
15710 if env_name =~# '^\s*document\s*$'
15713 let line_forward = searchpair('\\begin\s*{'.env_name.'}', '', '\\end\s*{'.env_name.'}',
15714 \ 'nW', '', stopline_forward)
15715 if line_forward == 0
15725 " the env_name variable might have wrong value as it is
15726 " looking using '\\begin' and '\\end' this might be not enough,
15727 " however the function atplib#CloseLastEnv works perfectly and this
15730 if env_name !~# '^\s*document\s*$'
15731 call atplib#CloseLastEnvironment(l:append, 'environment', '', [line_nr, 0])
15740 " {{{2 SET COMPLETION LIST
15741 " generate the completion names
15742 " {{{3 ------------ ENVIRONMENT NAMES
15743 if l:completion_method == 'environment_names'
15744 let l:end=strpart(l:line,l:pos[2]-1)
15746 let l:completion_list=deepcopy(g:atp_Environments)
15747 if g:atp_local_completion
15748 " Make a list of local envs and commands
15749 if !exists("s:atp_LocalEnvironments")
15750 let s:atp_LocalEnvironments=LocalCommands()[1]
15752 let l:completion_list=atplib#Extend(l:completion_list,s:atp_LocalEnvironments)
15754 let l:completion_list=atplib#Add(l:completion_list,'}')
15756 let l:completion_list=deepcopy(g:atp_Environments)
15757 if g:atp_local_completion
15758 " Make a list of local envs and commands
15759 if !exists("s:atp_LocalEnvironments")
15760 let s:atp_LocalEnvironments=LocalCommands()[1]
15762 call atplib#Extend(l:completion_list,s:atp_LocalEnvironments)
15766 keepjumps call setpos(".",[0,1,1,0])
15767 let l:stop_line=search('\\begin\s*{document}','cnW')
15768 keepjumps call setpos(".",l:pos_saved)
15769 if (atplib#SearchPackage('tikz', l:stop_line) || count(b:atp_PackageList, 'tikz.tex') ) &&
15770 \ ( atplib#CheckOpened('\\begin\s*{\s*tikzpicture\s*}', '\\end\s*{\s*tikzpicture\s*}', line('.'),g:atp_completion_limits[2]) ||
15771 \ atplib#CheckOpened('\\tikz{','}',line("."),g:atp_completion_limits[2]) )
15773 call extend(l:completion_list,atplib#Add(g:atp_tikz_environments,'}'))
15775 call extend(l:completion_list,g:atp_tikz_environments)
15779 if atplib#SearchPackage('amsmath', l:stop_line) || g:atp_amsmath != 0 || atplib#DocumentClass(b:atp_MainFile) =~ '^ams'
15781 call extend(l:completion_list,atplib#Add(g:atp_amsmath_environments,'}'),0)
15783 call extend(l:completion_list,g:atp_amsmath_environments,0)
15786 "{{{3 ------------ PACKAGES
15787 elseif l:completion_method == 'package'
15788 if exists("g:atp_latexpackages")
15789 let l:completion_list = copy(g:atp_latexpackages)
15791 let g:atp_latexpackages = atplib#KpsewhichGlobPath("tex", "", "*.sty")
15792 let l:completion_list = deepcopy(g:atp_latexpackages)
15794 "{{{3 ------------ COLORS
15795 elseif l:completion_method == 'colors'
15796 " To Do: make a predefined lists of colors depending on package
15798 " Make a list of local envs and commands
15799 if !exists("s:atp_LocalColors")
15800 let s:atp_LocalColors=LocalCommands()[2]
15802 let l:completion_list=s:atp_LocalColors
15803 " {{{3 ------------ TIKZ LIBRARIES
15804 elseif l:completion_method == 'tikz libraries'
15805 let l:completion_list=deepcopy(g:atp_tikz_libraries)
15806 " {{{3 ------------ TIKZ KEYWORDS
15807 elseif l:completion_method == 'tikzpicture keywords'
15809 keepjumps call setpos(".",[0,1,1,0])
15810 let l:stop_line=search('\\begin\s*{document}','cnW')
15811 keepjumps call setpos(".",l:pos_saved)
15813 let l:completion_list=deepcopy(g:atp_tikz_keywords)
15814 " TODO: add support for all tikz libraries
15815 let tikz_libraries = atplib#GrepPackageList('\\use\%(tikz\|pgf\)library\s*{')
15816 call map(tikz_libraries, "substitute(v:val, '\\..*$', '', '')")
15817 let g:tikz_libraries = tikz_libraries
15818 let g:tikz_libs = []
15819 for lib in tikz_libraries
15820 if exists("g:atp_tikz_library_".lib."_keywords")
15821 call add(g:tikz_libs, lib)
15822 call extend(l:completion_list,g:atp_tikz_library_{lib}_keywords)
15825 " {{{3 ------------ TIKZ COMMANDS
15826 elseif l:completion_method == 'tikzpicture commands'
15827 let l:completion_list = []
15828 " if tikz is declared and we are in tikz environment.
15829 let tikz_libraries = atplib#GrepPackageList('\\use\%(tikz\|pgf\)library\s*{')
15830 for lib in tikz_libraries
15831 if exists("g:atp_tikz_library_".lib."_commands")
15832 call extend(l:completion_list,g:atp_tikz_library_{lib}_keywords)
15835 if searchpair('\\\@<!{', '', '\\\@<!}', 'bnW', "", max([ 1, (line(".")-g:atp_completion_limits[0])]))
15836 call extend(l:completion_list, g:atp_Commands)
15838 " {{{3 ------------ COMMANDS
15839 elseif l:completion_method == 'command'
15841 let l:tbegin=strpart(l:l,l:o+1)
15842 let l:completion_list=[]
15844 " Find end of the preambule.
15845 if expand("%:p") == atp_MainFile
15846 " if the file is the main file
15847 let saved_pos=getpos(".")
15848 keepjumps call setpos(".", [0,1,1,0])
15849 keepjumps let stop_line=search('\\begin\s*{document}','nW')
15850 keepjumps call setpos(".", saved_pos)
15852 " if the file doesn't contain the preambule
15853 if &l:filetype == 'tex'
15854 let saved_loclist = getloclist(0)
15855 silent! execute '1lvimgrep /\\begin\s*{\s*document\s*}/j ' . fnameescape(atp_MainFile)
15856 let stop_line = get(get(getloclist(0), 0, {}), 'lnum', 0)
15857 call setloclist(0, saved_loclist)
15863 " Are we in the math mode?
15864 let l:math_is_opened = atplib#CheckSyntaxGroups(g:atp_MathZones)
15866 "{{{4 -------------------- picture
15867 if searchpair('\\begin\s*{picture}','','\\end\s*{picture}','bnW',"", max([ 1, (line(".")-g:atp_completion_limits[2])]))
15868 call extend(l:completion_list,g:atp_picture_commands)
15870 " {{{4 -------------------- MATH commands
15871 " if we are in math mode or if we do not check for it.
15872 if g:atp_no_math_command_completion != 1 && ( !g:atp_MathOpened || l:math_is_opened )
15873 call extend(l:completion_list,g:atp_math_commands)
15874 " amsmath && amssymb {{{5
15875 " if g:atp_amsmath is set or the document class is ams...
15876 if (g:atp_amsmath != 0 || atplib#DocumentClass(b:atp_MainFile) =~ '^ams')
15877 call extend(l:completion_list, g:atp_amsmath_commands,0)
15878 call extend(l:completion_list, g:atp_ams_negations)
15879 call extend(l:completion_list, g:atp_amsfonts)
15880 call extend(l:completion_list, g:atp_amsextra_commands)
15881 if a:expert_mode == 0
15882 call extend(l:completion_list, g:atp_ams_negations_non_expert_mode)
15884 " else check if the packages are declared:
15886 if atplib#SearchPackage('amsmath', l:stop_line)
15887 call extend(l:completion_list, g:atp_amsmath_commands,0)
15889 if atplib#SearchPackage('amssymb', l:stop_line)
15890 call extend(l:completion_list, g:atp_ams_negations)
15891 if a:expert_mode == 0
15892 call extend(l:completion_list, g:atp_ams_negations_non_expert_mode)
15897 if atplib#SearchPackage('nicefrac',l:stop_line)
15898 call add(l:completion_list,"\\nicefrac")
15900 " math non expert mode {{{5
15901 if a:expert_mode == 0
15902 call extend(l:completion_list,g:atp_math_commands_non_expert_mode)
15905 " -------------------- LOCAL commands {{{4
15906 if g:atp_local_completion
15908 " make a list of local envs and commands:
15909 if !exists("s:atp_LocalCommands")
15910 if exists("b:atp_LocalCommands")
15911 let s:atp_LocalCommands=b:atp_LocalCommands
15912 elseif exists("g:atp_local_commands")
15913 let s:atp_LocalCommands=g:atp_local_commands
15915 let s:atp_LocalCommands=LocalCommands()[1]
15918 call extend(l:completion_list,s:atp_LocalCommands)
15920 " {{{4 -------------------- TIKZ commands
15921 " if tikz is declared and we are in tikz environment.
15922 let in_tikz=searchpair('\\begin\s*{tikzpicture}','','\\end\s*{tikzpicture}','bnW',"", max([1,(line(".")-g:atp_completion_limits[2])])) || atplib#CheckOpened('\\tikz{','}',line("."),g:atp_completion_limits[0])
15925 " find all tikz libraries at once:
15926 let tikz_libraries = atplib#GrepPackageList('\\use\%(tikz\|pgf\)library\s*{')
15928 " add every set of library commands:
15929 for lib in tikz_libraries
15930 if exists("g:atp_tikz_library_".lib."_commands")
15931 call extend(l:completion_list, g:atp_tikz_library_{lib}_commands)
15935 " add common tikz commands:
15936 call extend(l:completion_list, g:atp_tikz_commands)
15938 " if in text mode add normal commands:
15939 if searchpair('\\\@<!{', '', '\\\@<!}', 'bnW', "", max([ 1, (line(".")-g:atp_completion_limits[0])]))
15940 call extend(l:completion_list, g:atp_Commands)
15943 " {{{4 -------------------- COMMANDS
15944 " if we are not in math mode or if we do not care about it or we are in non expert mode.
15945 if (!g:atp_MathOpened || !l:math_is_opened ) || a:expert_mode == 0
15946 call extend(l:completion_list,g:atp_Commands)
15948 if atplib#SearchPackage('fancyhdr', l:stop_line)
15949 call extend(l:completion_list, g:atp_fancyhdr_commands)
15951 if atplib#SearchPackage('makeidx', l:stop_line)
15952 call extend(l:completion_list, g:atp_makeidx_commands)
15956 " ToDo: add layout commands and many more packages. (COMMANDS FOR
15958 "{{{4 -------------------- final stuff
15959 let l:env_name=substitute(l:pline,'.*\%(\\\%(begin\|end.*\){\(.\{-}\)}.*\|\\\%(\(item\)\s*\)\%(\[.*\]\)\?\s*$\)','\1\2','')
15960 if l:env_name =~ '\\\%(\%(sub\)\?paragraph\|\%(sub\)*section\|chapter\|part\)'
15961 let l:env_name=substitute(l:env_name,'.*\\\(\%(sub\)\?paragraph\|\%(sub\)*section\|chapter\|part\).*','\1','')
15963 let l:env_name=substitute(l:env_name,'\*$','','')
15964 " if the pattern did not work do not put the env name.
15965 " for example \item cos\lab<Tab> the pattern will not work and we do
15966 " not want env name.
15967 if l:env_name == l:pline
15971 if has_key(g:atp_shortname_dict,l:env_name)
15972 if g:atp_shortname_dict[l:env_name] != 'no_short_name' && g:atp_shortname_dict[l:env_name] != ''
15973 let l:short_env_name=g:atp_shortname_dict[l:env_name]
15974 let l:no_separator=0
15976 let l:short_env_name=''
15977 let l:no_separator=1
15980 let l:short_env_name=''
15981 let l:no_separator=1
15984 " if index(g:atp_no_separator_list, l:env_name) != -1
15985 " let l:no_separator = 1
15988 if g:atp_env_short_names == 1
15989 if l:no_separator == 0 && g:atp_no_separator == 0
15990 let l:short_env_name=l:short_env_name . g:atp_separator
15993 let l:short_env_name=''
15996 call extend(l:completion_list, [ '\label{' . l:short_env_name ],0)
15997 " {{{3 ------------ LABELS /are done later only the l:completions variable /
15998 elseif l:completion_method == 'labels'
15999 let l:completion_list = []
16000 " {{{3 ------------ TEX INPUTFILES
16001 elseif l:completion_method == 'inputfiles'
16002 let l:completion_list=[]
16003 call extend(l:completion_list, atplib#KpsewhichGlobPath('tex', b:atp_OutDir . ',' . g:atp_texinputs, '*.tex', ':t:r', '^\%(\/home\|\.\|.*users\)', '\%(^\\usr\|texlive\|miktex\|kpsewhich\|generic\)'))
16004 call sort(l:completion_list)
16005 " {{{3 ------------ BIBFILES
16006 elseif l:completion_method == 'bibfiles'
16007 let l:completion_list=[]
16008 call extend(l:completion_list, atplib#KpsewhichGlobPath('bib', b:atp_OutDir . ',' . g:atp_bibinputs, '*.bib', ':t:r', '^\%(\/home\|\.\|.*users\)', '\%(^\\usr\|texlive\|miktex\|kpsewhich\|generic\|miktex\)'))
16009 call sort(l:completion_list)
16010 " {{{3 ------------ BIBSTYLES
16011 elseif l:completion_method == 'bibstyles'
16012 let l:completion_list=atplib#KpsewhichGlobPath("bst", "", "*.bst")
16013 "{{{3 ------------ DOCUMENTCLASS
16014 elseif l:completion_method == 'documentclass'
16015 if exists("g:atp_latexclasses")
16016 let l:completion_list = copy(g:atp_latexclasses)
16018 let g:atp_latexclasses = atplib#KpsewhichGlobPath("tex", "", "*.cls")
16019 let l:completion_list = deepcopy(g:atp_latexclasses)
16021 " \documentclass must be closed right after the name ends:
16023 call map(l:completion_list,'v:val."}"')
16025 "{{{3 ------------ FONT FAMILY
16026 elseif l:completion_method == 'font family'
16027 let l:bpos=searchpos('\\selectfon\zst','bnW',line("."))[1]
16028 let l:epos=searchpos('\\selectfont','nW',line("."))[1]-1
16030 let l:epos=len(l:line)
16032 let l:fline=strpart(l:line,l:bpos,l:epos-l:bpos)
16033 let l:encoding=matchstr(l:fline,'\\\%(usefont\|DeclareFixedFont\s*{[^}]*}\|fontencoding\)\s*{\zs[^}]*\ze}')
16034 if l:encoding == ""
16035 let l:encoding=g:atp_font_encoding
16037 " let b:encoding=l:encoding
16038 let l:completion_list=[]
16039 let l:fd_list=atplib#FdSearch('^'.l:encoding.l:begin)
16040 " let b:fd_list=l:fd_list
16041 for l:file in l:fd_list
16042 call extend(l:completion_list,map(atplib#ShowFonts(l:file),'matchstr(v:val,"usefont\\s*{[^}]*}\\s*{\\zs[^}]*\\ze}")'))
16044 call filter(l:completion_list,'count(l:completion_list,v:val) == 1 ')
16045 "{{{3 ------------ FONT SERIES
16046 elseif l:completion_method == 'font series'
16047 let l:bpos=searchpos('\\selectfon\zst','bnW',line("."))[1]
16048 let l:epos=searchpos('\\selectfont','nW',line("."))[1]-1
16050 let l:epos=len(l:line)
16052 let l:fline=strpart(l:line,l:bpos,l:epos-l:bpos)
16053 " let b:fline=l:fline
16054 let l:encoding=matchstr(l:fline,'\\\%(usefont\|DeclareFixedFont\s*{[^}]*}\|fontencoding\)\s*{\zs[^}]*\ze}')
16055 if l:encoding == ""
16056 let l:encoding=g:atp_font_encoding
16058 let l:font_family=matchstr(l:fline,'\\\%(usefont\s*{[^}]*}\|DeclareFixedFont\s*{[^}]*}\s*{[^}]*}\|fontfamily\)\s*{\zs[^}]*\ze}')
16059 " let b:font_family=l:font_family
16060 let l:completion_list=[]
16061 let l:fd_list=atplib#FdSearch('^'.l:encoding.l:font_family)
16062 for l:file in l:fd_list
16063 call extend(l:completion_list,map(atplib#ShowFonts(l:file),'matchstr(v:val,"usefont{[^}]*}{[^}]*}{\\zs[^}]*\\ze}")'))
16065 call filter(l:completion_list,'count(l:completion_list,v:val) == 1 ')
16066 "{{{3 ------------ FONT SHAPE
16067 elseif l:completion_method == 'font shape'
16068 let l:bpos=searchpos('\\selectfon\zst','bnW',line("."))[1]
16069 let l:epos=searchpos('\\selectfont','nW',line("."))[1]-1
16071 let l:epos=len(l:line)
16073 let l:fline=strpart(l:line,l:bpos,l:epos-l:bpos)
16074 let l:encoding=matchstr(l:fline,'\\\%(usefont\|DeclareFixedFont\s*{[^}]*}\|fontencoding\)\s*{\zs[^}]*\ze}')
16075 if l:encoding == ""
16076 let l:encoding=g:atp_font_encoding
16078 let l:font_family=matchstr(l:fline,'\\\%(usefont{[^}]*}\|DeclareFixedFont\s*{[^}]*}\s*{[^}]*}\|fontfamily\)\s*{\zs[^}]*\ze}')
16079 let l:font_series=matchstr(l:fline,'\\\%(usefont\s*{[^}]*}\s*{[^}]*}\|DeclareFixedFont\s*{[^}]*}\s*{[^}]*}\s*{[^}]*}\|fontseries\)\s*{\zs[^}]*\ze}')
16080 let l:completion_list=[]
16081 let l:fd_list=atplib#FdSearch('^'.l:encoding.l:font_family)
16083 for l:file in l:fd_list
16084 call extend(l:completion_list,map(atplib#ShowFonts(l:file),'matchstr(v:val,"usefont{[^}]*}{'.l:font_family.'}{'.l:font_series.'}{\\zs[^}]*\\ze}")'))
16086 call filter(l:completion_list,'count(l:completion_list,v:val) == 1 ')
16087 " {{{3 ------------ FONT ENCODING
16088 elseif l:completion_method == 'font encoding'
16089 let l:bpos=searchpos('\\selectfon\zst','bnW',line("."))[1]
16090 let l:epos=searchpos('\\selectfont','nW',line("."))[1]-1
16092 let l:epos=len(l:line)
16094 let l:fline=strpart(l:line,l:bpos,l:epos-l:bpos)
16095 let l:font_family=matchstr(l:fline,'\\\%(usefont\s*{[^}]*}\|DeclareFixedFont\s*{[^}]*}\s*{[^}]*}\|fontfamily\)\s*{\zs[^}]*\ze}')
16096 if l:font_family != ""
16097 let l:fd_list=atplib#FdSearch(l:font_family)
16098 let l:completion_list=map(copy(l:fd_list),'toupper(substitute(fnamemodify(v:val,":t"),"'.l:font_family.'.*$","",""))')
16100 " let l:completion_list=[]
16101 " for l:fd_file in l:fd_list
16102 " let l:enc=substitute(fnamemodify(l:fd_file,":t"),"\\d\\zs.*$","","")
16103 " if l:enc != fnamemodify(l:fd_file,":t")
16104 " call add(l:completion_list,toupper(l:enc))
16107 let l:completion_list=g:atp_completion_font_encodings
16109 " {{{3 ------------ BIBITEMS
16110 elseif l:completion_method == 'bibitems'
16111 let l:col = col('.') - 1
16112 while l:col > 0 && line[l:col - 1] !~ '{\|,'
16115 let l:pat=strpart(l:l,l:col)
16116 let l:bibitems_list=values(atplib#searchbib(l:pat))
16120 let l:pre_completion_list=[]
16121 let l:completion_dict=[]
16122 let l:completion_list=[]
16123 for l:dict in l:bibitems_list
16124 for l:key in keys(l:dict)
16125 " ToDo: change l:dict[l:key][...] to get() to not get errors
16126 " if it is not present or to handle situations when it is not
16128 call add(l:pre_completion_list, l:dict[l:key]['bibfield_key'])
16129 let l:bibkey=l:dict[l:key]['bibfield_key']
16130 let l:bibkey=substitute(strpart(l:bibkey,max([stridx(l:bibkey,'{'),stridx(l:bibkey,'(')])+1),',\s*','','')
16131 if l:nchar != ',' && l:nchar != '}'
16134 let l:title=get(l:dict[l:key],'title','notitle')
16135 let l:title=substitute(matchstr(l:title,'^\s*title\s*=\s*\%("\|{\|(\)\zs.*\ze\%("\|}\|)\)\s*\%(,\|$\)'),'{\|}','','g')
16136 let l:year=get(l:dict[l:key],'year',"")
16137 let l:year=matchstr(l:year,'^\s*year\s*=\s*\%("\|{\|(\)\zs.*\ze\%("\|}\|)\)\s*\%(,\|$\)')
16138 let l:abbr=get(l:dict[l:key],'author',"noauthor")
16139 let l:author = matchstr(l:abbr,'^\s*author\s*=\s*\%("\|{\|(\)\zs.*\ze\%("\|}\|)\)\s*,')
16140 if l:abbr=="noauthor" || l:abbr == ""
16141 let l:abbr=get(l:dict[l:key],'editor',"")
16142 let l:author = matchstr(l:abbr,'^\s*editor\s*=\s*\%("\|{\|(\)\zs.*\ze\%("\|}\|)\)\s*,')
16144 if len(l:author) >= 40
16145 if match(l:author,'\sand\s')
16146 let l:author=strpart(l:author,0,match(l:author,'\sand\s')) . ' et al.'
16148 let l:author=strpart(l:author,0,40)
16151 let l:author=substitute(l:author,'{\|}','','g')
16152 if l:dict[l:key]['bibfield_key'] =~ 'article'
16154 elseif l:dict[l:key]['bibfield_key'] =~ 'book\>'
16156 elseif l:dict[l:key]['bibfield_key'] =~ 'booklet'
16158 elseif l:dict[l:key]['bibfield_key'] =~ 'proceedings\|conference'
16160 elseif l:dict[l:key]['bibfield_key'] =~ 'unpublished'
16162 elseif l:dict[l:key]['bibfield_key'] =~ 'incollection'
16164 elseif l:dict[l:key]['bibfield_key'] =~ 'phdthesis'
16166 elseif l:dict[l:key]['bibfield_key'] =~ 'masterthesis'
16168 elseif l:dict[l:key]['bibfield_key'] =~ 'misc'
16170 elseif l:dict[l:key]['bibfield_key'] =~ 'techreport'
16172 elseif l:dict[l:key]['bibfield_key'] =~ 'manual'
16178 let l:abbr=l:type." ".l:author." (".l:year.") "
16180 call add(l:completion_dict, { "word" : l:bibkey, "menu" : l:title, "abbr" : l:abbr })
16183 for l:key in l:pre_completion_list
16184 call add(l:completion_list,substitute(strpart(l:key,max([stridx(l:key,'{'),stridx(l:key,'(')])+1),',\s*','',''))
16187 " add the \bibitems found in include files
16188 call extend(l:completion_list,keys(atplib#SearchBibItems(atp_MainFile)))
16189 elseif l:completion_method == 'colors'
16191 let l:completion_list=[]
16194 if exists("l:completion_list")
16195 let b:completion_list=l:completion_list " DEBUG
16197 " {{{2 make the list of matching completions
16198 "{{{3 --------- l:completion_method = !close environments !env_close
16199 if l:completion_method != 'close environments' && l:completion_method != 'env_close'
16200 let l:completions=[]
16201 " {{{4 --------- packages, bibstyles, font (family, series, shapre, encoding), document class
16202 if (l:completion_method == 'package' ||
16203 \ l:completion_method == 'bibstyles' ||
16204 \ l:completion_method == 'font family' ||
16205 \ l:completion_method == 'font series' ||
16206 \ l:completion_method == 'font shape' ||
16207 \ l:completion_method == 'font encoding'||
16208 \ l:completion_method == 'documentclass' )
16210 let l:completions = filter(deepcopy(l:completion_list),' v:val =~? "^".l:begin')
16212 let l:completions = filter(deepcopy(l:completion_list),' v:val =~? l:begin')
16214 " {{{4 --------- environment names, colors, bibfiles
16215 elseif ( l:completion_method == 'environment_names' ||
16216 \ l:completion_method == 'colors' ||
16217 \ l:completion_method == 'bibfiles' )
16219 let l:completions = filter(deepcopy(l:completion_list),' v:val =~# "^".l:begin')
16221 let l:completions = filter(deepcopy(l:completion_list),' v:val =~? l:begin')
16223 " {{{4 --------- tikz libraries, inputfiles
16224 " match not only in the beginning
16225 elseif (l:completion_method == 'tikz libraries' ||
16226 \ l:completion_method == 'inputfiles')
16227 let l:completions = filter(deepcopy(l:completion_list),' v:val =~? l:begin')
16228 if l:nchar != "}" && l:nchar != "," && l:completion_method != 'inputfiles'
16229 call map(l:completions,'v:val')
16231 " {{{4 --------- Commands
16232 " must match at the beginning (but in a different way)
16233 " (only in expert_mode).
16234 elseif l:completion_method == 'command'
16235 if a:expert_mode == 1
16236 let l:completions = filter(copy(l:completion_list),'v:val =~# "\\\\".l:tbegin')
16237 elseif a:expert_mode != 1
16238 let l:completions = filter(copy(l:completion_list),'v:val =~? l:tbegin')
16240 " {{{4 --------- Tikzpicture Keywords
16241 elseif l:completion_method == 'tikzpicture keywords'
16242 if a:expert_mode == 1
16243 let l:completions = filter(deepcopy(l:completion_list),'v:val =~# "^".l:tbegin')
16244 elseif a:expert_mode != 1
16245 let l:completions = filter(deepcopy(l:completion_list),'v:val =~? l:tbegin')
16247 " {{{4 --------- Tikzpicture Commands
16248 elseif l:completion_method == 'tikzpicture commands'
16249 if a:expert_mode == 1
16250 let l:completions = filter(deepcopy(l:completion_list),'v:val =~# "^".l:tbegin')
16251 elseif a:expert_mode != 1
16252 let l:completions = filter(deepcopy(l:completion_list),'v:val =~? l:tbegin')
16254 " {{{4 --------- Labels
16255 elseif l:completion_method == 'labels'
16256 " Complete label by string or number:
16258 let aux_data = atplib#GrepAuxFile()
16259 let l:completions = []
16260 for data in aux_data
16261 " match label by string or number
16262 if data[0] =~ l:begin || data[1] =~ '^'. l:begin
16263 let close = l:nchar == '}' ? '' : '}'
16264 call add(l:completions, data[0] . close)
16268 "{{{3 --------- else: try to close environment
16270 call atplib#CloseLastEnvironment('a', 'environment')
16271 let b:tc_return="1"
16274 "{{{3 --------- SORTING and TRUNCATION
16275 " ToDo: we will not truncate if completion method is specific, this should be
16276 " made by a variable! Maybe better is to provide a positive list !!!
16277 if g:atp_completion_truncate && a:expert_mode &&
16278 \ index(['bibfiles', 'bibitems', 'bibstyles', 'labels',
16279 \ 'font family', 'font series', 'font shape', 'font encoding' ],l:completion_method) == -1
16280 call filter(l:completions,'len(substitute(v:val,"^\\","","")) >= g:atp_completion_truncate')
16282 " THINK: about this ...
16283 " if l:completion_method == "tikzpicture keywords"
16284 " let bracket = atplib#CloseLastBracket(g:atp_bracket_dict, 1)
16286 " call add(l:completions, bracket)
16289 " if the list is long it is better if it is sorted, if it short it is
16290 " better if the more used things are at the beginning.
16291 if g:atp_sort_completion_list && len(l:completions) >= g:atp_sort_completion_list && l:completion_method != 'labels'
16292 let l:completions=sort(l:completions)
16295 let b:completions=l:completions
16297 " {{{3 labels, package, tikz libraries, environment_names, colors, bibfiles, bibstyles, documentclass, font family, font series, font shape font encoding and input files
16298 if l:completion_method == 'labels' ||
16299 \ l:completion_method == 'package' ||
16300 \ l:completion_method == 'tikz libraries' ||
16301 \ l:completion_method == 'environment_names' ||
16302 \ l:completion_method == 'colors' ||
16303 \ l:completion_method == 'bibfiles' ||
16304 \ l:completion_method == 'bibstyles' ||
16305 \ l:completion_method == 'documentclass'||
16306 \ l:completion_method == 'font family' ||
16307 \ l:completion_method == 'font series' ||
16308 \ l:completion_method == 'font shape' ||
16309 \ l:completion_method == 'font encoding'||
16310 \ l:completion_method == 'inputfiles'
16311 call complete(l:nr+2,l:completions)
16312 let b:tc_return="labels,package,tikz libraries,environment_names,bibitems,bibfiles,inputfiles"
16314 elseif !normal_mode && l:completion_method == 'bibitems'
16315 call complete(l:col+1,l:completion_dict)
16316 " {{{3 command, tikzcpicture commands
16317 elseif !normal_mode && (l:completion_method == 'command' || l:completion_method == 'tikzpicture commands')
16318 call complete(l:o+1,l:completions)
16319 let b:tc_return="command X"
16320 " {{{3 tikzpicture keywords
16321 elseif !normal_mode && (l:completion_method == 'tikzpicture keywords')
16322 let l:t=match(l:l,'\zs\<\w*$')
16323 " in case '\zs\<\w*$ is empty
16327 call complete(l:t+1,l:completions)
16328 let b:tc_return="tikzpicture keywords"
16330 " If the completion method was a command (probably in a math mode) and
16331 " there was no completion, check if environments are closed.
16332 " {{{ 3 Final call of CloseLastEnvrionment / CloseLastBracket
16333 let l:len=len(l:completions)
16334 if l:len == 0 && (!count(['package', 'bibfiles', 'bibstyles', 'inputfiles'], l:completion_method) || a:expert_mode == 1 )|| l:len == 1
16335 if (l:completion_method == 'command' || l:completion_method == 'tikzpicture commands') &&
16336 \ (l:len == 0 || l:len == 1 && l:completions[0] == '\'. l:begin )
16338 let filter = 'strpart(getline("."), 0, col(".") - 1) =~ ''\\\@<!%'''
16339 let stopline = search('^\s*$\|\\par\>', 'bnW')
16342 let cl_return = atplib#CloseLastBracket(g:atp_bracket_dict)
16344 let g:return = cl_return
16346 " If the bracket was closed return
16347 if cl_return != "0"
16351 " Check inline math:
16352 if atplib#CheckInlineMath('texMathZoneV') ||
16353 \ atplib#CheckInlineMath('texMathZoneW') ||
16354 \ atplib#CheckInlineMath('texMathZoneX') ||
16355 \ b:atp_TexFlavor == 'plaintex' && atplib#CheckInlineMath('texMathZoneY')
16356 let zone = 'texMathZoneVWXY' " DEBUG
16357 call atplib#CloseLastEnvironment(l:append, 'math')
16359 " Check environments:
16361 let l:env_opened= searchpairpos('\\begin','','\\end','bnW','searchpair("\\\\begin{".matchstr(getline("."),"\\\\begin{\\zs[^}]*\\ze}"),"","\\\\end{".matchstr(getline("."),"\\\\begin{\\zs[^}]*\\ze}"),"nW")',max([1,(line(".")-g:atp_completion_limits[2])]))
16362 let l:env_name = matchstr(strpart(getline(l:env_opened[0]), l:env_opened[1]-1), '\\begin\s*{\zs[^}]*\ze}')
16363 let zone = l:env_name " DEBUG
16364 if l:env_opened != [0, 0]
16365 call atplib#CloseLastEnvironment('a', 'environment', l:env_name, l:env_opened)
16370 let b:tc_return.=" close_env end " . zone
16371 let b:comp_method.=' close_env end ' . zone
16373 let b:tc_return.=" close_env end"
16374 let b:comp_method.=' close_env end'
16376 elseif l:completion_method == 'package' ||
16377 \ l:completion_method == 'bibstyles' ||
16378 \ l:completion_method == 'bibfiles'
16379 let b:tc_return='close_bracket end'
16380 call atplib#CloseLastBracket(g:atp_bracket_dict)
16385 " ToDo: (a challenging one)
16386 " Move one step after completion is done (see the condition).
16387 " for this one have to end till complete() function will end, and this can be
16388 " done using (g)vim server functions.
16390 " if l:completion_method == 'environment_names' && l:end =~ '\s*}'
16392 " let l:pos=getpos(".")
16394 " call setpos(".",l:pos)
16397 " unlet variables if there were defined.
16398 if exists("l:completion_list")
16399 unlet l:completion_list
16401 if exists("l:completions")
16402 unlet l:completions
16411 " Font Preview Functions:
16412 "{{{1 Font Preview Functions
16413 " These functions search for fd files and show them in a buffer with filetype
16414 " 'fd_atp'. There are additional function for this filetype written in
16415 " fd_atp.vim ftplugin. Distributed with atp.
16416 "{{{2 atplib#FdSearch
16417 "([<pattern>,<method>])
16418 function! atplib#FdSearch(...)
16424 let pattern = ( a:0 >= 1 ? a:1 : "" )
16425 let method = ( a:0 >= 2 && a:2 != 1 ? 0 : 1 )
16429 let path = substitute(substitute(system("kpsewhich -show-path tex"),'!!','','g'),'\/\/\+','\/','g')
16430 let path = substitute(path,':\|\n',',','g')
16431 let fd = split(globpath(path,"**/*.fd"),'\n')
16433 " Match for l:pattern
16436 call filter(fd, 'fnamemodify(v:val, ":t") =~ pattern')
16438 call filter(fd, 'v:val =~ pattern')
16443 "{{{2 atplib#FontSearch
16444 " atplib#FontSearch(method,[<pattern>])
16445 " method = "" match for name of fd file
16446 " method = "!" match against whole path
16447 if !exists("*atplib#FontSearch")
16448 function! atplib#FontSearch(method,...)
16450 let l:method = ( a:method == "!" ? 1 : 0 )
16451 let l:pattern = ( a:0 ? a:1 : "" )
16453 let s:fd_matches=atplib#FdSearch(l:pattern, l:method)
16455 " Open Buffer and list fd files
16456 " set filetype to fd_atp
16457 let l:tmp_dir=tempname()
16458 call mkdir(l:tmp_dir)
16459 let l:fd_bufname="fd_list " . l:pattern
16460 let l:openbuffer="32vsplit! +setl\\ nospell\\ ft=fd_atp ". fnameescape(l:tmp_dir . "/" . l:fd_bufname )
16462 let g:fd_matches=[]
16463 if len(s:fd_matches) > 0
16465 echomsg "Found " . len(s:fd_matches) . " files."
16467 " wipe out the old buffer and open new one instead
16468 if buflisted(fnameescape(l:tmp_dir . "/" . l:fd_bufname))
16469 silent exe "bd! " . bufnr(fnameescape(l:tmp_dir . "/" . l:fd_bufname))
16471 silent exe l:openbuffer
16472 " make l:tmp_dir available for this buffer.
16473 " let b:tmp_dir=l:tmp_dir
16475 map <buffer> q :bd<CR>
16477 " print the lines into the buffer
16479 call setline(1,"FONT DEFINITION FILES:")
16480 for l:fd_file in s:fd_matches
16481 " we put in line the last directory/fd_filename:
16482 " this is what we cut:
16483 let l:path=fnamemodify(l:fd_file,":h:h")
16484 let l:fd_name=substitute(l:fd_file,"^" . l:path . '/\?','','')
16485 " call setline(line('$')+1,fnamemodify(l:fd_file,":t"))
16486 call setline(line('$')+1,l:fd_name)
16487 call add(g:fd_matches,l:fd_file)
16490 call append('$', ['', 'maps:',
16491 \ 'p Preview font ',
16492 \ 'P Preview font+tex file',
16493 \ '<Tab> Show Fonts in fd file',
16494 \ '<Enter> Open fd file',
16497 \ 'Note: p/P works in visual mode'])
16499 setlocal nomodifiable
16504 echomsg "No fd file found, try :FontSearch!"
16506 echomsg "No fd file found."
16514 "{{{2 atplib#Fd_completion /not needed/
16515 " if !exists("*atplib#Fd_completion")
16516 " function! atplib#Fd_completion(A,C,P)
16519 " let l:path=substitute(substitute(system("kpsewhich -show-path tex"),'!!','','g'),'\/\/\+','\/','g')
16520 " let l:path=substitute(l:path,':\|\n',',','g')
16521 " let l:fd=split(globpath(l:path,"**/*.fd"),'\n')
16522 " let l:fd=map(l:fd,'fnamemodify(v:val,":t:r")')
16525 " for l:fd_file in l:fd
16526 " if l:fd_file =~ a:A
16527 " call add(l:matches,l:fd_file)
16534 " {{{2 atplib#OpenFdFile /not working && not needed?/
16535 " function! atplib#OpenFdFile(name)
16536 " let l:path=substitute(substitute(system("kpsewhich -show-path tex"),'!!','','g'),'\/\/\+','\/','g')
16537 " let l:path=substitute(l:path,':\|\n',',','g')
16538 " let b:path=l:path
16539 " let l:fd=split(globpath(l:path,"**/".a:name.".fd"),'\n')
16540 " let l:fd=map(l:fd,'fnamemodify(v:val,":t:r")')
16542 " execute "split +setl\\ ft=fd_atp " . l:fd[0]
16545 "{{{2 atplib#Preview
16546 " keep_tex=1 open the tex file of the sample file, otherwise it is deleted (at
16547 " least from the buffer list).
16548 " To Do: fd_file could be a list of fd_files which we would like to see, every
16549 " font should be done after \pagebreak[4]
16550 " if a:fd_files=['buffer'] it means read the current buffer (if one has opened
16552 function! atplib#Preview(fd_files,keep_tex)
16553 if a:fd_files != ["buffer"]
16555 for l:fd_file in a:fd_files
16556 call extend(l:fd_files,{fd_file : readfile(l:fd_file)})
16559 let l:fd_files={bufname("%"):getline(1,"$")}
16563 let l:declare_command='\C\%(DeclareFontShape\%(WithSizes\)\?\|sauter@\%(tt\)\?family\|EC@\%(tt\)\?family\|krntstexmplfamily\|HFO@\%(tt\)\?family\)'
16564 let b:declare_command=l:declare_command
16566 let l:font_decl_dict={}
16567 for l:fd_file in a:fd_files
16568 call extend(l:font_decl_dict, {l:fd_file : [ ]})
16569 for l:line in l:fd_files[l:fd_file]
16570 if l:line =~ '\\'.l:declare_command.'\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}'
16571 call add(l:font_decl_dict[l:fd_file],l:line)
16576 " let l:tmp_dir=tempname()
16577 if exists("b:tmp_dir")
16578 let l:tmp_dir=b:tmp_dir
16580 let l:tmp_dir=tempname()
16582 if !isdirectory(l:tmp_dir)
16583 call mkdir(l:tmp_dir)
16585 if a:fd_files == ["buffer"]
16586 let l:testfont_file=l:tmp_dir . "/" . fnamemodify(bufname("%"),":t:r") . ".tex"
16588 " the name could be taken from the pattern
16589 " or join(map(keys(deepcopy(a:fd_files)),'substitute(fnamemodify(v:val,":t:r"),".fd$","","")'),'_')
16590 " though it can be quite a long name.
16591 let l:testfont_file=l:tmp_dir . "/" . fnamemodify(a:fd_files[0],":t:r") . ".tex"
16593 call system("touch " . l:testfont_file)
16595 let l:fd_bufnr=bufnr("%")
16597 let s:text="On November 14, 1885, Senator \\& Mrs.~Leland Stanford called
16598 \ together at their San Francisco mansion the 24~prominent men who had
16599 \ been chosen as the first trustees of The Leland Stanford Junior University.
16600 \ They handed to the board the Founding Grant of the University, which they
16601 \ had executed three days before.\\\\
16602 \ (!`THE DAZED BROWN FOX QUICKLY GAVE 12345--67890 JUMPS!)"
16604 " let l:text="On November 14, 1885, Senator \\& Mrs.~Leland Stanford called
16605 " \ together at their San Francisco mansion the 24~prominent men who had
16606 " \ been chosen as the first trustees of The Leland Stanford Junior University.
16607 " \ They handed to the board the Founding Grant of the University, which they
16608 " \ had executed three days before. This document---with various amendments,
16609 " \ legislative acts, and court decrees---remains as the University's charter.
16610 " \ In bold, sweeping language it stipulates that the objectives of the University
16611 " \ are ``to qualify students for personal success and direct usefulness in life;
16612 " \ and to promote the public welfare by exercising an influence in behalf of
16613 " \ humanity and civilization, teaching the blessings of liberty regulated by
16614 " \ law, and inculcating love and reverence for the great principles of
16615 " \ government as derived from the inalienable rights of man to life, liberty,
16616 " \ and the pursuit of happiness.''\\
16617 " \ (!`THE DAZED BROWN FOX QUICKLY GAVE 12345--67890 JUMPS!)\\par}}
16618 " \ \\def\\\moretext{?`But aren't Kafka's Schlo{\\ss} and {\\AE}sop's {\\OE}uvres
16619 " \ often na{\\"\\i}ve vis-\\`a-vis the d{\\ae}monic ph{\\oe}nix's official r\\^ole
16620 " \ in fluffy souffl\\'es? }
16623 if a:fd_files == ["buffer"]
16624 let l:openbuffer="edit "
16626 let l:openbuffer="topleft split!"
16628 execute l:openbuffer . " +setlocal\\ ft=tex\\ modifiable\\ noro " . l:testfont_file
16629 map <buffer> q :bd!<CR>
16631 call setline(1,'\documentclass{article}')
16632 call setline(2,'\oddsidemargin=0pt')
16633 call setline(3,'\textwidth=450pt')
16634 call setline(4,'\textheight=700pt')
16635 call setline(5,'\topmargin=-10pt')
16636 call setline(6,'\headsep=0pt')
16637 call setline(7,'\begin{document}')
16641 let l:len_font_decl_dict=len(l:font_decl_dict)
16642 let b:len_font_decl_dict=l:len_font_decl_dict
16643 for l:fd_file in keys(l:font_decl_dict)
16645 call setline(l:i,'\textsc\textbf{\Large Fonts from the file '.l:fd_file.'}\\[2em]')
16648 " call setline(l:i,'\pagebreak[4]')
16649 call setline(l:i,'\vspace{4em}')
16650 call setline(l:i+1,'')
16651 call setline(l:i+2,'\textsc\textbf{\Large Fonts from the file '.l:fd_file.'}\\[2em]')
16654 let l:len_font_decl=len(l:font_decl_dict[l:fd_file])
16656 for l:font in l:font_decl_dict[l:fd_file]
16657 " SHOW THE FONT ENCODING, FAMILY, SERIES and SHAPE
16658 if matchstr(l:font,'\\'.l:declare_command.'\s*{[^#}]*}\s*{[^#}]*}\s*{\zs[^#}]*\ze}\s*{[^#}]*}') == "b" ||
16659 \ matchstr(l:font,'\\'.l:declare_command.'\s*{[^#}]*}\s*{[^#}]*}\s*{\zs[^#}]*\ze}\s*{[^#}]*}') == "bx"
16660 let b:show_font='\noindent{\large \textit{Font Encoding}: \textsf{' .
16661 \ matchstr(l:font,'\\'.l:declare_command.'\s*{\zs[^#}]*\ze}\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}') . '}' .
16662 \ ' \textit{Font Family}: \textsf{' .
16663 \ matchstr(l:font,'\\'.l:declare_command.'\s*{[^}#]*}\s*{\zs[^#}]*\ze}\s*{[^#}]*}\s*{[^#}]*}') . '}' .
16664 \ ' \textit{Font Series}: \textsf{' .
16665 \ matchstr(l:font,'\\'.l:declare_command.'\s*{[^#}]*}\s*{[^#}]*}\s*{\zs[^#}]*\ze}\s*{[^#}]*}') . '}' .
16666 \ ' \textit{Font Shape}: \textsf{' .
16667 \ matchstr(l:font,'\\'.l:declare_command.'\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}\s*{\zs[^#}]*\ze}') . '}}\\[2pt]'
16669 let b:show_font='\noindent{\large \textbf{Font Encoding}: \textsf{' .
16670 \ matchstr(l:font,'\\'.l:declare_command.'\s*{\zs[^#}]*\ze}\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}') . '}' .
16671 \ ' \textbf{Font Family}: \textsf{' .
16672 \ matchstr(l:font,'\\'.l:declare_command.'\s*{[^}#]*}\s*{\zs[^#}]*\ze}\s*{[^#}]*}\s*{[^#}]*}') . '}' .
16673 \ ' \textbf{Font Series}: \textsf{' .
16674 \ matchstr(l:font,'\\'.l:declare_command.'\s*{[^#}]*}\s*{[^#}]*}\s*{\zs[^#}]*\ze}\s*{[^#}]*}') . '}' .
16675 \ ' \textbf{Font Shape}: \textsf{' .
16676 \ matchstr(l:font,'\\'.l:declare_command.'\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}\s*{\zs[^#}]*\ze}') . '}}\\[2pt]'
16678 call setline(l:i,b:show_font)
16681 call setline(l:i,'{' . substitute(
16682 \ matchstr(l:font,'\\'.l:declare_command.'\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}'),
16683 \ l:declare_command,'usefont','') .
16685 " WRITE SAMPLE TEXT
16686 call add(b:match,matchstr(l:font,'\\'.l:declare_command.'\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}'))
16689 if l:j<l:len_font_decl
16690 call setline(l:i,s:text . '}\\\\')
16692 call setline(l:i,s:text . '}')
16698 call setline(l:i,'\end{document}')
16700 if b:atp_TexCompiler =~ '^pdf'
16705 call system(b:atp_TexCompiler . " " . l:testfont_file .
16706 \ " && " . b:atp_Viewer . " " . fnamemodify(l:testfont_file,":p:r") . l:ext ." &")
16712 "{{{2 atplib#FontPreview
16713 " a:fd_file pattern to find fd file (.fd will be appended if it is not
16714 " present at the end),
16716 " a:2 = l:keep_tex, i.e. show the tex source.
16717 function! atplib#FontPreview(method, fd_file,...)
16720 let l:method = ( a:method == "!" ? 1 : 0 )
16721 let l:enc = ( a:0 >= 1 ? a:1 : "" )
16722 let l:keep_tex = ( a:0 >= 2 ? a:2 : 0 )
16724 if filereadable(a:fd_file)
16725 let l:fd_file=a:fd_file
16728 if a:fd_file !~ '.fd\s*$'
16729 let l:fd_file=a:fd_file.".*.fd"
16731 let l:fd_file=a:fd_file
16733 " let l:path=substitute(substitute(system("kpsewhich -show-path tex"),'!!','','g'),'\/\/\+','\/','g')
16734 " let l:path=substitute(l:path,':\|\n',',','g')
16735 " let l:fd_all=split(globpath(l:path,"**/*.fd"),'\n')
16736 " let l:fd=filter(l:fd_all,'v:val =~ l:fd_file && fnamemodify(v:val,":t") =~ "^".l:enc')
16738 let l:fd=atplib#FdSearch(a:fd_file, l:method)
16742 echo "FD file not found. Try :FontPreview!"
16744 echo "FD file not found."
16747 elseif len(l:fd) == 1
16748 let l:fd_file_list=l:fd
16752 echo l:i." ".substitute(f,'^'.fnamemodify(f,":h:h").'/\?','','')
16755 let l:choice=input('Which fd file? ')
16759 let l:choice_list=split(l:choice,',')
16760 let b:choice_list=l:choice_list
16761 " if there is 1-4 --> a list of 1,2,3,4
16762 let l:new_choice_list=[]
16763 for l:ch in l:choice_list
16764 if l:ch =~ '^\d\+$'
16765 call add(l:new_choice_list,l:ch)
16766 elseif l:ch =~ '^\d\+\s*-\s*\d\+$'
16767 let l:b=matchstr(l:ch,'^\d\+')
16768 let l:e=matchstr(l:ch,'\d\+$')
16771 call add(l:new_choice_list,l:k)
16776 let b:new_choice_list=l:new_choice_list
16777 let l:fd_file_list=map(copy(l:new_choice_list),'get(l:fd,(v:val-1),"")')
16778 let l:fd_file_list=filter(l:fd_file_list,'v:val != ""')
16779 " let l:fd_file=get(l:fd,l:choice-1,"return")
16780 if len(l:fd_file_list) == 0
16785 call atplib#Preview(l:fd_file_list,l:keep_tex)
16788 " {{{2 atplib#ShowFonts
16789 function! atplib#ShowFonts(fd_file)
16790 let l:declare_command='\C\%(DeclareFontShape\%(WithSizes\)\?\|sauter@\%(tt\)\?family\|EC@\%(tt\)\?family\|krntstexmplfamily\|HFO@\%(tt\)\?family\)'
16793 for l:line in readfile(a:fd_file)
16794 if l:line =~ '\\'.l:declare_command.'\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}'
16795 call add(l:font_decl,l:line)
16798 let l:font_commands=[]
16799 for l:font in l:font_decl
16800 call add(l:font_commands,substitute(
16801 \ matchstr(l:font,'\\'.l:declare_command.'\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}\s*{[^#}]*}'),
16802 \ l:declare_command,'usefont',''))
16804 return l:font_commands
16809 " vim:fdm=marker:ff=unix:noet:ts=8:sw=4:fdc=1
16813 doc/automatic-tex-plugin.txt [[[1
16815 automatic-tex-plugin.txt For Vim version 7 Last change: 7 October 2010
16817 An Introduction to AUTOMATIC (La)TeX PLUGIN
16818 by Marcin Szamotulski
16819 mszamot [AT] gmail [DOT] com
16820 ----------------------------------------
16822 If you found this plugin useful or you have any kind of problems with running
16823 it or some ideas to share, you are cordially invited to write to me:
16824 mszamot@gmail.com. Voting at Vim site is also welcome ;) .
16826 -----------------------------------------------------------------------------
16829 This is a filetype plugin for Vim to comfortably write TeX (LaTeX, PdfLaTeX)
16830 documents, which provides functionality not met in other such plugins. It
16831 makes you FREE from compiling procedure, making this process automatic using
16832 autocommands. It also provides useful mappings and other functions: to analyse
16833 your .log file, to see the table contents, to search for a label, to search in
16834 bib files or to find a macro definition matching a pattern, or even to find
16835 and preview fonts in your tex distribution. The features include an extended
16836 tab completion for: commands, environment names, packages, input files, bib
16837 files, bst files, colors, closing brackets and environments (preserves
16838 nesting),... etc. To have full functionality you need: pdffonts available in
16839 the package 'app-text/poppler' (at least in Gentoo). Another good tool is
16840 texdoc, which is a part of texlive - these days standard TeX distribution for
16841 Linux, and MikTeX on Windows.
16842 ------------------------------------------------------------------------------
16846 * background compilation with debugging mode
16847 * command to make the document (cross references, references, index, tables
16848 of contents) |atp-:MakeLatex|,
16849 * completion for commands, closing environments (even nested), package names,
16850 citations and labels. Support for some latex packages.
16851 See |atp-Completion|,
16852 * table of contents which allows to switch between different sections, files,
16853 but also to delete and paste sections:
16854 See |atp-:TOC|, |atp-toc-window|,
16855 * list of labels which allows to see the context of a label:
16857 * a powerful function to search in bibliographic files (bib files):
16858 See |atp-bibsearch|,
16859 * a command to list ToDo lines:
16861 * a command to search for a macro definition (multi-line support):
16862 See |atp-:DefiSearch|,
16863 * a command to search and PREVIEW fonts in your latex distribution:
16864 See |atp-:FontSearch|, and |atp-:FontPreview|,
16868 -----------------------------------------------------------------------------
16872 |atp-installation| Installation
16873 |atp-commands| Functions and commands
16874 |atp-toc-window| Commands/maps defined in Table of Contents window
16876 |atp-bibsearch| Searching in bib files
16877 |atp-completion| How to use and configure completion
16878 |atp-omnicompletion| and omnicompletion
16879 |atp-configure| How to configure to your needs
16880 |atp-ProjectFiles| A note how to write project files within ATP.
16881 |atp-ProjectScript| A script executing project specific settings.
16882 |atp-mappings| Mappings and Commands
16883 |atp-errors| Error handling
16884 |atp-editing| Editing tools
16885 |atp-requirements| Requirements
16886 |atp-viewers| Note about viewers
16887 (including inverse and reverse searching for xdvi)
16888 |atp-tips| Some tex oriented tips
16889 |atp-highlight| Colors and syntax files
16890 |atp-remarks| Final remarks
16891 |atp-copy-rights| Copy Rights
16894 Note on usage: type :help atp<CTRL>d to see all the helptags. To see help tags
16895 for all the defined functions :help atp*()<CTRL>d, mappings: :help atp-map<CTRL>d
16897 ================================================================================
16900 Changes in version 7.6.3
16902 - ATP is published on the rights of GLP v3 or higher.
16905 imap <Ctrl-j>, imap <Ctrl-k> - these are two motions (based on syntax)
16906 which help to navigate throught brackets (but not only) in insert mode.
16908 map <Ctrl-j>, map <Ctrl-k> - as above but in normal mode.
16910 These motions emulate the behaviour of latex-suite place holder system <++>.
16913 - A bug fixed so that the script should now work in any locale (thanks to the
16916 - If g:atp_babel is set to 1 the keymap name is shown in the status line.
16918 - Project script is written via BufWrite autocommand group (it used to be
16919 VimLeave). Both <SID>Compiler() (map \l) and <SID>MakeLatex() (:MakeLatex)
16920 functions do not write project file while saving the buffer to the disk.
16922 Changes in version 7.6
16924 Project Licence: General Public Licence 3.
16926 The support of 'latexmk' program is added from LatexBox vim plugin by
16927 D. Munger (http://www.vim.org/scripts/script.php?script_id=3109).
16928 This includes the commands: :Latexmk, :LatexmkForce, :LatemkStop,
16929 :LatexmkStatus, :LatexmkStatusDetailed, :LatexmkClean, :LatexmkCLeanAll.
16930 (Now whole, LatexBox plugin is included in ATP - note that some tools have
16931 been extended). You can pass options to latexmk using the variable
16932 g:LatexBox_latexmk_options. Output type is set by g:LatexBox_output_type
16933 (default value is 'pdf').
16935 Maps |atp-]]|, |atp-[[|, |atp-][|, |atp-[]| and |atp-]%|, |atp-[%|.
16937 Maps |atp-}p|, |atp-{p|, |atp-}c|, |atp-{c|, |atp-}s|, |atp-{s|, |atp-}S|,
16938 |atp-{S| which nicely work in visual mode. Previously these maps were
16939 <Localleader>np, <LocalLeader>pp. {:} are configurable with two variables:
16940 |g:atp_map_forward_motion_leader| and |g:atp_map_backward_motion_leader|.
16942 Maps |atp-}i| and |atp-{i| (the same as |atp-]gf| and |atp-[gf|, but
16943 shorter). Note that }} maped to } (the same with {{ and {).
16945 Maps |atp-}e| and |atp-{e| to go o next/previous environment.
16947 |atp-:NInput|, |atp-:PInput| depends on |g:atp_mapNn| (and thus also the
16950 |atp-:NSec|, |atp-:NSSec|, |atp-:NChap|, |atp-:NPart|
16951 |atp-:PSec|, |atp-:PSSec|, |atp-:PChap|, |atp-:PPart|
16952 admits bang "!" (see |:command-bang|). Without bang it skips sections
16953 which are commented with bang it doesn't skip them. The 'wrapscan' option
16954 applies to these commands (and corresponding maps).
16957 vMap c (see |atp-vc|) select comment lines which begin with '^\s*%'.
16958 vMap ip (see |atp-vip|) also \newline starts/ends inner paragraph.
16960 :BibSearch /{pattern}/ [flag]
16961 The command now has the same syntax as |:vimgrep| and |atp-:S|. It is now
16962 possible to pass any vim pattern. Note that /.../ can be omitted if the
16963 pattern doesn't contain white spaces (you can use |/\s| instead).
16964 :BibSearch without any arguments still works (shows all bib files attached
16965 to source tex file).
16967 The pattern to highlight matching string is made better and is passed to
16968 @/ hence you can use |n| and |N| in the BibSearch buffer.
16970 *g:atp_RelativePath*
16971 If set to 1 (the default is 1), project variables: b:atp_MainFile,
16972 b:TreeOfFiles, b:ListOfFiles, b:TypeDict, b:LevelDict will store path
16973 relative to |b:atp_ProjectDir| (which is the same as path to
16974 your main file, however if the file is a symbolic link it will hint
16975 to the resolved path). The |atp-:S| will use correctly these values.
16976 This is particulary useful if you want to share the project file.
16978 If you run into problems with |atp-:S| you can set this variable to
16979 0 and use |atp-:InputFiles| to regenerate the variables - they will
16980 now store the full path (the other way around also works).
16983 Stores the project direcory, by default where |b:atp_MainFile| is
16984 located (the filename is resovled if it is a symbolic link). It is not
16985 written to the |atp-ProjectScript| (this makes the |atp-ProjectScript|
16986 independent of the host when |g:atp_RelativePath| is set). This
16987 variable is mainly for internal purposes. If you want to set the
16988 output directory use |b:atp_OutDir|.
16990 |atp-:PasteSection|
16991 By default it puts the section after the current one.
16993 Changes in version 7.5.3
16995 *atp-:ShowPackages*
16996 :ShowPackages Command list LaTeX packages defined in the preambule.
16998 Completion for Labels, and :Lables command supports subequation
16999 environment, which produces labels : 1a, 1b, etc. Syntax group
17000 atp_Labals_SectionNr is renamed to atp_Labels_CounterValue.
17002 Completion for pseudo algorithms: in algorithmic environment \IF{}:\ENDIF,
17003 \FOR{}:\ENDFOR, \WHILE{}:\ENDWHILE are treated as bracket pairs and can be
17004 closed using Tab Completion (|atp-completion|).
17006 Small change in |atp-:NSec|: it goes to next section, chapter or part,
17007 similarly with the other commands.
17009 The command |atp-:ToggleEnvironment| supports project files
17010 (see|g:atp_toggle_labels| for details.)
17012 |b:atp_ReloadOnError| works in project files.
17014 There is |atp-:ListPrinters| which does what it sais. (It uses |g:atp_ssh|
17015 variable to get the host name to which printers are connected).
17017 New wrapers: \overline{:} and \underline{:} (vmaps <LocalLeader>ov and
17020 <HISTORY_FEATURE> changed into <PROJECT_SCRIPT>
17021 Note: you can remove whole directory ~/.vim/ftplugin/ATP_files/history/
17022 It is not used any more.
17024 As suggested by user its better to store local history file in the project
17025 directory. The project script file which stores local buffer variables is
17026 named '<tex_file_name>.project.vim'. The currently used script is stored
17027 in the variable b:atp_ProjectScript.
17029 Loading procedure searches for files which ends with .project.vim. There
17030 might be many such files in one directory. The file is used which contains
17031 the current buffer in the list b:ListOfFiles. If none of the files project
17032 scripts was containing the current buffer name in b:ListOfFiles then new
17033 project script will be written for the current buffer. Before writting the
17034 project script file if b:ListOfFiles doesn't exists it will be generated
17037 If you want to disable a project script, you can:
17038 (1) write in its first line 'finish', or
17039 (2) include in it 'let b:atp_History = 0'.
17041 If the project script is stored locally the it is easier to include it in
17042 a revision system (bzr, svn, etc.) and share it with colaborators.
17044 The common history file (which stores two global variables:
17045 g:atp_latexpackages, g:atp_latexclasses) is now
17046 ~/.vim/ftplugin/ATP_files/common_var.vim
17048 If you want to disable project script file and common history file set
17049 g:atp_History=0 in your |vimrc| file or |atprc| file.
17051 |atprc| file is executed before project script file (with local
17052 variables) and common_var.vim files are sourced. Thus the history files
17053 will override the settings in |vimrc| and |atprc| files.
17055 Variables and command has changed:
17056 b:atp_ProjectScritp, g:atp_ProjectScript ( old b:atp_History, g:atp_History)
17057 turn on/off Project Script (loading and writting)
17058 b:atp_ProjectScriptFile
17059 the project script file name which is in use.
17060 :LoadProjectScript ( old :LoadHistory)
17061 :LoadCommonScript ( old :LoadCommonHistory)
17062 :WriteProjectScript ( old :WriteHistory)
17063 :WriteCommonScript ( old :WriteTexDistroHistory)
17065 g:atp_cached_common_variables and g:atp_cached_local_variables should
17066 contain variable names which contain the prefix 'b:' for local buffer
17067 variables, 'g:' or '' for global variables, etc... (see
17068 |internal-variables|).
17070 You can also read |atp-ProjectScript|.
17073 Tab completion supports all tikz libraries (as written in pgfmanual.pdf).
17076 All toggle commands: |atp-:ToggleAuTex|, |atp-:ToggleSpace|,
17077 |atp-:ToggleCheckMathOpened|, |atp-:ToggleCallBack|,
17078 |atp-:ToggleDebugMode|, |atp-:ToggleTab|, |atp-:ToggleNn| have an optional
17079 argument with value "on" or "off". If not given they toggles the feature.
17081 Changes in version 7.5
17082 < Tags in help file for variable are now just the variable names, without
17083 the 'atp-' prefix (after all almost every variable starts with atp).
17084 There is one exception: the LatexBox variables.
17086 Other chaneges in |atp-]m|, |g:atp_mapNn|, |atp-:NSec|, |atp-:Open|, |atp-:Babel|, |atp-Compare|,
17087 |atp-:SynxTex|, |atp-item| (updated help tags).
17089 Changes in version 7.4
17090 < See |atp-:NSec|, |atp-visual|(mappings has changed), |atp-:TexDoc|
17091 (updated help tags)
17093 Changes in version 7.3.7
17094 < Numerous Fixes + |atp-:DeleteSection|, |atp-:PasteSection|,
17095 |atp-:SectionStack| and |atp-:Undo|, |atp-highlight-notification|
17096 (updated help tags).
17098 Changes in version 7.3.4 and 7.3.6
17099 < Changes in: |atp-:DefiSearch|, |b:atp_running|, |atp-visual|,
17100 |atp-gw|, |atp-g<|, |atp-g>|, |g:atp_sort_completion_list| .
17102 See |atp-:GotoFile|, |atp-:S|, |atp-:BibSearch| (updated help tags).
17104 New Features in version 7.3.1 (some changes after version 7.3)
17105 < Some things works faster in this version: generating the lables and
17106 recursive looking for input files (using vimgrep).
17108 See: |atp-:GotoFile|, |atp-:MakeLatex|, |atp-:S|, |atp-:ToggleNn|
17109 (updated help tags)
17111 New Features in version 7.2.1
17112 < See: |atp-completion-labels|, |atprc|, |atp-debug-mode|,
17113 |b:atp_TexFlavor| (updated help tags).
17115 New Features in version 7.1
17116 < See: |g:atp_MathVimOptions| (updated help tag).
17119 ================================================================================
17120 INSTALLATION *atp-installation*
17122 :filetype plugin on is required to run this plugin, see
17123 |:filetype-plugin-on| and |:filetype-indent-on| if you want to have
17124 automatic indentation for TeX files. Also |:syntax on| is required as
17125 several features (but not basic ones) requieres syntax.
17127 To install you just need to copy tex.Vim file to ~your ~/.Vim/ftplugin/
17128 directory copy this help file to ~/.Vim/doc and then run :helptags ~/.Vim/doc
17129 and that's all, now you can just type your story ... :)
17131 If you do not like colors you can still set syntax on but clear the highlight
17132 colors (you should make a simple function which clears all the highlight
17133 groups, because ':hi clear' will not give you what you want).
17136 ================================================================================
17137 COMMANDS *atp-commands* *atp-:*
17139 The main function is not seen by the user (it is called s:compiler, for those
17140 who want to read the plugin). It executes tex compiler specified by the
17141 variable b:atp_TexCompiler. It is executed
17142 as an autocommand by the line:
17143 au! CursorHold $HOME*.tex silent call 's:auTeX()'
17144 where s:auTeX() is a simple function which calls s:compiler if the file written
17145 on the disk and the buffer differ. There are two comparing mechanism, the
17146 default one is using |b:changedtick-variable| , the seconds compares the buffer
17147 with the on-disk version:
17149 The default value is "changedtick". Then the |b:changedtick-variable|
17150 is used to find if there buffer differs and to run latex. With any other
17151 value a compare function will be used (which compares the buffer and
17152 the written file on the disk) - this method is much slower but has
17153 additional features: by defualt differences in comments are skipped
17154 (if you set g:atp_compare_embedded_comments = 1 (the default is 0)
17155 then also the comments which do not start right at the begging of line
17156 will be skipped). The second feature is to not see differences in
17157 amount of blank lines: two or more blank lines is the same as one
17158 blank line, for this set g:atp_compare_double_empty_lines to 1, which
17161 As you can see it will run if a key is not pressed during time defined by
17162 option 'updatetime' (see |CursorHold|) in the normal mode. If you type in
17163 insert mode the file won't be compiled (and that's alright as you can be in the
17164 middle of your very long formula). The value of 'updatetime' which works fine
17165 is around 1000ms ('updatetime' is set in milliseconds). Tex compiler is run with
17168 which points to a unique temporary file in Vim temporary directory (using the
17169 function 'tempname()' (see |tempname()|. If you are concerned with security
17170 reasons read also: |shelltemp|.
17172 You can switch off/on the function s:auTeX by pressing <S-F5> or by letting
17173 the local to buffer variable b:autex=1 (on) b:autex=0 (off). It is useful in
17174 some situations turn automatic compiling off. The key <S-F5> calls the function
17175 ToggleAuTex() which sets the variable b:autex and issue a message. You can also
17176 set this variable to 0 for some files that are not supposed to be processed,
17179 au BufRead texmf/*.tex let b:atp_autex=0
17181 On start up b:atp_autex is set to 1 if the path of opened file is not under any
17182 tex directory ('kpsewhich -show-path tex', except the current dir). For example,
17183 files located under your local texmf tree will have b:atp_autex=0.
17185 The second important variable b:atp_TexCompiler (see |b:atp_TexCompiler|) configures
17186 if you use TeX, PdfTeX, LaTeX, PdfLaTeX and it should point to the program
17187 name so please do not use capital letters.
17189 Next variable to set is |b:atp_OutDir|. It configures where TeX
17190 will put the output and where viewer and log analyzing tools can find
17193 The last top most important variable is |g:keep| which is a list of extensions,
17195 let g:keep = ["log", "aux", "toc", "bbl"]
17196 Files with this extension will be copied from |b:atp_OutDir| to the temporary
17197 directory with appropriate name to be used when (La)TeX is compiling. (log file
17198 will be only copied after it is created, other files will be copied back and
17199 forth between you |b:atp_OutDir| and the temporary directory)
17203 By default the call back mechanism is turned on (g:atp_callback=1)
17205 When call back mechanism is set, which is by default if you run gui
17206 version, if you invoke 'vim' from command line you need to add
17207 'servername' variable, it might be desirable to alias vim to to >
17208 vim --servername VIM
17209 < you have additional functionalities:
17211 * STATUS LINE NOTIFICATION: status line can show if tex is running >
17212 let g:atp_status_notification = 1
17213 < If unset you will get a message when compiler ends.
17214 If set the number next to the name of your compiler indicates
17215 how many instances are currently running.
17216 * The LOG FILE will be automatically read after compilation.
17218 * if t:atp_DebugMode = 'silent'
17219 You will not get any message from compilation.
17222 After the end of compilation (invoked by the user
17223 or autocommand) you will get a message with the
17224 return status of the compilator.
17226 If you open the error window with :copen or with
17227 the menu option ToggleDebugMode then it will be
17228 automatically closed after first compilation with
17232 Every compilation which is invoked by the user will
17233 be run in verbose mode as with <F5> key.
17235 Note: the 'verbose' mode in 'vim' (in console) needs to be run, when
17236 there is no other latex instance running. Now you get a message to
17237 wait until compilation ends. In future releases, a better solution
17238 will be worked out. Gui version 'gvim' works better (as it doesn't
17239 suspend the editor).
17241 The background compilation is always done in g:atp_DefaultDebugMode.
17242 Unless it is set to 'verbose' in which case 'debug' mode is used.
17244 You can invoke compiler in the 'debug' mode with '<LocalLeader>d',
17245 '<LocalLeader>l' uses the default mode.
17247 :DebugMode {debug-mode} *atp-:DebugMode*
17248 Command which help to set b:atp_DebugMode variable (has nice completion).
17249 {debug-mode} is one of "silent", "debug", "verbose".
17252 *b:atp_ReloadOnError*
17253 The variable b:atp_ReloadOnError if set to 1 (which is the default) reload the
17254 file even when the exit status of compiler was non zero. If set to 0, then the
17255 file will not be reloaded [actually for viewers other than xpdf it will not be
17256 copied from the temporary directory, for xpdf it will be copied but not
17259 There is also a variable which stores the last command which executed
17260 your tex compiler, see |g:atp_TexCommand|.
17262 Below I explain commands (functions) which are accesible:
17264 :{runs}TEX[!] [debug_mode] *atp-:TEX*
17266 If anyway you want to run TeX yourself but you do not want to see the
17267 output this is the right tool. This runs TeX in 'nonstopmode'. You can
17268 specify an argument {runs} which tells how many consecutive runs of
17269 TeX you need (this is important if you want to compile Table of
17270 Contents, or index, or the bibliography (see |atp-:Bibtex|)
17272 Without "!" it copies the aux file only if there are no compilation
17273 errors, with "!" it updates the aux file even if there were errors.
17274 This is done to make the labels completion work better, when there are
17275 errors they often affect the aux file in a way that interfers with
17276 |atp-:Labels| command.
17278 If b:atp_OpenViewer=1 and there current viewer (b:Viewer) is not
17279 running on the output file then this function will open a viewer. By
17280 default b:atp_OpenViewer=0 and this feature is disabled.
17282 The command :2TEX will call the compiler two times.
17284 It is useful when you want to make the outline (using hyperref
17285 package) of your article in pdf files, the tex file has to be
17286 'sourced' twice. To make the bibliography you can use |atp-:Bibtex|.
17288 If {runs} > 5 it will be reduced to 5, to avoid running tex for hundreds
17289 (or event thousands) of times (what could happen otherwise by
17290 a mistake giving the range of the command to be the current line
17293 The optional argument [debug_mode] has possible valus: '', 'silent',
17294 'debug', 'verbose'. When '' the value of g:atp_DefaultDebugMode is
17295 used. See the description of |atp-debug-mode|.
17297 \d is mapped to :TEX debug and \l to :TEX (thus it uses your default
17302 This is equivalent to ':TEX debug'.
17306 With one command you can make your whole document: cross references,
17307 bibliography (with or without bibtex), index, table of contents, table
17308 of figures, table of theorems ([ntheorem package]), table of
17309 algorithms. ':MakeLatex!' should be used when an entry from
17310 bibliography was deleted (when 'bibtex' is involved this is when you
17311 delete last citation command of a bib entry).
17313 :ShowErrors [flag] *atp-:ShowErrors*
17314 This command shows error/warning messages. It sets the |'errorformat'|
17315 variable accordingly to the optional [flag] argument, which is a word
17319 w - include all warning messages
17320 r - include all reference warnings
17321 c - include all citations warnings
17322 f - include all font warnings
17323 fi - include font info massages
17324 F - show files listed in the log
17325 (messages which start with 'File: ')
17326 shows the files loaded by tex
17327 for example fd files that LaTeX is using
17328 p - show packages loaded by tex
17329 (messages which start with 'Package: ')
17330 all - show all the log file
17331 o - open the log file in a new buffer (split).
17333 If none flag is given 'e' is used. If 'o' flag is uesd the split
17334 buffer with log message has a map 'q' to ':bd'.
17337 < will show all reference and citation warnings.
17339 ShowErrors maps: *atp-:ShowErrors-maps*
17341 <F6>+e to see all errors (:ShowErrors e)
17342 <F6>+w to see all warnings (:ShowErrors w)
17343 <F6>+r to see warnings coming (:ShowErrors rc)
17344 from references or citations
17345 <F6>+f to see font warnings (:ShowErrors f)
17347 this is not a texloganalyzer mapping but it is a good place to mention it:
17348 <F6>+l to open log file in a new split window
17349 this is a mapping to the |atp-:OpenLog|.
17351 :SetErrorFormat {flag} *atp-:SetErrorFormat*
17352 This command has the same syntax as :ShowErrors. It only sets the
17353 |'erroformat'| variable.
17356 :Compiler {compiler-program} *atp-:Compiler*
17357 Command which help to set b:atp_TexCompiler variable (with
17360 :Bibtex[!] [debug_mode] *atp-:Bibtex*
17362 This function will call bibtex to produce the bibliography file
17363 (.bbl). If in |b:atp_OutDir| there is no 'aux' file it first calls tex
17364 compiler. After the 'bbl' file is produced two consecutive runs of tex
17365 compiler are called to make the bibliography.
17367 If you specify any value to the [debug_mode] option then then this function
17368 will be called in verbose mode (only the last time tex compiler will
17369 run in errorstop mode). This gives you the chance to see the output of
17370 bibtex command for a second. The command :Bibtex v is associated to
17371 this behaviour. If you want to just run bibtex see the next function.
17373 The command :Bibtex will :call Bibtex(), while :Bibtex v
17374 (and :Bibtex [debug_mode]) will :call Bibtex(1)
17376 The bang "!" is used in the same way as for |atp-:TEX| command.
17378 For the description of optional argument [debug_mode] see |atp-:TEX|.
17380 *g:atp_raw_bibinputs*
17381 Tex is looking for the date base files in the path: `kpsewhich
17382 -show-path bib`. The variable g:atp_bibinputs contains
17383 these directories separated by commas. If atp cannot find your
17384 bib file, tex also won't be able.
17385 *g:atp_raw_texinputs*
17386 Similarly this variable stores all of path reported by `kpsewhich
17389 This is a list of directories as g:atp_raw_bibinputs with appended '**'
17390 see ':h file-searching'.
17392 This is a list of directories as g:atp_raw_texinputs with appended '**'
17393 see ':h file-searching'.
17395 :ViewOutput *atp-:ViewOutput*
17396 map \v,map <F3>, imap <F3>
17397 You would like to see what you are editing use this function. It will
17398 use the program defined in the variable b:atp_Viewer. See |b:atp_Viewer|,
17399 |g:atp_XpdfServer|, |atp-xpdfOptions|. When there is no output file it will run
17400 TeX and open the file. Read more about particular viewers
17401 (inverse/reverse searching) in |atp-viewers|.
17403 :Viewer {viewer-program} *atp-:Viewer*
17404 Command which help to set b:atp_Viewer variable (with nice completion).
17406 :SetXdvi *atp-:SetXdvi*
17407 This command sets the options for xdvi viewer, which enables inverse
17408 and reverse searching. It sets the command >
17411 < For inverse searching hold CTRL and click left mouse button on
17412 the text in xdvi viewer.
17414 :SetXpdf *atp-:SetXpdf*
17415 This command sets the options for xpdf viewer (as for now the
17416 inverse/reverse searching in pdf files is not implemented)
17417 It will read the xpdf viewer options from the variables
17418 b:atp_xpdfOptions and g:atp_xpdfOptions.
17421 :BibSearch /{pattern}/ [flag] see |atp-:BibSearch|
17422 This function finds bib entries in bib files defined in your tex file
17423 and in the variable b:atp_BibFiles (see |b:atp_BibFiles|), which match the
17424 [pattern] (a vim regular expression). The output is configurable by
17425 the [flag] argument, see |atp-bibflags|. By default the pattern is
17428 :BibChoose see |atp-:BibChoose|
17429 map c, map y, map p
17430 This function is defined in the buffer with results of BibSearch
17431 command. It is mapped to 'y', 'c' and 'p' and let you copy the bib
17432 entry key to a register (see |atp-:BibChoose|) or directly to last
17433 opened buffer (after the last cursor position). When you choose to
17434 paste, it will close the BibSearch window.
17437 :FindBibFiles *atp-:FindBibFiles*
17438 This updates the variables s:bibfiles, s:allbibfiles,
17439 s:notreadablebibfiles. Finds all bib files defined in all
17440 '\bibliography' commands. For more about the above variables read
17441 |atp-variables-bib|. This function is called internally be the script
17442 functions BibSearch/BibChoose. The command :FindBibFiles finds bib
17443 files in the current buffer.
17445 If a readable bib file was not found under one of path listed in of
17446 g:atp_bibinputs variable (see |g:atp_bibinputs|) it is classified
17450 :GotoFile[!] *atp-:GotoFile*
17451 :EditInputFile[!] / the old name / *atp-:EditInputFile*
17453 This command finds input files under b:atp_MainFile (it is recursive).
17454 The nmap 'gf' checks first if there is a file under the cursor. If
17455 there is no file under the cursor it list all input files. Input file
17456 is one introduced in the source file with \input{<file>}, \input
17457 <file> \include{<file>}. The current file is now shown with highlight
17458 group: |hl-WarningMsg|.
17460 This command uses kpsewhich to find in which path to find input files.
17461 Actually the path variables: |g:atp_texinputs| for input files and
17462 |g:atp_bibinputs| for bib files are used.
17464 The bibliographis declared are also listed. The command searches for
17465 them in any directory listed in g:atp_bibinputs (see
17466 |g:atp_bibinputs|).
17468 If g:atp_developer = 1 (default 0) then the map 'gf' can also open
17469 package files and document class files, but only when using 'gf' over
17470 \usepackage or \documentclass tex commands.
17472 With bang "!" this command regenerates tree of files (this is
17473 important only in files with input lines), without it uses cached
17474 values (if they exist).
17476 The current file is now shown with highlight group: |hl-WarningMsg|.
17480 If you configure g:atp_LibraryPath, this function will find files
17481 matching [pattern] under g:atp_LibraryPath and let them open with
17482 a program defined in >
17484 < The g:atp_LibraryPath is a comma-separeted list of directory names.
17485 You can use wildcards '**' and '*' as in |globpath()|.
17486 The default value of g:atp_OpenTypeDict is: >
17487 let g:atp_OpenTypeDict = {
17488 \ "pdf" : "xpdf", "ps" : "evince",
17489 \ "djvu" : "djview", "txt" : "split" ,
17490 \ "tex" : "edit", "dvi" : "xdvi -s 5" }
17491 < The values of g:atp_OpenTypeDict should be a program to open the file,
17492 or one of 'tabe', 'split', 'edit', (if 'vim' is sepcified, then 'tabe'
17493 will be used). The cat program is also supported.
17495 Found files (all not just matching ones) are stored in the variable
17496 g:atp_Library. It is set by |globpath()| on g:atp_LibraryPath and then
17497 filtered, only files which extensions are given in g:atp_OpenTypeDict
17498 will be stored. This variable is restored by the history common file.
17499 You can use {bang} "!" to regenarete the library if it has changed.
17500 This is particulary useful as by default ATP remebers g:atp_Library in
17501 the common project script (see |atp-ProjectScript|).
17503 :ShowErrors o *atp-:OpenLog*
17504 :OpenLog, map <F6>l, imap <F6>l
17505 Opens log file in a new split window with two options (which are set
17506 locally): 'ruler', 'nospell', and a map 'q' to ':bd'.
17508 You can also use the command ':Explore' to see log, aux, ... files
17509 (which is a part of 'netrw' vim plugin).
17512 In the log file there are some special tools to syncronize the tex source file
17513 and the Viewer (currently on xpdf is supported) with log file: |atp-:SyncTex|
17514 and |atp-:SyncXpdfLog|) These tools can sync tex file/xpdf automatically using
17515 autocommand group |CursorMoved|.
17519 If you open log file with ':ShowErrors o' command then you can use
17520 this command to move to the place in the source code where the error
17521 occurs. It works with project files and also can go to error which
17522 appear in a declared package. It will go to the first error line
17523 declared in the log file below the cursor position (more precisely, to
17524 frist line which matches '^l\.\d\+\|on input line\|at lines' will be used).
17526 With bang [!] it opens new window if the file with error is not shown
17527 in the current tab page. Without bang it opens the file in the window
17528 where ':ShowErrors o' was used.
17530 If you set g:atp_SyncLog = 1 (the default value is 0) then the source
17531 file will be syncronized with the log file via autocommand (with
17532 |CursorMoved|). This sets 'cursorline' option to indicate the
17533 corresponding line in the source file. When the log buffer becomes
17534 hidden this option should be unset.
17536 To set g:atp_SyncLog you can use :Sync command. ':Sync' will toggle
17537 the value, ':Sync on' will set it to 1 and ':Sync off' will set it
17540 If you set g:atp_developer = 1 this command will also go to files
17541 under texmf tree (pacakages and classes).
17545 *g:atp_SyncXpdfLog*
17546 If you set g:atp_SyncXpdfLog = 1 (the default value is 0) and you use
17547 xpdf as a viewer it will be syncronised with the log file (with
17548 autocommand group |CursorMoved|). You can also use the command
17549 :SyncXpdf or :Xpdf in the log buffer which does the same.
17552 :Delete[!] *atp-:Delete*
17554 Deletes all files which extension belongs to g:atp_tex_extensions in
17555 the directory |b:atp_OutDir|. By default g:atp_tex_extensions does not
17556 contain '.tex', '.pdf', '.dvi' so none of your important files will be
17557 deleted. When the command is used with bang it also deletes the
17558 current output file.
17560 :SshPrint [printer], [printer_options] *atp-:SshPrint*
17561 It will run 'lpr' command and append to it the options defined in the
17562 variable 'g:printeroptions' + options given in the second argument. It
17563 prints the pdf or dvi depending on the value of |b:atp_TexCompiler|.
17565 If you specify the variable 'g:atp_ssh=<user>@<host>' it will print
17566 via ssh on the <host> using the [printer]. The command ':SshPrint' has
17567 a completion set for the printers available on your local system or in
17568 the host. All the arguments of the command SshPrint are |<f-args>|.
17570 Both arguments are optional (the default system printer is used, and
17571 only the options 'g:printeroptions' apply).
17573 The command has completion for the names of printers (also remote
17574 printers), press <Tab> to cycle through printers, or type first
17575 letters of the printers name and press <Tab> to complete it.
17579 Sends "lpstat -l" remotely (using the |g:atp_ssh| value) or locally and
17582 :ListPrinters *atp-:ListPrinters*
17583 List printers available on the host |g:atp_ssh|.
17586 If g:atp_babel variable is set on start up to 1 (however, the default
17587 value is 0, you can use |vimrc| or |atprc| file to switch it on) then
17588 ATP will set the |'keymap'| option according to the default babel
17589 languege (which is the last language passed to babel as optional
17590 argument [lang_list] in \usepackage[lang_list]{babel}).
17592 The |g:atp_kemaps| variable is used to translate babel language name
17593 to 'keymap' value. The default is something like: >
17594 let g:atp_keymaps = {
17595 \ 'british' : 'ignore', 'english' : 'ignore',
17596 \ 'USenglish' : 'ignore', 'UKenglish' : 'ignore',
17597 \ 'american' : 'ignore',
17598 \ 'bulgarian' : 'bulgarian-bds', 'croatian' : 'croatian',
17599 \ 'czech' : 'czech', 'greek' : 'greek',
17600 \ 'plutonikogreek': 'greek', 'hebrew' : 'hebrew',
17601 \ 'russian' : 'russian-jcuken', 'serbian' : 'serbian',
17602 \ 'slovak' : 'slovak', 'ukrainian' : 'ukrainian-jcuken',
17603 \ 'polish' : 'polish-slash' }
17604 < When the value is <ignore> then the function <SID>Babel() (or the
17605 command |atp-:Babel|) will ignore setting keymap option for this
17606 language. Using the above syntax you can set this variable in |vimrc|
17609 This is useful if you in day to day work use one language, but some
17610 times you write a tex file in some other language.
17613 :ShowOptions[!] [pattern]
17614 This will show values of variables that are currently set.
17615 With bang it also shows global variables defined in
17616 'ftplugin/ATP_files/options.vim' (that means almost all global
17617 variables). Completion lists are filtered out by default.
17619 The optional argument [pattern] is used to filter variables names with
17622 TIP: if you are looking for a variable you can use this command to
17625 *atp-:WrapSelection*
17626 :WrapSelection {beginWrapper}, [endWrapper], [cursor_pos], [new_lines]
17628 Puts selected text inside begin_wrapper: [endWrapper] and sets the
17629 cursor position according to the variables [cursor_pos]. Possible values
17630 are: a number (indicates the character of {beginWrapper} to put the
17631 cursor on (see and check vmap \c below), or 'end' put the cursor at
17632 the end of [endWrapper] or 'begin' leave the cursor at the beginning
17633 (to be precise at the end of the starting wrapper).
17634 The default [endWrapper] is '}'. The last argument [new_lines]
17635 0/1 (default is 0): if 1 then the begin_wrapper and end_wrapper are put
17636 in seperate lines (the begin line and end line are split), this is
17637 useful for putting text into and environment \begin{}:\end{}.
17639 The command arguments should be separated with commas and quoted
17640 separately (see |<args>|).
17642 For the predefined maps which use WrapSelection see below
17643 |atp-maps-WrapSelection| or use |atp-:HelpVMaps|.
17645 *atp-:InteligentWrapSelection*
17646 :InteligentWrapSelection {mathWrapperPair}, {textWrapperPair}, [cursor_pos], [new_lines]
17648 Puts the selected text inside {mathWrapperPair} if the cursor stands
17649 in mathematics otherwise inside {textWrapperPair}.
17650 {mathWrapperPair} {textWrapperPair} are vim lists of length at
17651 least 1, the first wrapper is the opening and the second is the
17652 closing one (if not given the default '}' is used. The other arguments
17653 are as for |atp-:WrapSelection|. If the opening leader in is not
17654 given then this command is not wrapping the text (see below for the
17655 suggested map '\tx')
17657 The command arguments should be separated with commas and quoted
17658 separately (see |<args>|).
17660 For the predefined maps which use WrapSelection see below
17661 |atp-maps-InteligentWrapSelection| or use |atp-:HelpVMaps|.
17663 *atp-maps-WrapSelection*
17664 *atp-maps-InteligentWrapSelection*
17665 These are the provided maps in visual mode: >
17666 vmap <buffer> \rm :<C-U>InteligentWrapSelection ['\\textrm{'], ['\\mathrm{']<CR>
17667 vmap <buffer> \em :<C-U>InteligentWrapSelection ['\\emph{'], ['\\mathit{']<CR>
17668 vmap <buffer> \it :<C-U>InteligentWrapSelection ['\\textit{'], ['\\mathit{']<CR>
17669 vmap <buffer> \sf :<C-U>InteligentWrapSelection ['\\textsf{'], ['\\mathsf{']<CR>
17670 vmap <buffer> \tt :<C-U>InteligentWrapSelection ['\\texttt{'], ['\\mathtt{']<CR>
17671 vmap <buffer> \bf :<C-U>InteligentWrapSelection ['\\textbf{'], ['\\mathbf{']<CR>
17672 vmap <buffer> \bb :<C-U>InteligentWrapSelection ['\\textbf{'], ['\\mathbb{']<CR>
17673 vmap <buffer> \sl :<C-U>WrapSelection '\\textsl{'<CR>
17674 vmap <buffer> \sc :<C-U>WrapSelection '\\textsc{'<CR>
17675 vmap <buffer> \up :<C-U>WrapSelection '\\textup{'<CR>
17676 vmap <buffer> \md :<C-U>WrapSelection '\\textmd{'<CR>
17677 vmap <buffer> \un :<C-U>WrapSelection '\\underline{'<CR>
17678 vmap <buffer> \ov :<C-U>WrapSelection '\\overline{'<CR>
17679 vmap <buffer> \n :<C-U>InteligentWrapSelection ['\\textnormal{'],['\\mathnormal{']<CR>
17680 vmap <buffer> \cal :<C-U>InteligentWrapSelection [''],['\\mathcal{']<CR>
17681 vmap <LocalLeader>f :WrapSelection '{\usefont{'.g:atp_font_encoding.'}{}{}{}\selectfont ', '}',(len(g:atp_font_encoding)+11)<CR>
17682 < Suggested maps: >
17683 vmap <buffer> \tx :<C-U>InteligentWrapSelection [''],['\\text{']<CR>
17684 vmap <buffer> \in :<C-U>InteligentWrapSelection [''],['\\intertext{']<CR>"
17685 < The leader '\' in above commands is configurable: the value of
17686 g:atp_vmap_text_font_leader is used (the default is '\').
17688 Another provided wrapper: >
17689 vmap <buffer> \f :WrapSelection
17690 \ '{\\usefont{".g:atp_font_encoding."}{}{}{}\\selectfont ', '}', '(len(g:atp_font_encoding)+11)'<CR>
17691 < Where the variable: >
17692 g:atp_font_encoding
17693 < stores the default encoding which is 'OT1', unless you use fontenc
17694 package, then the default for fontenc is used (the last defined in
17695 \usepackage[...]{fontenc} see the 'Latex2e font selection'
17696 /font user guide/ available on CTAN).
17699 vmap m :WrapSelection '\(', '\)'<CR>
17700 vmap M :WrapSelection '\[', '\]'<CR>
17701 vmap <LocalLeader>( :WrapSelection '(', ')', 'begin'<CR>
17702 vmap <LocalLeader>[ :WrapSelection '[', ']', 'begin'<CR>
17703 vmap <LocalLeader>{ :WrapSelection '{', '}', 'begin'<CR>
17704 vmap <LocalLeader>) :WrapSelection '(', ')', 'end'<CR>
17705 vmap <LocalLeader>] :WrapSelection '[', ']', 'end'<CR>
17706 vmap <LocalLeader>} :WrapSelection '{', '}', 'end'<CR>
17707 vmap <LocalLeader>b( :WrapSelection '\left(', '\right)', 'begin'<CR>
17708 vmap <LocalLeader>b[ :WrapSelection '\left[', '\right]', 'begin'<CR>
17709 vmap <LocalLeader>b( :WrapSelection '\left(', '\right)', 'begin'<CR>
17710 vmap <LocalLeader>b[ :WrapSelection '\left[', '\right]', 'end'<CR>
17711 vmap <LocalLeader>b{ :WrapSelection '\left{', '\right}', 'end'<CR>
17712 vmap <LocalLeader>b{ :WrapSelection '\left{', '\right}', 'end'<CR>
17713 < And the maps to put the selected text into an environment: >
17714 vmap <LocalLeader>C :WrapSelection '\begin{center}', '\end{center}', '0','1'<CR>
17715 vmap <LocalLeader>R :WrapSelection '\begin{flushright}', '\end{flushright}', '0','1'<CR>
17716 vmap <LocalLeader>L :WrapSelection '\begin{flushleft}', '\end{flushleft}', '0','1'<CR>
17717 < (note that the arguments for this command must be put in ':' or ":")
17718 the highlighted text will put inside \textbf{ }.
17720 You can also use a wrapper which was yanked into register 'a': >
17722 < This will work not only in visual mode. It will operate on last
17723 selected text. So if you accidentally lost the selection you can still
17724 use this command (but not the maps)!
17729 This is a wraper around Align command of the great AutoAlign vim plugin:
17730 http://www.vim.org/scripts/script.php?script_id=884.
17731 This command sets correct align options and aligns the environment.
17732 The following LaTeX environments are supported: >
17733 equation, align, alignat, flalign, displaymath and tabular
17734 < Equation, align, alignat, flalign and displaymath are checked using
17735 syntax, tabular environment is checked using searchpair() function,
17736 the g:atp_completion_limits[2] applies.
17740 Shows Table of Contents of your document. It do not yet support the
17741 started version of chapter, section,... environments.
17743 The optional argument bang controls if the table of contents data base
17744 must be generated: by default map \t doesn't regenerate the toc data
17745 base (unless if it doesn't exist), :TOC command regenerate the
17746 data base, :TOC! ]ot.
17748 See |atp-toc-window| for commands and maps defined in the toc window.
17750 TOC() supports many edited files. For example if you have in your
17751 buffer list two files a.tex and b.tex this command will produce table
17752 of contents of both of them. If you have just one opened window
17753 (excluding the ToC window) then pressing <space>, <enter>, p and q
17754 will take you to the right buffer (which will be read if is unloaded
17755 or hidden). If you split a window then <space>, <enter>,
17756 p, q will take you to the window from which you are coming. However,
17757 if you have two windows with two different buffers loaded they will
17758 act on the window with the matching buffer name.
17760 The variable t:toc_window_width sets the width of table of contents
17761 window. By default t:toc_window_width=30. You can set a global
17762 variable g:toc_window_width to override the default value.
17766 This function returns the name of the currently edited chapter/
17767 section/subsection/subsubsection. Use ':echo CTOC()' or just ':CTOC' to
17768 see the returned value. If you added a section unit the function will
17769 not update the database, run ':TOC' to do that (map \t).
17771 :Labels[!] *atp-:Labels*
17773 Shows labels defined in your file. You can also use the commands and
17774 mappings described in |atp-toc-window|.
17776 If you forget what are these mappings, write ':map <buffer>' in the
17777 TOC or LABELS window, or move to the end of the LABELS window to see
17778 a short help message.
17780 The key 's' shows the context of the label under the cursor (your
17781 current window splits).
17783 The variable t:labels_window_width sets the width of labels window. By
17784 default t:labels_window_width=30. You can set a global
17785 variable g:labels_window_width to override the default value.
17787 Without bang "!" the labels data base will not be generated.
17788 Difference of \t and \L is that \L regenerates the database (whichc is
17791 *atp-:NEnv* *atp-}e*
17792 :NEnv {environment}
17794 Move to next environment, for example ':NEnv definition'. Completion
17795 is set, which finds environments defined in current tex source file.
17796 This function omits environments in comment lines.
17798 If g:atp_mapNn is set to one (see |atp-:ToggleNn|) then this command
17801 *atp-:PEnv* *atp-{e*
17802 :PEnv {environment}
17804 Move to previous environment, for example ':NEnv definition'. Completion
17805 is set, which finds environments defined in current tex source file.
17806 This function omits environments in comment lines.
17808 If g:atp_mapNn is set to one (see |atp-:ToggleNn|) then this command
17812 *atp-:NPart* *atp-}p*
17813 *atp-:NChap* *atp-}c*
17814 *atp-:NSec* *atp-}s*
17815 *atp-:NSSec* *atp-}S*
17817 :NPart[!], :NChap[!], :NSec[!], :NSSec[!], :NSSSec[!] [title_pattern]
17818 map }p, map }c, map }s, map }S
17819 vmap }p, vmap }c, vmap }s, vmap }S
17821 Go to next part/chapter/section/subsection/subsubsection which title
17822 matches optionally given [title_pattern]. With bang "!" the command
17823 doesn't skip commented sections. Maps skip them. The search will wrap
17824 around the end of a file if 'wrapscan' is set.
17826 Map Command Meaning
17827 }p :NPart go to next part
17828 }c :NChap go to next chapter
17829 }s :NSec go to next section
17830 }S :NSSec go to next subsection
17832 The leader } can be changed by setting the variable
17833 *g:atp_map_forward_motion_leader* .
17835 Note: the maps work in visual mode and operator pending mode ('d\ns'
17836 will delete till the end of the section). You can use |n| and |N| vim
17837 normal commands (also in visual mode) to go further.
17839 In visual mode these maps go to end of current section or, if already
17840 at the end of section, end of next section.
17842 [title_pattern] is the pattern which will match for the pattern, it
17843 should start with '.*' when you want to match somewhere in a midle of
17846 These commands (and maps) use vim |search()| function or |atp-:S| command
17847 depending on the value of |g:atp_mapNn| (see |atp-:ToggleNn|, when
17848 g:atp_mapNn=1 the |atp-:S| command is used). You can set the value
17849 of |g:atp_mapNn| using the command |atp-:ToggleNn|. If 'wrapscan' is
17850 set and g:atp_mapNn=1 the search will wrap around the end of the project (not the end of
17851 the current buffer).
17853 You can unmap these keys and use <Plug>GotoNextSubSection,
17854 <Plug>GotoNextSection, <Plug>GotoNextChapter, <Plug>GotoNextPart to
17858 *atp-:PPart* *atp-{p*
17859 *atp-:PChap* *atp-{c*
17860 *atp-:PSec* *atp-{s*
17861 *atp-:PSSec* *atp-{S*
17863 :PPart[!], :PChap[!], :PSec[!], :PSSec[!], :PSSSec[!] [title_pattern]
17864 map {p, map {c, map {s, map {S
17865 vmap {p, vmap {c, vmap {s, vmap {S
17867 Go to previous part/chapter/section/subsection/subsubsection which
17868 title matches [title_pattern] (an optional argument). With bang "!"
17869 the command doesn't skip commented sections. Maps skip them. The
17870 search will wrap around the begining of a file if 'wrapscan' is set.
17872 The leader { can be changed by setting the variable
17873 *g:atp_map_backward_motion_leader* .
17875 For descirption of arguments read |atp-:NextSection| just above.
17877 Map Command Meaning
17878 {p :PPart go to previous part
17879 {c :PChap go to previous chapter
17880 {s :PSec go to previous section
17881 {S :PSSec go to previous subsection
17883 These commands (and maps) use vim |search()| function or |atp-:S|
17884 command depending on the value of |g:atp_mapNn| (see |atp-:ToggleNn|,
17885 when g:atp_mapNn=1 the |atp-:S| command is used). If 'wrapscan' is
17886 set and g:atp_mapNn=1 the search will wrap around the beginning of
17887 the project (not the beginning of the current buffer).
17889 You can unmap these keys and use <Plug>GotoPreviousSubSection,
17890 <Plug>GotoPreviousSection, <Plug>GotoPreviousChapter,
17891 <Plug>GotoPreviousPart to define new maps.
17893 ToDo({keyword}, {stop}, [bufname]) *atp-function-ToDo*
17894 :ToDo [bufname] *atp-:ToDo*
17895 :Note [bufname] *atp-:Note*
17896 The function list all the lines of the buffer [bufname] which match
17897 for the pattern '%.*{keyword}'. The {stop} argument is the pattern to
17898 before which to stop. The optional argument is the buffer
17899 name (the buffer name completion is set on). If not given the
17900 current buffer is assumed.
17901 You can set highlighting for this command by:
17902 highlight atp-Todo ctermfg=... guifg=...
17903 The command :ToDo sets keyword='\c\<todo\>' and
17904 stop='\s*%.*\c\<note\>', and the command :Note sets
17905 keyword='\c\<note\>' and stop='\s*%.*\c\<todo\>'. This prevent from
17906 listing ToDo lines with Notes and vice versa.
17908 :ToggleSpace, map <F2> *atp-:ToggleSpace*
17909 This function (command) sets, if it is undefined or removes if it is
17910 defined, the mapping:
17912 :cmap <Space> \_s\+
17914 which is useful when searching by the command '/', especially if
17915 |'textwidth'| or |'wrapmargin'| is non zero (and |'formatoptions'|
17916 contains one of the flags 't', 'v' or 'b'). Then each <Space> will
17917 match for a space or end of line.
17920 :ToggleStar adds/removes a star from the current
17921 map <LocalLeader>s environment (if it is not one belonging
17923 g:atp_no_star_environments
17925 *atp-:ToggleEnvironment*
17926 :ToggleEnv mapped to <F4> and <S-F4>, switches environment
17927 map <S-F4> name. See (i.e. echo ) g:atp_toggle_environments_1...7
17928 (you can change or add your own variables,
17929 just add numbers - they must be consecutive).
17931 Read |g:atp_toggle_labels| below how it handles the
17932 prefixes of labels.
17934 *atp-:ChangeEnvironment*
17935 :ChangeEnv This does the same as the above command but asks for
17936 map <F4> environment name
17938 Read |g:atp_toggle_labels| below how it handles the
17939 prefixes of labels.
17941 *g:atp_toggle_labels*
17942 The commands |atp-:ToggleEnvironment| and |atp-:ChangeEnvironment|
17943 changes the prefixes of labels (if there is one, which belongs to
17944 g:atp_shortnames_dict) and all ref's (\ref, \eqref and \pageref). You
17945 have to turn on this feature by putting g:atp_toggle_labels=1 (by
17946 default it is 0). Check if it works for you! If there is a label or
17947 reference to which it wants to change it doesn't change labels and
17948 issue a Warning Message, thus I believe it should work for every one,
17949 but as this changes your file it is turned off by default.)
17951 In project files this is done in all files belonging to the project.
17952 Changes are not saved by deafualt (ATP uses |'hidden'| option, so when
17953 you use q! or qa! all changes will be lost).
17955 :SetOutDir *atp-:SetOutDir*
17956 This is a command which sets the |b:atp_OutDir| variable and the
17957 |'errorfile'| option. See |b:atp_OutDir| for the default value.
17959 :SetErrorFile *atp-:SetErrorFile*
17960 If you change |b:atp_OutDir| variable and you want to update the
17961 |'errorfile'| option use this command. It will show you the value to
17962 which |'errorfile'| was set.
17964 :Status[!] *atp-:ATPStatus*
17965 This function (command) sets the status line, which include: the name
17966 of currently eddited chapter (or section) the value of
17967 |b:atp_OutDir| (unless used with bang!) and it will warn you if
17968 |b:atp_OutDir| variable is not set. This function is called at startup
17969 unless the variable 'g:atp_statusline=0' is set. The status is set by
17971 au BufWinEnter *.tex :call Status()
17972 < In this way every opened window with a '*.tex' file will get the correct
17976 :FontSearch[!] [pattern] *atp-:FontSearch*
17980 will list all the fd files in your tex distribution which
17981 names starts with t1 (i.e. which describes fonts in encoding
17983 :FontSearch! bookman
17984 will list all fd files which full path matches 'bookman'.
17986 In the opened window there are several mappings defined:
17987 <Enter> open the fd file under the cursor
17988 <Tab> list fonts defined in the fd file (shows the command
17989 that you can use in your tex file to use this font)
17990 p preview the fonts defined in the fd file under the
17991 cursor, do not shows the latex source.
17992 P preview fonts and show the latex source
17993 (then you can see the errors why the preview was not
17994 produced; in many cases there are no encoding files or
17995 fonts themselves for which you have to look in CTAN
17996 archive yourself; or YOU CAN just SEE HOW TO USE
17998 q close the window (actually, delete the buffer using
17999 :bd, it will be still in the list if you type ":ls!",
18000 so even then you can reload previous searches.)
18002 In addition to 'p' and 'P' maps there is a :Preview command.
18003 Note: the maps 'p' and 'P' work in both normal and visual mode.
18004 You can select a part of the text and use this maps or the command
18005 :Preview to make one preview file for all the font files.
18008 The same mappings are defined in the window with fd file opened
18009 (except <Enter>, <Tab>).
18011 Additionally, read |font-lowlevelcommands| to learn how to use
18012 |\usefont|, |\fontsize|, |\selectfont| and other such commands.
18013 The 'Latex 2e font selection' by 'LeTeX3 Project Team' might be very
18014 useful. It is available on the net (you probably have it in your tex
18015 distribution if it is installed with the documentation, if not check
18018 ATP also has a very nice completion for various font declaration
18019 commands, see |atp-completion-fontdeclaration|.
18021 Hopefully, this will help your documents to become beautiful :)
18024 :FontPreview[!] {fdFile} [encoding] [keep_tex]
18025 Previews all fonts defined in fd file matching the pattern <fd_file>
18026 with encoding [encoding] (optional). If [keep_tex] is 1 (defualt is 0)
18027 it will keep the latex source file for debugging purposes.
18029 Without [!] it matches just the name of the fd files, with [!] the
18030 pattern {fdFile} matches for full path.
18032 It returns a list of fonts which fd files matches the {fdFile} pattern in
18033 [encoding]. You will be asked to chose for which files make a preview,
18034 possible answers are: >
18036 < which is equivalent to >
18038 < you can also mix this notation: >
18040 < As in FontSearch command the [keep_tex] variable specifies if
18041 the source file will be shown (for debugging purposes, or just to look how
18042 to use the font :).
18044 *atp-:HelpEnvIMaps*
18045 *atp-:HelpMathIMaps*
18050 These commands list valid mappings defined by ATP (unless g:no_plugin_maps or
18051 g:no_atp_maps are defined).
18054 Prints PIDs of all running instances of |b:atp_TexComopiler|.
18056 ================================================================================
18057 TABLE OF CONTENTS WINDOW *atp-toc-window*
18059 For the table of contents command and maps read |atp-:TOC|.
18061 The Table of Contents window is used by both |atp-:TOC| and |atp-:Labels|
18064 In the Table of Contents window there are the following nmaps:
18066 'e' to echo the line from your tex file
18067 'y' or 'c' to yank the label of the chapter under the cursor
18068 to a register, if it exists,
18069 'p' to paste it directly to your tex file (just after the
18070 current cursor position),
18071 's' it splits the window with your tex source file and
18072 sets the current line to the beginning of the
18073 chapter/section under the cursor,
18074 'q' to quit, and finaly,
18075 <Enter> to go to the chapter under the cursor and close ToC.
18076 <space> to go to the chapter under the cursor but leave ToC
18079 There are also commands: ':C' and ':P', which do the same as 'c' and
18080 'p' mappings. They all call the function 'Yank(<where>)', the argument
18081 <where> can be one of: '@<register name>' or 'p'.
18083 You can also delete and paste sections using the Table of Contents
18085 *atp-:DeleteSection*
18086 *atp-:PasteSection*
18087 *atp-:SectionStack*
18092 < Using ':DeleteSection' you can delete the section under cursor together
18093 with all its subsections. /Section can be one of: part, chapter,
18094 section, subsection, subsubsection, or bibliography/. Deleted section
18095 will be added to a stack which can be shown using the command
18096 ':SectionStack' There is a command to paste the section from section
18097 stack ':PasteSection'. By default it pastes the most recent element in
18098 the stack. Passing a number will paste that element of the stack
18099 /bear in mind that then numbers of sections in the stack will change/.
18101 ':PasteSection' puts the section just after where current section
18102 ends (section under the cursor in the ToC buffer).
18104 Note: If you use bibtex commands to make bibliography ATP finds the
18105 line which contains '\bibliography' command. And then searches
18106 backward for the first line which is a blank line. The next line is
18107 assumed to be the first line of bibliography. Thus to move the last
18108 section before bibliography or the bibliography itself its better you
18109 put a blank line before bibliography commands. The same applies for
18110 bibliographies put in the middle of document (end of a chapter, part,
18111 etc.) The end of bibliography is found in the same way as the end of
18112 subsubsection. If you use
18113 \begin{thebibliography}:\end{thebibliography} there is no such
18116 If you want to paste a section before the first section, use the line
18117 with the file name.
18121 nnoremap u, nnoremap U, nnoremap g-, nnoremap g+
18122 < You can use undo. The :Undo command will undo in the buffer under
18123 the cursor (it simly switches to the correct window, usese the vim
18124 undo function, and runs :TOC command - so after all your back in
18125 ToC.). The ':Undo' command has one argument - the vim undo command to
18126 use, it is one of: 'u/U/g-/g+' (the default is 'u'). They are mapped
18127 to 'u','U', 'g-' and 'g+'. (only in the ToC buffer). Note: ':Undo'
18128 command doesn't changes the Section Stack.
18130 There is one more level of security: There is a global variable which
18131 stores all the deleted sections together with some information about
18133 g:atp_SectionBackup
18134 < it is a vim list (see |List|). Each entry is a list of the following format: >
18135 [ <title>, <type>, <deleted_section>, <section_nr>, <file> ]
18136 < where <title> is the section title, <type> is one of: part, chapter,
18137 section, subsection, subsubsection bibliography or abstract. Deleted
18138 section is a list of deleted lines, <section_nr> is the number of the
18139 section that it had before deletetion, <file> is the full path to the
18140 file which it comes from. If you need to use it, you can use the vim
18141 function |append()| to put the <deleted_section> in the right place.
18144 You may want to have a map: >
18145 :au FileType toc_atp nnoremap dd :DeleteSection<CR>
18146 < this can be put in your '$HOME/.atp.vim' configuration file.
18147 ================================================================================
18148 SEARCHING IN BIB FILES *atp-bibsearch*
18150 ___________________________
18155 |atp-bibflags:default|
18156 |atp-bibsearch-show-only-keys|
18158 |atp-bibflags:output|
18160 |atp-bibflags:last|
18161 |atp-bibflags:add-flag|
18163 |atp-bibsearch-highlight|
18165 |atp-bibflags:examples|
18166 |atp-bibsearch-variables|
18169 ____________________________
18170 Naming Conventions:
18172 @article{<label>, \
18173 author = { .... }, <-- bib entry |
18174 title = { .... }, > bib field
18175 journal= " .... ", |
18178 article <-- bib field keyword
18179 author,title,... <-- bib entry label
18180 <label> <-- bib field label
18183 One more function is provided which searches the bib files for bib fields,
18184 and for the bib field labels for the latex command \cite{}.
18186 BibSearch({bang}, [pattern], [flags]) *atp-BibSearch*
18187 The function BibSearch allows you to search for the [pattern] in bib
18188 files and opens a new window with results. For the command, please read
18191 {bang} has two possible values "!" or "", with "!" it looks first for
18192 input files, while if {bang}="" only if ATP has not done it yet.
18194 The function BibSearch takes two arguments (the last one is optional).
18195 The first one is the [pattern] to match against each line of the
18196 bibliographic files supplied in the commands \bibliography (if there
18197 are several names,please do not add a white space ' ' after ',' unless
18198 the file name begins with a space, i.e.
18200 \bibliography(Mathematics, Physics,/home/user/Bibliography)
18202 then the plugin will understand that the names of the bib files are
18203 'Mathematics.bib', ' Physics.bib' and '/home/user/Bibliography.bib'.
18207 Before the match all the ligature symbols and {:} are removed. For
18208 example \`a, \' e, \oa,\ea are substituted with a, e, oa, ea
18209 (respectively). Note that the space in \' e is also removed. Each
18210 line (without ligatures) of every bib file found in your tex document
18211 will be matched against the pattern, for example if the pattern is:
18213 'author.*Grothendieck'
18215 the BibSearch function will find all the bibliographic fields
18216 which in one line have the words 'author' and 'Grothendieck' (in most
18217 cases it means that you will see only works of Grothendieck). Another
18220 '^\(\s*author.*Joayl\)\|Galois Theory'
18222 will result in all bib fields which author is Joyal or
18223 which includes the words 'Galois Theory' (which by the way apear in
18224 many article/book titles), yet another example:
18226 'author.*Joayl\|title\p*Galois Theory'
18228 This will match against all bib entries written by Joyal or which title
18229 includes the word 'Galois Theory'.
18231 :call BibSearch('author.*Joyal\&.*Tirney')
18233 will find all the bib entries which were written by Joyal and Tirney
18234 (and maybe somebody else).
18236 For now, there is no possibility to filter bibliographic entries which
18237 both match a pattern in separate lines, i.g. to show all bib entries
18238 written by Joyal on 'Descent Theory'.
18240 Before a match, all '{', and '}' are deleted from the line of the bib file.
18241 But you will see them in the output (what can be useful for debugging
18242 errors in bib files)
18244 Note that in Vim patterns should be quoted using '...' not "...".
18246 Further examples are supplied after the next section
18247 |atp-bibflags:examples|, which describes other functionalities of the
18248 BibSearch/BibChoose commands.
18250 *atp-bibpattern:last*
18251 *atp-bib-b:atp_LastBibPattern*
18252 The variable 'b:atp_LastBibPattern' stores the last pattern used by
18256 The first optional argument [flags] chooses what and in which order
18257 you want to see the bib entries found (entries are listed in
18258 the order they appear in bib file). Flag is a word made of letters.
18259 There are three kinds of flags: entry flags which matches against
18260 labels of bib entries, like author, title, etc..., and keyword flags: which
18261 matches against keywords of bib fields: @article, @book, @techreport,
18262 etc... and two special flags 'All' and 'L'. A flag is a word on
18282 any other letter - do not show anything but the first line of bib entry
18283 @a - article /@article/
18284 @b - book or booklet /@book,@booklet/
18285 @B - Booklet /@booklet/
18286 @c - incollection /@incollection,@inbook/
18287 @p - proceedings, inproceedings, conference /@proceedings,@inproceedings,@conference/
18289 @M - Manual /@manual/
18290 @t - master or PhD thesis /@masterthesis,@phdthesis/
18291 @T - Techreport /@techreport/
18292 @u - unpublished /@unpublished/
18293 All - all flags (see |atp-bibflags:all|)
18294 L - last flags (see |atp-bibflags:last|)
18298 tayu@a --> show the entries: tile, author, year, url of matching articles.
18299 baeP@b --> show the entries: booktitle, author, editor,
18300 publisher of matching books (@book,@booklet).
18302 Flags '@.' are filtered out, if one does not belong to the one above
18303 then it is deleted. You can see which flags are defined using
18304 ShowOptions function/command (they are listed as Available
18306 *atp-bibflags:default*
18307 The default flag is stored in the global variable g:defaultbibflags and is
18308 equal to 'tabejsyu'. This means that the output for each bib field found
18317 if title,author,... are specified in the bibliography for the given
18318 position. If there are many position which match you can set flags to
18319 be as simple as possible to include more lines on the screen. For
18320 example 'tabe' is quite reasonable (note that all bib entries are
18321 matched separately, i.e. if a bib field has both 'title' and 'booktitle'
18322 bib entries it will give you both of them.
18324 *atp-bibsearch-show-only-keys*
18325 If you just want to list just the lines with bib fields keywords:
18326 @article{, @book{, etc. supply a flag which do not belongs to
18327 'g:defaultallbibflags', for example 'X', or 'X@a'
18330 You can also specify flags with '+', for example:
18335 This feature ADDS FLAGS TO THE DEFAULT VALUE defined in the variable
18336 g:defaultbibflags (see |atp-defaulbibflags|). The first will result in
18337 showing the default entries and the page number, the second will
18338 result in showing only books with the default bib entries. You can
18339 specify as many additional flags as you wish. *atp-bibflags:output*
18340 Note that the function shows the line with database file name if there
18341 are entries in this bibliography which match the pattern thus,for
18342 example, if you specify the flag '@a' and you see the line with
18343 database file name, but you do not see any bib entry, then in this
18344 database there are bib fields which match but these are not articles.
18347 The flags='All' is a synonim of flag=g:defaultallbibflags which by default is
18348 equal to'tabejfsvnyPNSohiuHcp' i.e. all flags in this order. If you
18349 add your own flag you should change this global variable. You can add to
18350 this flag any flag which contains '@' (see |atp-bibflags|) by
18351 the plus operator, i.e. All+@a@b or +@aAll will give the same result.
18353 *atp-bibflags:last*
18354 *atp-bib-b:atp_LastBibFlags*
18355 The variable 'b:atp_LastBibFlags' stores the recently used flags. The flag
18356 'L' sets the flags for this search to the value of 'b:atp_LastBibFlags'.
18357 You can write '+L@a', '+L@a', 'L@a' or '@aL' but not '+@La', if you
18358 want to add some flags to previous searches. Next time the flag 'L'
18359 will change the meaning (i.e. it is really the last time not earlier
18360 :) However, there is no '-' :( '-@aL' could be helpful.
18362 The variable 'b:atp_LastBibFlags' is not changed when you use the 'All'
18365 *atp-bibflags:add-flag*
18366 You can add your own flags but not keyword flags (i.e. @a,@b,...).
18367 Just add an entry to the dictionary g:bibflagsdict. (:ShowOptions v to
18368 see its current value), For example
18370 let g:bibflagsdict=extend(g:bibflagsdict,
18371 \ { '<flags_name>' : [ '<bib_entry_name>': '<how_to_show>'] })
18373 where, <flags_name> is the flag to use (it should be one letter), it
18374 must be different from the defined flags, <bib_entry_name> is a
18375 lower case bib entry name, like 'title', 'url', etc., <how_to_show> if
18376 you want to have a nice output put the bib entry name and that much of
18377 white spaces to get 13 strings.
18379 :BibChoose {BibEntry[RegisterName]} *atp-:BibChoose*
18380 map c, map y, map p
18381 This function/command is only available in the window with BibSearch results
18382 and allows to copy a bib entry key to a register or directly to the
18383 last opened buffer (after the cursor position). It is mapped to 'c'
18384 and 'y'. You will be asked to give the number of bib entry to yank:
18386 <bib entry number><register name><Enter> - to copy it to a register
18387 <bib entry number><Enter> - to paste it to 'tex' file
18388 <Enter> - to skip the choice
18390 When you paste the bib entry key the bib search window will close. For
18395 < Copy the bibkey to register e,+ or paste directly to the buffer
18396 in which :BibSearch was invoked, at last cursor position.
18398 The same you will obtain using tha nmaps y or c.
18400 This commands and maps are only in the BibSearch buffer.
18402 *atp-bibsearch-highlight*
18403 The colours of the output are set by the syntax file
18404 'syntax/bibsearch_atp.Vim'. All groups except one are the same as in
18405 the syntax file for bib files ('syntax/bib.Vim' in your $VIMRUNTIME
18406 directory). Their names are 'bibsearchEntryKw' instead 'bibEntryKw'.
18407 The one that is differently defined 'bibsearchComment'. Which is
18408 changed in that way to highlight the bib file names. One additional
18409 highlight group is: 'bibsearchInfo'. It highlights the number of
18410 entry and its line number in the bib file. By default all bibsearch
18411 groups are linked to the corresponding bib group, the bibsearchInfo
18414 In a colour file (~/.Vim/color/*.Vim) you can use these groups to set
18415 colours. See |highlight| or just read a colour file. For example,
18416 this is a nice set of colours for dark background
18419 :BibSearch /{pattern}/ [flag] *atp-:BibSearch*
18420 which do what you expect. The arguments should not be quoted and
18421 separated by a white spaces (if you want to include a white space use
18422 '\ '), for more see |f-args|. If you do not provide any argument then
18423 all entries of all bib files will be shown. Examples:
18425 Some examples: *atp-bibflags:examples*
18428 < Above command shows all bib fields with
18432 < and this is a tip how to show all bib fields with
18433 different flags than the default ones(the '@'
18434 will match at every bib field!). It is
18437 :call BibSearch('','yt')
18439 :BibSearch title[\s.]*Galois Theory aetb
18441 The next one shows all bib fields which were written by Joyal and
18442 Tirney (and may by somebody else).
18444 :BibSearch 'author.*Joyal\&.*Tirney'
18447 :DefiSearch[!] [pattern] *atp-:DefiSearch*
18448 The [pattern] argument is optional. Finds all definitions which
18449 matches the pattern. It looks in the main file (only in the preambule,
18450 unless the optional bang '!' is used) and all the input files (except
18453 The pattern is any vim pattern.
18455 It works likes ]d but handles muliti line definitions.
18457 *atp-bibsearch-variables*
18458 *atp-variables-bib*
18460 All the values of important variables can be shown by ShowOption
18466 < This variable is a list and you can put here additional bib files.
18467 They will be parsed by the BibSearch/BibChoose functions.
18469 The following variables you can see using the ShowOptions command (see
18470 |atp-ShowOptions|). >
18472 < This variable is a list which stores bib files found in your tex
18473 files and which are readable. It is set up when you first run of the commands:
18474 BibSearch/BibChoose/ShowOptions. Its value is shown by the
18475 functions FindBibFiles({bufname}). >
18477 < this is a sum of found bib files the locally defined b:bibfiles, which
18478 not necessarily are readable. >
18479 s:notreadablebibfiles
18483 -----------------------------------------------------------------------------------
18484 *atp-bibsearch-comments*
18485 Please do not hesitate to report any bug to me:
18488 The algorithm will work only if all kind of bib entries of your bib
18489 file are included in the list g:bibentries. However, changing just
18490 this variable is not enough. In that case the search engine (function
18491 s:search) will produce correct output, but the function which displays
18492 found entries, will not know how to work with the new entries. One
18493 would have to add an entry to the dictionary 'g:bibflagsdict'. If
18494 it is the case, please let me know: mszamot [AT] gmail [DOT] com
18496 As you can see entries of the type '@string' which can be used in bib
18497 files are not supported (i.e. there is no function which substitutes
18498 the variables defined in @string to their values), but it is doable.
18499 @string{ Name = Value }
18502 ================================================================================
18503 COMPLETION *atp-completion*
18505 The completion is by default mapped to <Tab>. For example if you type
18506 \math<Tab> you will get a list of choices which completes this command. (See
18507 ':h popupmenu-completion' and ':h completion' for more).
18509 *atp-completion-expert-mode*
18510 *atp-completion-non-expert-mode*
18511 There are two completion algorithm: expert mode and non expert mode: the
18512 keyword for completion in expert mode must match at the beginning, in non
18513 expert mode any where. Also in expert mode the list of possible completions is
18514 smaler (for example there is no '\lneqq', there is only '\lneq').
18516 Note: Non expert mode doesn't check if you are editing math (see
18517 |g:atp_MathOpened|), and is useful when you want to complete a non-math
18518 command inside mathematics.
18521 If you prefer to not map <Tab> key then you can define g:atp_no_tab_map=1 in
18522 your vimrc file or atprc file |atprc|. Note that vim can add/remove
18523 tabshift witdth from the begining of line in other ways: in normal mode with
18524 |>>| and |<<|, in insert mode: |i_CTRL-T|, |i_CTRL-D| and in visual mode with
18525 |>| and |<|. Also you can use |atp-g>| and |atp-g<|. The alignment of tabular
18526 and other environemnts can be done with |atp-:TexAlign| command.
18528 You can switch off/on completion modes adjusting the variable
18529 'g:atp_completion_active_modes', all names of completion modes are stored in
18530 the variable 'g:atp_tab_completion_modes'.
18532 If 'g:atp_local_completion' is set to non zero value, then input files
18533 will be scanned for \def, \newcommand, \newnevironment and \newtheorem
18534 commands and they will be used for completion. (if its value is 1 then this
18535 will be done during first completion - this is the default, if it is set to
18536 2 then this will be done at start up.
18538 NOTE: if you press <Tab> but then you changed your mind, the
18539 completion pop-up menu allows to cancel completion: press ctrl+p (i.e.
18540 go up - some times more than once) and then press <space>.
18542 Note: Completion checks the preambule for definitions of LaTeX packages. If
18543 a supported package is present (for example: tikz) then the complation will
18544 contain additional commands. If you add a package or a class you should unlet
18545 correponding variable: |g:atp_latexpackages| and |g:atp_latexclasses|.
18550 It is a command to toggle the tab map off/on: :ToggleTab, it is also mapped
18553 Note: see |atp-Tab-note|.
18556 COMPLETION MODES *atp-completion-modes*
18558 commands *atp-completion-commands*
18559 if g:atp_check_if_math_mode = 1 then the pull of commands
18560 contains math commands only if there you are inside a math
18561 environment. This works perfectly if you switch from $:$ and
18562 $$:$$ to their equivalent (and more up-to-date) \(:\) and \[:\].
18563 The list of math environment in which ATP will think you are
18564 editing a math mode is stored in the variable:
18565 'g:atp_math_modes'. Its entries are two element list of
18566 patterns which matches the beginning and end of a math mode.
18567 The '0' entry have to provide the beginning and end pattern of
18568 in line math '\(:\)', the second for displayed math '\[:\]'.
18569 Its default value is given below.
18571 If you add a package (like tikz or amsmath, or amssymb) then
18572 the set of completions will contain extra commands/environment
18573 names defined in these packages Because some classes calls
18574 amsmath package silently setting the variable
18575 'g:atp_amsmath=1' will ensure that you will get completions
18576 for these commands. The algorithm checks if you have this
18577 package declared or if you use some of the standard ams
18578 class (actually checks if the document class name matches
18581 If you do not want math commands completions at all define
18582 ':let g:atp_no_math_command_completion=1' (you can put it in
18583 your |vimrc| or |atprc| file, or define while writing,
18584 both will work, so you can switch off the math completions
18587 The label command completes in a special way: for example in
18589 \begin{theorem}\lab<Tab>
18591 \begin{theorem}\label{thm:
18592 The dictionary of short names is 'g:atp_shortname_dict'. If
18593 you do not likes this idea (however it can help you to
18594 correctly write \ref{ - to avoid referring to lemmas as
18595 propositions, and also it makes completion for \ref{ nicer
18596 - you can list only labels for theorems), so if you do not
18597 want it anyway: 'let g:atp_no_short_names=1' will make the
18601 *atp-variables-local_completion*
18602 *b:atp_LocalCommands*
18603 *g:atp_LocalCommands*
18604 *b:atp_LocalEnvironments*
18605 *g:atp_LocalEnvironments*
18606 By default the first time you are completing an environment
18607 name or a command a list of locally defined environments and
18608 commands is made (it takes a few seconds). If you do not want
18609 to completions for them define "let g:atp_local_completion=0",
18610 if g:atp_local_completion=2" then the search for local
18611 definitions and commands will be done on startup. If you
18612 added a command or an environment the command
18613 :LocalCommands! will update the list of local definitions, but
18614 also the list of packages used by your latex source file
18615 ( completion lists are only used by Tab Completion function if
18616 the package was given, thus it is necessary to run this
18617 command if the preambule has changed)
18618 The output is stored in two variables: >
18619 b:atp_local_commands
18620 b:atp_local_environments
18622 If you use the same set of definitions in every tex file
18624 g:atp_local_commands
18625 g:atp_local_environments
18627 which if defined are used instead of b:atp_local_commands and
18628 b:atp_local_environments (use the command :LocalCommands
18629 to generate the list and then use the command:
18630 :let @a= b:atp_local_commands
18631 i.e. copy the variable to register a and paste it in your Vimrc file.)
18633 There is an extended support for tikz picture environment both
18634 inline \tikz{:} and displayed
18635 \begin{tikzpicture}:\end{tikzpicture}. The completion works
18636 for commands and keywords. The pull of them is enlarged if you
18637 add a tikz library. Yet not all the libraries are
18638 supported but this is just the matter of my time. Normal
18639 commands are added if you are inside {:}.
18642 ref/label/cite *atp-completion-ref*
18643 *atp-completion-label*
18644 *atp-completion-cite*
18645 Tab Completion for Labels
18647 For label completion puts short names, for ref and eqref
18648 commands the completions are the labels found in all files
18649 associated to the main file (the plugin searches the input
18650 and include files for them). The same for cite: which searches
18651 also in bib files defined in the main file.
18653 There is also omnicompletion (CTRL-X CTRL-O, see
18654 |i_CTRL-X_CTRL-O|) for \cite command. Check it out, as it is
18655 very nice (especially in gvim!) and very fast.
18657 For both completion and omnicompletion for the cite command,
18658 the text after \cite{ [ or after a comma after \cite{ ] is
18659 treated as a regular expression. Thus you can wirte:
18661 \cite{.*author1\&.*author2<Tab>
18663 to get the completions for things written by both author 1 and
18664 2 (regardless of the order they appear in bib files).
18666 BibTeX omni completion is triggered by '\cite{', '\citep{' or '\citet{'.
18667 For example, assume you have in your .bib files an entry looking like: >
18670 author = "Donald E. Knuth",
18671 title = "Seminumerical Algorithms",
18672 publisher = "Addison-Wesley",
18677 \cite{Knuth 1981<CTRL-X><CTRL-O>
18678 \cite{algo<CTRL-X><CTRL-O>
18681 \ref{{pattern}<Tab> matches the label name for the {pattern}.
18682 When pattern is matched for a number of a label '^' is added in
18683 front of the pattern (see below). In this case both completion modes:
18684 expert and non-expert works in the same way.
18686 You can also use vim patterns after '\cite{'.
18688 < Tab Completion for labels (|atp-completion|) allows to specify
18689 the number of the counter, e.g. >
18691 < will complete into the label of the counter with value '3.1'.
18692 As for now you can not specify which counter to complete. You
18693 can also write '\ref{3.1$' then '^3.1$' is used as a pattern!
18695 For this two work the aux file must be present. As for now
18696 the aux file, if it is not present, is not made.
18698 This is working with the main document classes: article, book,
18699 review, amsart, amsbook, memoir. If for some class it is not
18700 working thanks for reporting me (it's enough to email me just
18701 the document class).
18703 brackets *atp-completion-brackets*
18704 Closing of brackets {:},{:},[:],(:) (also closes math modes \(:\) and
18706 Relelvant variables are: g:atp_bracket_dict a dictionary of
18707 brackets by default it consists of pairs '(' : ')', '{' : '}',
18708 '[' : ']'. There is a second dictionary g:atp_sizes_of_brackets
18709 which contains all the sizes of brackets in latex plus a pair
18710 '\' : '\', for closing the math modes: \(:\), \[:\] and the
18713 environments *atp-closing-environments*
18714 *atp-completion-env*
18715 Completes after '\begin{' and '\end{'. For example
18716 '\begin{cen<Tab>' will give '\begin{center}'
18717 But '\begin{theorem}<Tab>' or
18718 '\begin{theorem}\label{thm:1}<Tab> will close the environment.
18719 The algorithm tries to close environment in many natural
18720 situations: for example when it did found less than one command
18721 completion. It closes the right environment when they are
18722 nested (however not in right place!) and it preserves the
18723 indention. When after \begin{center}\label{...} XXX is
18724 something (in place of XXX) it will close the environment in
18725 after the cursor position otherwise in next line.
18727 The environments opened in tex definitions ('\def',
18728 '\newcommand', '\renewcommand') will not be closed unless the
18729 current cursor position is in that line (sometimes one might
18730 want to have a definition which only opens an environment).
18734 (the <Tab> indicates in which position the
18735 <Tab> can be pressed to get the described
18750 < Usually the closing comes in the next line,
18751 unless we are inside an environment which is opened
18752 after the non closed environment:
18758 \begin{minipage}<Tab>
18760 \end{minipage}<Tab>
18766 < Then the closing will be put just after the last
18767 opened environment closes, or
18782 < If we are outside the theorem environment,
18783 '\end{enumerate}' will be placed just above
18784 '\end{theorem}', and
18786 \begin{theorem}[Joyal\&Tirney]\label{thm:jt}
18794 \end{enumerate}<Tab>
18796 < will put \end{minipage} just above
18797 \begin{enumerate}. Furthermore, if:
18800 \begin{enumerate}\label{enu:1}
18811 \end{enumerate}<Tab>
18813 < '\end{minipage}' will be put just above
18814 '\end{enumerate}'. Furthermore,
18816 \begin{theorem}[...]\label{...} Let \(C\) be a ....
18820 That is, if you like to write \begin{}:\end{} in the beginning
18821 and end of a line this will be preserved. However, there is no
18822 support for nested environments then!
18824 font declarations *atp-completion-fontdeclaration*
18825 This is completion for the commands
18826 \usefont{<encoding>}{<font_familly>}{<font_series>}{<font_shape>},
18827 \fontencoding{<encoding>},
18828 \fontfamily{<font_family>},
18829 \fontseries{<font_series>},
18830 \fontshape{<font_shape>},
18831 \DeclareFixedFont{<cmd>}{<encoding>}{<font_familly>}{<font_series>}{<font_shape>}{<size>}
18833 It first splits the line and take a part between the commands
18834 \selectfont (if there is not \selectfont command this step is
18837 Then if the <encoding> is declared the font families for the
18838 completion will only come from this <encoding>.
18840 If <font_family> is defined, <font_series> and <font_shape>
18841 come from the particular font definition file (the declared
18842 encoding is used if not the value of
18843 |g:atp_font_encoding| is used).
18845 If <font_family> and <font_series> are defined then the
18846 <font_shape> for this font (in the above encoding) is found.
18850 Completion for the command '\bibliographystyle{'. Finds all
18851 "bst" files avaiable in your tex distribution.
18855 Completion for the command '\documentclass'. Returns list of
18856 all classes available in your distribution.
18858 ------------------------------------------------------------------
18859 ATP COMPLETION VARIABLES *atp-completion-variables*
18861 These are all variables which can help to customise the completion:
18862 (if the value is given it is the default, if it is not means it is too long to
18864 *g:atp_completion_limits*
18866 g:atp_completion_limits = [ '40', '60', '80', '100' ]
18868 The above variable specifies how long should
18869 atp plugin search for closed/unclosed environments:
18870 the first value - search for \(:\) [ in line math ]
18871 the second - search for \[:\] [ displayed math ]
18872 the third - search for \begin{<env>:\end{<env>
18873 the fourth - for environments defined in
18874 the variable g:atp_long_environments
18876 You can also put "-1" as the values of
18877 g:atp_completion_limits, then the search
18878 forward/backward will last till first/last
18879 line. However, this makes it run slower.
18880 *g:atp_long_environments*
18882 g:atp_long_environments = []
18884 If some of your environments are very long put
18885 ther names in this list. Do not forget that is
18886 environment <env> is long and is put inside
18887 environment <center> then <center> is alos
18890 However, this will not close long environments
18891 (for that you have to change the third
18892 argument of g:atp_completion_limits !). This
18893 just prevents closiong environments which are
18894 closed and to long to see that.
18896 g:atp_completion_modes = [
18897 \ 'commands', 'inline_math',
18898 \ 'displayed_math', 'package_names',
18899 \ 'tikz_libraries', 'environment_names',
18900 \ 'close_environments' ,'labels',
18901 \ 'bibitems', 'input_files',
18902 \ 'bibfiles', 'bibstyles',
18903 \ 'documentclass' ]
18905 This is the list of completion modes.
18906 *g:atp_completion_active_modes*
18908 g:atp_completion_active_modes = g:atp_completion_modes
18909 < This is the list of completion modes which are
18910 active, by default all modes are active. Remove
18911 a value from this list to make it inactive (You can
18912 use remove() command, see ':h remove()').
18914 g:atp_sort_completion_list = 12
18915 < If the length of completion list for Tab
18916 Completion is longer than this value, entries
18917 will be sorted alphabetically, else they are
18918 provided in, I hope, useful order. If set to
18919 0 the list will not be sorted (if set to 1 it
18920 will be always sorted). >
18922 g:atp_amsmath_environments
18923 g:atp_shortname_dict
18924 < It is used to defin <short_name> in
18925 \label{<short_name><separator>
18926 when completeing the \label command.
18928 g:atp_separator = ':'
18929 < It is used as a separator in:
18930 \label{<short_name><separator>
18931 when completeing the \label command.
18933 g:atp_no_separator = 0
18934 g:atp_env_short_names = 1
18935 g:atp_no_separator_list = ['', 'titlepage']
18937 g:atp_math_commands
18938 g:atp_ams_negations
18939 g:atp_math_commands_non_expert_mode
18940 g:atp_ams_negations_non_expert_mode
18941 < The two last list of commands will be add only in
18942 the non expert mode (|atp-completion-non-expert-mode|).
18944 g:atp_amsmath_commands
18945 g:atp_fancyhdr_commands
18946 g:atp_tikz_environments
18947 g:atp_tikz_libraries
18948 g:atp_tikz_commands
18949 g:atp_completion_truncate = 4
18950 < do not complete commands less than
18951 4 characters (not counting the leading '\' if
18952 present). If 0 then complete all the defined
18953 commands. This only works in the expert mode.
18957 g:atp_MathOpened = 1
18958 < the default value is 1. With the default value
18959 expert mode completion will check if you are
18960 completing inside mathematical environment or
18961 not. Inside math environment only math
18962 commands are completed and outside math
18963 commands are disabled. This makes the set of
18964 completions more acurate. If you need non math
18965 command (like \textrm{}) inside math use non
18966 expert mode (see |atp-completion-non-expert-mode|)
18970 let g:atp_MathZones = [
18971 \ 'texMathZoneV', 'texMathZoneW',
18972 \ 'texMathZoneX', 'texMathZoneY',
18973 \ 'texMathZoneA', 'texMathZoneAS',
18974 \ 'texMathZoneB', 'texMathZoneBS',
18975 \ 'texMathZoneC', 'texMathZoneCS',
18976 \ 'texMathZoneD', 'texMathZoneDS',
18977 \ 'texMathZoneE', 'texMathZoneES',
18978 \ 'texMathZoneF', 'texMathZoneFS',
18979 \ 'texMathZoneG', 'texMathZoneGS',
18980 \ 'texMathZoneH', 'texMathZoneHS',
18981 \ 'texMathZoneI', 'texMathZoneIS',
18982 \ 'texMathZoneJ', 'texMathZoneJS',
18983 \ 'texMathZoneK', 'texMathZoneKS',
18984 \ 'texMathZoneL', 'texMathZoneLS' ]
18985 < the default value in plaintex files is >
18986 g:atp_MathZones = [ 'plaintexMath' ]
18987 < These are zones recongized by tab completion
18988 as mathematical ones (see |g:atp_MathOpened|).
18992 g:atp_no_complete = ['document']
18993 < List of environments which is not closed by
18994 <tab> completion. (The document environment in longer
18995 documents can be not seen by the algorithm as closed,
18996 because it searches only in a part of the text, see
18997 |g:atp_completion_limits| variable above).
18999 g:atp_bracket_dict = { '(' : ')', '{' : '}', '[' : '] }
19000 g:atp_sizes_of_brackets = {'\left': '\right', '\bigl' : '\bigr',
19001 \ '\Bigl' : '\Bigr', '\biggl' : '\biggr' ,
19002 \ '\Biggl' : '\Biggr', '\' : '\' }
19004 *g:atp_latexpackages*
19005 *g:atp_latexclasses*
19007 g:atp_latexpackages
19009 < stores list of packages and classes in your tex distribution. They are
19010 resored when you exit vim from the common history file (see |atp-history-common|).
19012 They are used for completion of the LaTeX commands \usepackage and
19015 If you reinstall, add or remove tex classes/packages from your tex
19016 distribution it is enough to unlet these variables. ATP will find new
19017 values when it will need them for the first time.
19020 ================================================================================
19021 OMNI-COMPLETION *atp-omnicompletion*
19022 by David Munger (LatexBox plugin)
19024 Completion is achieved through omni completion |compl-omni|, with default
19025 bindings <CTRL-X><CTRL-O>. There are four types of completion:
19029 ------------------------------------------------------------------------------
19031 *atp-omnicompletion-commands*
19034 Command completion is triggered by the '\' character. For example, >
19035 \beg<CTRL-X><CTRL-O>
19039 Associated settings:
19040 |atp-g:LatexBox_completion_commands|
19041 |atp-g:LatexBox_completion_close_braces|
19044 ------------------------------------------------------------------------------
19046 *atp-omnicompletion-environments*
19049 Environment completion is triggered by '\begin{'. For example, >
19050 \begin{it<CTRL-X><CTRL-O>
19054 Completion of '\end{' automatically closes the last open environment.
19056 Associated settings:
19057 |atp-g:LatexBox_completion_environments|
19058 |atp-g:LatexBox_completion_close_braces|
19061 ------------------------------------------------------------------------------
19063 *atp-omnicompletion-labels*
19066 Label completion is triggered by '\ref{' or '\eqref{'. For example, >
19067 \ref{sec:<CTRL-X><CTRL-O>
19068 offers a list of all matching labels, with their associated value and page number.
19069 Labels are read from the aux file, so label completion works only after
19074 \ref{sec:<CTRL-X><CTRL-O>
19076 \eqref{2<CTRL-X><CTRL-O>
19077 < 3. labels and numbers together (separated by whitespace): >
19078 \eqref{eq 2<CTRL-X><CTRL-O>
19081 Associated settings:
19082 |atp-g:LatexBox_ref_pattern|
19083 |atp-g:LatexBox_completion_close_braces|
19086 ------------------------------------------------------------------------------
19088 *atp-omnicompletion-bibtex*
19091 BibTeX completion is triggered by '\cite{', '\citep{' or '\citet{'.
19092 For example, assume you have in your .bib files an entry looking like: >
19095 author = "Donald E. Knuth",
19096 title = "Seminumerical Algorithms",
19097 publisher = "Addison-Wesley",
19102 \cite{Knuth 1981<CTRL-X><CTRL-O>
19103 \cite{algo<CTRL-X><CTRL-O>
19105 You can also use regular expressions (or vim patterns) after '\cite{'.
19107 Associated settings:
19108 *atp-g:LatexBox_cite_pattern* Default: '\\cite\(p\|t\)\?\*\?\_\s*{'
19109 *atp-g:LatexBox_ref_pattern* Default: '\\v\?\(eq\|page\)\?ref\*\?\_\s*{'
19111 Patterns to match \cite and \ref commands for BibTeX and label completion.
19112 Must include the trailing '{'.
19113 To match all commands that contain 'cite' (case insensitive), use: >
19114 let g:LatexBox_cite_pattern = '\c\\\a*cite\a*\*\?\_\s*{'
19115 < To match all commands that end with 'ref' (case insensitive): >
19116 let g:LatexBox_ref_pattern = '\c\\\a*ref\*\?\_\s*{'
19117 < Both examples match commands with a trailing star too.
19119 *atp-g:LatexBox_bibtex_wild_spaces* Default: 1
19121 If nonzero, spaces act as wildcards ('.*') in completion.
19122 For example, if nonzero, >
19124 < is equivalent to >
19127 *atp-g:LatexBox_completion_close_braces* Default: 1
19129 If nonzero, omni completion will add closing brackets where relevant.
19130 For example, if nonzero, >
19135 *atp-g:LatexBox_completion_environments*
19136 *atp-g:LatexBox_completion_commands*
19138 Static completion lists for environments
19139 |atp-omnicompletion-environments| and commands
19140 |atp-omnicompletion-commands|.
19142 ================================================================================
19143 HOW TO CONFIGURE ATP TO YOUR NEEDS *atp-configure*
19146 There are several options you can set, and they might be set in your Vimrc
19147 file. The default values are given below (except the completion setup and
19148 bibtex documented above).
19150 $HOME/.atprc.vim (only on Unix/GnuLinux) or ftplugin/ATP_files/atprc.vim
19151 A configuration file for ATP. You do not have to use autocommands to set
19152 local-buffer variables, just place them here. The settings in atprc file
19153 override the values in history files (|atp-history|).
19155 Tip: If you want to see (almost) all the variables, type ':let g:atp-<CTRL+d>',
19156 and ':let b:<CTRL+d>'.
19158 All buffer variables (see |b:var|), i.e. these which name begins with "b:",
19159 should be set in your Vimrc file. The best way to do that is by using
19162 au BufReadPre *.tex let b:atp_TexCompiler="latex"
19164 If you put just let b:atp_TexCompiler, this will also work but not always: for
19165 example when you open a new buffer in existing Vim session.
19167 let b:atp_TexCompiler = "pdflatex" *b:atp_TexCompiler*
19168 Used by functions: TEX() (map \l, imap \l), VTEX() (map <F5>, imap <F5>)
19170 You can set it to latex, tex, luatex, and so on and possibly to
19173 There is a command to set this variable with nice completion, see
19176 let b:atp_TexFlavor = "tex"
19177 If you are editing a plain tex file it is automatically set to
19178 'plaintex', then you get highlighting for $$:$$. Some other features
19179 are planned (you can also set this while editing a 'tex' file, i.e.
19180 latex document but using $$:$$ is latex is not recommended it is know
19181 to break some latex specific things).
19183 let b:atp_TexOptions = ""
19184 If you want to set some additional options to your tex compiler you can
19185 use this variable, note that -output-directory, and -mode, are
19186 already used. You can use this to make reverse searching with xdvi see
19190 let b:atp_OutDir = fnameescape(fnamemodify(resolve(b:atp_MainFile,":h")) . "/"
19192 This is the directory in which tex will put the output files. If the
19193 open file is not a symbolic link it is equal to the directory in which
19194 the tex file is located. If the open file is a symbolic link it points
19195 to the directory in which the real file is located.
19197 If you set this variable to './' (or '.') and change the current
19198 working directory for example to /tmp (:cd /tmp) then the latex output
19199 will be placed in /tmp, i.e. it will move with with cd. However, the
19200 default value of b:atp_OutDir is not affected by :cd command.
19202 White spaces and other characters should not be escaped. It will be
19203 quoted in '...' using the |shellescape()| function.
19205 You can see the current output directory in the status (it is in the
19206 short notation) to see it whole type:
19208 or use the function ShowOptions() (see |apt-:ShowOptions|).
19210 If in your environment the variable $TEXMFOUTDIR is set the value of
19211 b:atp_OutDir will be set to its value.
19214 WRITING PROJECTS *atp-ProjectFiles*
19217 let b:atp_MainFile = expand("%:p")
19218 < This variable points to the main file of the project, it is set on the
19219 start up to the file you open. If you edit project file (for the first
19220 time), start with the main file and use gf (see |atp-gf|) to go to the
19221 project file you want to edit. In this way all the project files will
19222 have correctly set this variable. The value of this variable is used
19223 by compilation functions. This variable is written in the history file
19224 (see |atp-ProjectScript|). And when the history is on (see
19225 |atp-ProjectScript|,
19226 or set b:atp_History=1) it is restored between sessions. In this way,
19227 next time, you can open any project file and the b:atp_MainFile
19228 variable will be set to the correct value.
19230 The history feature stores more variables: b:TreeOfFiles a dictionary
19231 which contains the tree of input files, b:ListOfFiles - list of input
19232 files, b:TypeDict dictionary of types of input files, where the type
19233 is one of following: {preambule}, {input}, {bib}. The last variable is
19234 b:LevelDict which is a dictionary of input levels (for example: input
19235 files in input file have level 2).
19237 There are other tools to make editing project files more easy. There
19238 is search function: |atp-:S| which works better than the vim |:ijump|
19239 command, which cannot go above the current file in the tree of input
19240 files, but is much faster.
19242 :ToggleNn [on] *atp-:ToggleNn*
19243 The command |atp-:ToggleNn| toggles the value of |g:atp_mapNn| variable.
19244 The optional argument [on] has three possible values: "", "on" or
19245 "off". The default "", toggles the value of |g:atp_mapNn|, "on" sets
19246 g:atp_mapNn to 1 and "off" sets it to 0.
19250 < If it is set to 1 then several tools use |atp-:S| command instead of
19251 vim |search()| function (which looks only in the current buffer).
19253 |atp-:NPart|, |atp-:NChap|, |atp-:NSec|, |atp-:NSSec|, |atp-:NSSSec|,
19254 |atp-:PPart|, |atp-:PChap|, |atp-:PSec|, |atp-:PSSec|, |atp-:PSSSec|,
19258 The default value of |g:atp_mapNn| is 0.
19260 The variable g:atp_mapNn should be always set as follows (in
19261 |atprc| or |vimrc| file): >
19262 if !exists("g:atp_mapNn")
19263 let g:atp_mapNn = 1
19265 < Then the value will be preserved when atp opens new buffer
19266 when using |atp-:S| command. If you want to have project specific
19267 setting use |atp-ProjectScript|.
19269 Another good tip for LaTeX project files is to set |b:atp_TexFlavor|
19270 variable to 'tex' (in your |vimrc| or |atprc| file). This will prevent
19271 from situations that vim recognizes input file as a plain TeX while it
19272 is an input file into a LaTeX project.
19273 Anotehr way is add options to 'viewoptions' (see |'viewoptions'|). And
19274 set mkview and loadview via autocommands >
19275 au BufWinLeave *.tex mkview
19276 au BufWinEnter *.tex silent loadview
19277 < This will ensure that filetype variable is set correctly. Some ATP tools
19278 behave in a different way in plaintex files. For example TreeOfFiles
19279 function (it makes the variables b:TreeOfFiles, b:ListOfFiles,
19280 b:TypeDict, b:LevelDict). It is recursive in LaTeX files but not in
19281 plain TeX files). On this function is based the command :LocalCommands
19282 which makes list of commands, environments and colors for Tab
19283 Completion and also |atp-:S| command. It is done so, because in plain
19284 tex there is no way to distiguish input files from input packages
19285 which we do not want to scan (especialy recursively, which might be time
19288 PROJECT SCRIPT *atp-ProjectScript*
19289 < The file: |b:atp_MainFile| . ".project.vim", in the same directory as
19290 |b:atp_MainFile| stores values of local variables saved before vim
19291 leaved a buffer (it is very similar to |View|. Local and global
19292 variables are supported. The local variables which are cached in this
19293 way are listed in >
19294 let g:atp_cached_local_variables = [
19295 \ 'b:atp_MainFile', 'b:atp_History',
19296 \ 'b:atp_LocalCommands', 'b:atp_LocalColors',
19297 \ 'b:atp_LocalEnvironments', 'bTreeOfFiles',
19298 \ 'b:ListOfFiles', 'b:TypeDict',
19300 < The each file will have separate history file which stores the values
19301 of these variables.
19302 *atp-ProjectScriptCommon*
19303 There is also file for variables for all projects. It stores values of
19304 global variables (by default it is "ftplugin/ATP_files/common_var.vim".
19305 The global variables that are written in this file are given in vim
19307 let g:atp_cached_common_variables = [ 'g:atp_texpackages', 'g:atp_texclasses', 'g:atp_Library' ]
19309 If you want to disable this feature for some reason you can set >
19310 let g:atp_ProjectScript = 0
19312 let b:atp_ProjectScript = 0
19313 < If you want to disable this feature only for a given buffer.
19314 (The value of local variable overrides the value of global one!).
19315 Hint: (if you want to disable loading history for one file):
19316 In your .vimrc file you can set the local variable via
19317 autocommand group BufEnter or you can put an if statement in your
19319 if expadn("%:p") == <path_to_file>
19320 let b:atp_History = 0
19322 < If you want to turn off history file for all buffers use: >
19323 au FileType tex let b:atp_History=0
19324 < in |vimrc| file or 'let b:atp_History = 0' in |atprc| file.
19325 There are these commands: >
19326 :LoadProjectScript[!] [local/common]
19327 :WriteProjectScript[!] [local/common]
19328 :DeleteProjectScript[!] [local/common]
19329 :ToggleProjectScript[!] [on/off]
19330 < which do the obvious thing (if g:atp_History=0 or b:atp_History=0 they
19331 will not work). The default value of the optional argument is "local".
19332 :DeleteHistory [local] command (with optional argument [local]) deletes
19333 the history file for the current buffer (only the local one), with
19334 bang "!" it deletes also common history file. The bang of :WriteHistory
19335 forces to write to history file even when history is turned off
19336 (b:atp_History == 0 or !exists("b:atp_ProjectScript") && g:atp_ProjectScript == 0).
19338 The command ':ToggleProjectScript [on/off]' turns on/off the feature
19339 for this buffer (it sets |b:atp_ProjectScript|). When no argument is
19340 given it will toggle the value. With bang it also sets the global
19341 variable. |b:atp_ProjectScript| is by default in the >
19342 g:atp_cached_local_variables
19343 < so it will be restored afterwards. |b:atp_ProjectScript|if defined
19344 overrides the value of global variable g:atp_History. So you can set
19345 in your atp file g:atp_ProjectScript = 0 and for some files using the
19347 let g:atp_ProjectScript = 0
19348 if expand("%:t") == "myfile.tex"
19349 let b:atp_History = 1
19351 < will turn on the feature only for myfile.tex. Something more elaborate
19352 would be to set b:atp_History only for files with modification time
19353 less than two days for example.
19355 Note: If you delete the history file for the current buffer it will be
19356 written after exiting vim, unless you turn off the history feature.
19358 The project script is disabled for files which full path matches
19359 'texmf'. With the optional bang ':LoadProjectScript common' loads the
19360 common project script also for them. :WriteHistory command will write
19361 the history disregarding if the file is under texmf directory or not.
19363 Note: If you use this feature, you might need to use some times the
19364 commands: |atp-:LocalCommands| and |atp-:InputFiles| which will update
19365 b:atp_LocalCommands, b:atp_LocalColors, b:atp_LocalEnvironments and
19366 b:TreeOfFiles, b:ListOfFiles, b:TypeDict and b:LevelDict. Then use
19367 these commands |atp-:LocalCommands| (with bang "!"), and
19368 |:InputFiles|. The second set of variables is also updated by |atp-:S|
19369 (also with "!") and and |atp-:GotoFile| (with "!" as well).
19371 Note: Also when you add a package to tex you should remove the common
19372 history file, so that the new packages will be added to completion
19376 :S[!] /{pattern}/ [flags]
19377 The pattern is a vim pattern (with 'magic'). With bang "!" it
19378 regenerates the tree of input files.
19380 This is command does the same job as |/| but is recursive in the tree
19381 of files (so it is useful only in project files). The syntax of this
19382 command is similar to |:vimgrep|.
19384 This works similarly to |:ijump|. But also goes back to the root file
19387 It sets the alternate file to the buffer from which the search begun.
19388 Note that this means that if nothing was found the alternate file
19389 before search will be lost.
19391 The {pattern} is any vim pattern as desribed in |pattern| (it was only
19392 tested with 'magic' set on).
19394 The supported [flags] are 'bcewW'. Their meaning is the same as flags
19395 for |search()| function.
19397 You can enclose the pattern with any non-ID character (see
19398 |'isident'|) instead of /, as far as it does not appear in the
19399 {pattern}. Examples: >
19400 :S pattern\_swith\_sspaces
19402 :S pattern with spaces
19405 Note that the function might be slow when the project files where not
19408 There is a function to check where the input file is on the hard drive
19409 if the name in the input command doesn't include the full path. It
19410 asks kpsewhich which directories to search, filters out
19411 directories which are not under '/home' (I assume that there is your
19412 local texmf tree) and also directories which name contains one of the
19413 two keywords 'texlive' and 'kpsewhich'. This makes the searching
19416 Furthermore, the command is designed so that it can find all patterns
19417 '\\input' (and thus easily find next/previous input file). You can
19421 < and you can use |n| and |N| vim normal commands. Note that it if you
19422 go backward, then it means that it will find the most deep line, e.g.:
19427 \input{file.1} ----> -------
19432 < ':S /\\input/ b' in the X position fill find \input{file.1.1} assuming
19433 file.1.1.tex doesn't includes any other file.
19436 The pattern can be '\\input'. Then it goes recursively to the first
19439 *atp-:NInput* *atp-}i* *atp-]gf*
19440 *atp-:PInput* *atp-{i* *atp-[gf*
19441 Now it also doesn't search inside commented input files. There two
19443 :NInput, nmap ]gf, nmap }i
19444 :PInput, nmap [gf, nmap {i
19445 which finds the next/previous input line (also commented). See
19446 |atp-:S_input| to find how it works. They depend on |g:atp_mapNn|, if
19447 1 |atp-S:| is used if 0 vim |search()| function. To repeat search you
19448 can use |n| and |N| vim normal commands. These commands omit comment
19453 let b:atp_auruns = 1
19454 < This variable control how many times the automatic function calls tex
19455 compiler (consecutively). It is useful if you are working with PDF
19456 files and you want to have bookmarks (you can get them using hyperref
19457 package with the option: bookmarks. Then set b:atp_auruns to '2'.
19461 < This variable stores the current number of running instances of latex.
19462 When it is greater than 1 a message in the status line is shown. If :PID
19463 command returns that no latex is running this variable this variable
19466 *g:atp_MathVimOptions*
19468 g:atp_MathVimOptions = { 'textwidth' : '0' }
19469 < This variable is a dictionary of vim settings and its values which
19470 will be valid when you edit mathematics inside the pairs \(:\), $:$,
19471 \[:\], $$:$$ (only in plain tex files or if g:atp_TexFlavour
19472 = 'plaintex'). For example, the default value will toggle between
19473 your 'textwidth' in non-math and 0 in math. The dictionary may
19474 contain short option names equally well as long names.
19476 Note: the standard tex syntax file defines other zones: for example
19477 for align and equation environments (and many others) but some how
19478 they are not accessible using synstack() function.
19480 This feature can be turned off setting variable >
19481 g:atp_SetMathVimOptions
19482 < to '0', the default is '1'.
19483 *g:atp_autex_check_if_closed*
19485 let g:atp_autex_check_if_closed = 1
19486 < This feature is not implemented.
19487 tex run if all environments \begin:\end, \(:\) and \[:\] are closed.
19488 Set g:atp_autex_check_if_closed=0 in order to not make the checks.
19491 let g:texmf = $HOME/texmf
19492 < This variable configures where input files are placed. See
19493 |atp-:EditInputFile|.
19496 let g:askforoutdir = 0
19497 < Its values are 1 and 0. When it is set to 1 you will be asked for the
19498 name of a directory where tex will put output files, note that this
19499 name should end with a "/".
19502 let b:atp_Viewer = "xpdf"
19503 < it was tested with xpdf, evince, epdfviewer, kpdf, okular, xdvi and
19504 they all works fine. I'm using xpdf and the xpdf server options are
19505 supported so that the file is automatically reloaded (other viewers,
19506 except epdfview, have this functionality as well. This do not works
19507 for acroread. Read more about viewers in |atp-viewers|.
19509 If you use program b:atp_Viewer then you can use the variable
19510 b:atp_{b:atp_Viewer}Options to set the options, for example if b:atp_Viewer="xpdf"
19511 then you might use:
19513 *atp-Viewer_Options*
19520 b:atp_okularOptions
19521 b:atp_evinceOptions, etc ... (and also g:atp_...Options variables)
19522 Used by function: ViewOutput() (map \v, map <F3>, imap <F3>)
19524 For example, if you want to have different look of one document you can
19525 set it to "-bg gray20". Some examples:
19527 let b:atp_xpdfOptions = "-bg Grey30 -mattecolor SlateBlue2 -papercolor White"
19528 let g:atp_xpdfOptions = "-bg NavajoWhite4 -fg black -mattecolor burlywood"
19529 let b:atp_xdviOptions = "-expertmode 0 -s 6"
19533 let b:atp_XpdfServer=fnamemodify(expand("%"),":t")
19534 < Used by function: ViewOutput() (map \v, map <F3>, imap <F3>)
19536 It is equal to the name of the source file. You do not need escape
19537 spaces in the name (shellescape() function is used before it is send
19541 let b:atp_OpenViewer = 1
19542 < If the function which calls TeX compiler do not see that you are
19543 viewing the output file it will open it for you if b:atp_OpenViewer=1.
19544 Otherwise, this feature is disabled.
19547 let g:rmcommand = "perltrash"
19548 < Used by function: Delete() (map <F6>d imap <F6>d)
19550 If you have another 'trash can' program you can use it here, if you do
19551 not have it you can use "rm" (at your own risk). It is used to delete
19552 the files produced by (La)TeX (see |apt-Delete()|). The function
19553 Delete() will remove all files in the output directory (see
19554 |b:atp_OutDir|), which ends with an extension defined in the list
19555 |g:atp_tex_extensions|. If you set:
19559 then the function Delete() (see |apt-Delete()|) will use the Vim
19560 |delete()| command, and will delete only the files produced by the
19561 current '.tex' file. The temporary directory is cleared by rm command.
19563 The program 'perltrash' is in the package app-misc/perltrash (at least
19566 let g:atp_delete_output = 0
19567 < If set to 1 then Delete function (map <F6>d) will delete also the
19570 *g:atp_tex_extensions*
19572 let g:atp_tex_extensions=["aux", "log", "bbl", "blg", "spl", "snm", "nav", "thm", "brf", "out", "toc", "mpx", "idx", "maf", "blg", "glo", "mtc[0-9]", "mtc1[0-9]", "pdfsync" , "ind"]
19574 This list is used by the function Delete() (see |apt-Delete()|) which
19575 deletes all the files with the specified extension in the directory
19576 b:atp_OutDir, unless g:rmcommand="" (see |g:rmcommand|) in which case
19577 Delete() deletes only the output files for the current buffer.
19580 let g:keep = ["log", "aux", "toc", "bbl", "ind"]
19581 < Files with an extension belonging to this list will be copied from
19582 'b:atp_OutDir' to the temporary directory with appropriate name. Then it
19583 will be used by (La)TeX. (log file will be copied after it is created,
19584 other files will be copied back and forth between 'b:atp_OutDir' and the
19585 temporary directory). These four elements: log,aux,toc,bbl are
19586 essentially minimum to work with: table of contents, pdf-bookmarks and
19587 bibtex. There are possibly other classes, like beamer, or packages
19588 like theorem (produce .thm files) which will need to configure this
19591 You can change this variable by the command:
19592 :let g:keep+=["thm","spl"]
19595 let g:printeroptions = ""
19596 < You can set the printer options. These are options for the 'lpr'
19597 command, which will print the output file (pdf or dvi) this depends on
19598 the b:atp_TexCompiler that you use.
19602 < This variable is for debugging purposes. It stores the last executed command to
19603 compile your document. It changes also when your compiler was run
19609 < It is readonly variable.
19611 g:defaultbibflags see |atp-bibflags:default|
19612 g:defaultallbibflags see |atp-bibflags:all|
19613 b:atp_LastBibFlags see |atp-bibflags:last|
19615 b:bibfiles see |atp-variables-bib|
19618 s:notreadablebibfiles
19619 For more on bib flags see |atp-bibflags|.
19621 let t:toc_window_width=30
19622 < g:toc_window_width (by default not set, if set overrides
19623 t:toc_window_width)
19624 Configures the initial width of the window with table of contents.
19626 let t:labels_window_width=30
19627 < g:labels_window_width (by default not set, if set overrides
19628 t:labels_window_width)
19629 Configures the initial width of the window with labels.
19632 < by default it is not set, put the line
19634 let g:atp_statusline=0
19636 in your $VIMRC file if you do not want the status line provided by this
19637 plugin. (See |atp-:ATPStatus|).
19639 let b:atp_TruncateStatuSection=40
19640 < This variable sets how many characters of the section/subsection title
19641 (or chapter/section titles if you write a book) should be shown in the
19642 status line. Section title and subsection title gets equal amount of
19645 g:atp_kpsewhich_tex
19646 g:atp_raw_kpsewhich_tex
19647 < This two variables stores the information returned by
19648 'kpsewhich -show-path tex'
19649 They are locked. The first one has pretended '**' wildcards to every
19650 directory, which is done for using with globpath() and findfile()
19653 ================================================================================
19656 Lots of mappings which are given here uses #. This is a convenient map on
19657 British keyboards, but not in the US layout, you can change them for '`' or
19658 some other key that it is not used in Vim (there are not many of them though).
19659 The most commonly used latex-suite plugin uses similar set of mappings (but
19660 there might be some differences). The easy way to change imap leaders is by
19661 using the variables:
19663 g:atp_imap_first_leader == "#"
19664 < for Greak letters, >
19665 g:atp_imap_second_leader == "##"
19666 < for font commands, >
19667 g:atp_imap_third_leader == "]"
19668 < for environments, >
19669 g:atp_imap_fourth_leader == "["
19670 < for extra environments in the old layout.
19671 You can list imaps with |atp-:HelpMathIMaps| and |atp-:HelpEnvIMaps|.
19673 All other mappings (map, vmap, nmap, ...) are using <LocalLeader> which can be
19674 altered with the option |maplocalleader|. A good alternate solution is to use "_"
19677 Maps are using the <buffer> option thus are local to the buffer. To unmap you
19678 also have to use this option, for example to unmap \l issue the command:
19680 :unmap <buffer> <LocalLeader>l
19682 The maps are loaded unless you set one of variables: 'g:no_plugin_maps' or
19683 'g:no_atp_maps' (disables maps defined in tex_atp.Vim), 'g:no_atp_toc_maps'
19684 (disables maps defined in 'toc_atp.Vim'), 'g:atp_no_env_maps' (disables the
19685 environment maps '[*', ']*') or 'g:atp_no_tab_map' (disables the tab map
19686 for completion, then completion is mapped to <F7> and <S-F7> (for the non
19687 expert mode) but there is no map for 'WrapSelection()', you have to provide
19690 Note: in all mappings "\" is set to your <LocalLeader> (and thus, in fact, the
19693 Note: The list of commands might not be complete.
19701 map <F5>,imap <F5>, :VTEX
19704 map \v,map <F3>, imap \v, imap <F3>
19706 :Bibtex[!] run only BibTeX, with bang [!] run LaTeX+BibTeX+LaTeX+LaTeX
19709 :OpenLog, :ShowErrors o
19710 map <F6>l, imap <F6>l
19714 Deletes all the files with an extension which belongs to
19715 g:atp_tex_extensions in the directory b:atp_OutDir. By default
19716 g:atp_tex_extensions does not contain '.tex', '.pdf', '.dvi' so none
19717 of your important files will be deleted. If you set
19718 g:atp_delete_output=1 the function will delete also the current output
19719 file (but not any other!).
19723 This is a mapping to the command ':TOC'
19728 This is a mapping to the command ':Labels'
19730 :GotoFile, :EditInputFile
19734 nmap ]m, nmap [m *atp-[m*
19735 Goto the beginning of next/previous math environment.
19738 nmap ]M, nmap [M *atp-[M*
19739 Goto the beginning of next/previous displayed math environment.
19747 Goto previous \begin{
19755 Goto previous \end{
19759 Goto begin of next comment group
19763 Goto begin of previous comment group
19767 map <F1>, imap <F1>
19768 Then you have to type what you are looking for and press enter. The
19769 option 'keywordprg' is set to 'texdoc -m', i.e when your cursor is
19770 over a package name and you press 'K' key then you should see the
19771 package document file (if it is named after the package).
19773 Without any argument it will open "g:atp_TeXdocDefault", by default it
19774 is eqaul to "-a lshort", i.e. "The not so short introduction to LaTeX
19775 2e" by Tobias Oetiker. You can change the default for something that
19776 you use more often, for example you can set it to "-a faq", i.e. 'The
19777 UK TeX FAQ' (or even to "-a lshort faq" if you want them both :).
19781 Goto next input file.
19784 Goto previous input file.
19786 pdffonts is mapped to <F6>g
19787 There is also a command ':PdfFonts' which does the same.
19789 FONT COMMANDS *atp-imap-fonts*
19790 imap ##rm \textrm{}<Left>
19791 imap ##it \textit{}<Left>
19792 imap ##sl \textsl{}<Left>
19793 imap ##sf \textsf{}<Left>
19794 imap ##bf \textbf{}<Left>
19796 imap ##mit \mathit{}<Left>
19797 imap ##mrm \mathrm{}<Left>
19798 imap ##msf \mathsf{}<Left>
19799 imap ##mbf \mathbf{}<Left>
19802 GREEK LETTERS *atp-imap-greek-letters*
19803 Note: you can list this mappings using the command |atp-:HelpMathIMaps|.
19830 Not all upper Greek letters are in LaTeX:
19847 ENVIRONMENT IMAPS *atp-imap-environments*
19848 Note: you can list this mappings using the command |atp-:HelpEnvIMaps|.
19849 imap ]b \begin{}<Left>
19850 imap ]e \end{}<Left>
19851 imap ]c \begin{center}<Cr>\end{center}<Esc>O
19853 imap ]d \begin{definition}<Cr>\end{definition}<Esc>O
19854 imap ]t \begin{theorem}<Cr>\end{theorem}<Esc>O
19855 imap ]P \begin{proposition}<Cr>\end{proposition}<Esc>O
19856 imap ]l \begin{lemma}<Cr>\end{lemma}<Esc>O
19857 imap ]r \begin{remark}<Cr>\end{remark}<Esc>O
19858 imap ]C \begin{corollary}<Cr>\end{corollary}<Esc>O
19859 imap ]p \begin{proof}<Cr>\end{proof}<Esc>O
19860 imap ]x \begin{example}<Cr>\end{example}<Esc>O
19861 imap ]n \begin{note}<Cr>\end{note}<Esc>O
19863 imap ]E \begin{enumerate}<Cr>\end{enumerate}<Esc>O
19864 imap ]I \begin{itemize}<Cr>\end{itemize}<Esc>O
19865 imap ]i \item *atp-item*
19866 This map has more features: if the preceeding line is of the
19869 then using this map in a next line will result with
19871 This will work for other types of items, (1) -> (2), 1) -> 2),
19872 [1] -> [2], 1. -> 2. and also (a) -> (b), b) -> c), [c] -> [d],
19873 but also (1a) -> (1b).
19876 imap ]a \begin{align}<Cr>\end{align}<Esc>O
19877 imap ]q \begin{equation}<Cr>\end{equation}<Esc>O
19879 imap ]L \begin{flushleft}<Cr>\end{flushleft}<Esc>O
19880 imap ]R \begin{flushright}<Cr>\end{flushright}<Esc>O
19882 imap ]T \begin{center}<CR>\begin{tikzpicture}<CR><CR>\end{tikzpicture}<CR>\end{center}<Up><Up>
19883 imap ]f \begin{frame}<Cr>\end{frame}<Esc>O
19885 MATH IMAPS *atp-imap-math*
19886 These are very useful mappings for typing mathematics:
19889 These maps are done like in auctex plugin (the idea and the solution
19890 are taken from there :) and thus it is slightly different than just
19891 a map and works better).
19892 imap ]m \[\]<Left><Left>
19893 imap ]M \[\]<Left><Left>
19895 LOG FILE MAPS *atp-maps-log*
19896 This are available maps in the log file, when it was opened with
19897 |atp-:OpenLog| command >
19898 ]e, [e - go to next/previous error message in log file
19899 ]w, [w - go to next/previous warning message in log file
19900 ]c, [c - go to next/previous citation warning message in log file
19901 ]r, [r - go to next/previous reference warning message in log file
19902 ]i, [i - go to next/previous info message in log file
19903 ]f, [f - go to next/previous font info message in log file
19904 ]p, [p - go to next/previous font package message in log file
19905 ]P, [P - go to next/previous page in log file
19906 % - searchpair for (:).
19907 < You can use |n| and |N| vim normal commands to repeat previous search [count] times.
19909 ================================================================================
19910 DEBUGGING *atp-errors*
19911 This section describes some limitation of ATP (as you see, this section is
19912 not written, but the aim is to make it disapear anyway ;).
19914 *atp-errors-bibsearch*
19915 A possible error which may occur using the :BibSearch commands has a simple
19916 cause: we count number of brackets '()', '{}' and '"' (but nor '\"') to see
19917 where the bib entry ends and where to join lines. The message error is echoed
19918 when more than 30 lines where processed and the matching bracket was not found
19919 (or the number of '"' is odd). Look at your bib file at the specified
19920 position. Syntax highlighting for bib files can help you finding where such
19921 an error is located. (After reading the bib file comment lines and lines which
19922 begin with @string are removed, so that the brackets in comment lines do not
19925 ================================================================================
19926 EDITING TOOLS *atp-editing*
19929 visual mode: ie, iE, ae, im, am, ip, ap, iS, aS, c
19931 They select the current environment in two ways: >
19936 m - math zones: \(:\), $:$, \[:\], $$:$$,
19937 or math environment \begin:\end.
19940 < *atp-vie* *atp-viE* *atp-vae*
19941 ie, iE, ae select environment: from the nearest \begin (top) to the nearest \end (bottom).
19943 'viE' selects a bit more than 'vie' but less than 'vae', it
19944 selects a bracket pair before the beginning of the inner part
19945 of an environment, so it can be environment name or an option
19948 *atp-vim* *atp-vam*
19949 im, am selects mathematics.
19950 *atp-vip* *atp-vap*
19951 ip, ap selects paragraph.
19952 In inner mode: from the nearest >
19953 \begin, \end, \par, \newline or empty line (top)
19955 \begin, \end, \par, \newline or empty line (bottom).
19956 < in outer mode: from the nearest >
19957 \par or empty line (top)
19959 \par or empty line (bottom).
19960 < *atp-viS* *atp-vaS*
19961 iS, aS selects using syntax stack (see |synstack()|), inner is the
19962 top element in the syntax stack (the highlighted area will be
19963 small) and outer uses the most bottom element in the syntax
19964 stack (the resulting are will be wide). Some syntax groups are
19965 filtered out (like 'texDocZone') which not always are
19968 c select comment lines which begin with '^\s*%'. If not in
19969 comment line, end visual mode.
19973 Quite useful normal map: m`vipgq``. It is mapped to gw (in normal
19978 nmaps: g>, g<, 2g>, ..., 6g>
19979 A normal map to m`vipg>`` (or m`vip2g>``).
19983 ================================================================================
19984 REQUIREMENTS *atp-requirements*
19986 This plugin requires Vim version higher than 7. Several tools uses syntax, so
19987 even if you do not like colors on the screen you should set "syntax on". For
19988 example, the recognition of math mode used by |atp-completion|, and
19989 |atp-:TexAlign| command (but also some other things).
19991 It is nice to have 'texdoc' program. This plugin maps <F1> to a function which
19992 calls it. This allows to speed up searches for documentation. Also the option
19993 'keywordprg' has the value "texdoc -m", thus pressing 'K' (see |K|) over a tex
19994 package should open you the package documentation. The same applies to this
19997 Another good programs are: texloganalyzer (which is now not used by ATP) and pdffonts
19998 There is a map to use pdffonts, see: |pdffonts|.
20000 ================================================================================
20001 NOTES ON VIEWERS *atp-viewers*
20004 xpdf *atp-viewers-xpdf*
20005 It is fully supported. It is configured in the way that when your tex
20006 file have errors, xpdf viewer will not reload your file, which I found
20009 You can set your own options of xpdf using b:XpdfOptions, for example
20011 let b:atp_xpdfOptions="-bg NavajoWhite4 -fg black -mattecolor burylwood"
20013 will make xpdf view different. This is helpful when you edit to
20014 files, and do not want to xpdf mix them. Another example:
20016 let b:atp_xpdfOptions="-bg Grey30 -mattecolor SlateBlue2 -papercolor White"
20020 *atp-viewers-okular*
20022 Works fine. Note that okular has supports syncing in pdf. Just use
20023 'pdfsync' package ('\usepackage{pdfsync}') and set the option in
20025 settings>Configure Okular>Editor
20027 Editor Custom Text Editor
20028 Command gvim --servername GVIM --remote-expr "atplib#FindAndOpen('%f','%l')"
20029 < Then you can use <Shift>+<Left_Mouse> in okular to syncronize the gvim
20030 with pdf. This syncing is not 100% accurate and you can find on the
20031 pdfsync web-page that this is not a bug. For me syncing in xdvi works
20034 The function atplib#FindAndOpen asks each running gvim server if is is
20035 "hosting" source of the file %f. Then it uses this server to set the
20036 line (but it doesn't check if the cursor is in the right window!).
20039 The function 'atplib#FindAndOpen' will not start gvim if it is not
20042 Alternative configuration would be to run okular from vim and
20043 set the Command to >
20044 Command gvim --servername GVIM --remote-wait +%l %f
20045 < but I don't know how to set this from the command line. If you know,
20046 Many Thanks for Reporting!
20050 Works fine (moves page a little bit when updates a file).
20052 This viewer does not support automatic reloads when the file changes
20053 (but it seems that the work is in progress). You have to issue CTRL-R
20054 yourself when the file is changed.
20056 As with epdfview (with the difference that it supports automatic
20057 updates, but it do not works somehow)
20059 xdvi *atp-viewers-xdvi*
20060 *atp-viewers-xdvi-reverse/inverse-searching*
20061 Works fine. The file will be updated after a click (or use the xdvi
20062 options '-watchfile 1' see man xdvi for explanations). You can set
20063 inverse/reverse searching by the command |SetXdvi|. It is recommended
20064 to use gVim rather than Vim, if you want to use Vim you have to run it
20065 with the command: >
20066 vim --servername xdvi <file>
20067 < You can pick any server name.
20069 The command SetXdvi defines a new function:
20071 RevSearch() *atp-:RevSearch*
20072 map \rs, :RevSearch
20073 Which makes an reverse search (sets the xdvi position according to the
20074 cursor position in gVim).
20076 Here I describe how inverse/reverse searching is done.
20078 (1) Inverse searching
20079 (i.e. position Vim's cursor after xdvi event:
20080 usually CTRL+Left Mouse) with this options:
20082 let b:atp_TexCompiler = "latex"
20083 let b:atp_TexOptions = "-src-specials"
20084 let b:atp_Viewer = "xdvi -editor 'gvim --remote-wait +%l %f'"
20086 See Vim tip at: http://Vim.wikia.com/wiki/Vim_can_interact_with_xdvi
20088 (2) Reverse searching
20089 For reverse searching (position xdvi according to the Vim's cursor
20090 position) you can set:
20092 let b:reverse_search="xdvi -sourceposition " . line(".") . ":" . col(".") . fnamemodify(expand("%"),":p") . " " . fnamemodify(expand("%"),":p:r") . ".dvi"
20094 To make an reverse search:
20096 :call system(b:reverse_search)
20098 And xdvi will place itself at the current cursor position in the 'tex'
20099 source file. You can make a map for this.
20101 To use this with Vim one have to add server name. Run
20104 vim --servername VimTeX
20105 let b:atp_Viewer="xdvi -editor 'vim --servername " . v:servername . " --remote-wait +%l %f'"
20106 let b:reverse_search="xdvi -editdor 'vim --servername " . v:servername "' -sourceposition " . line(".") . ":" . col(".") . fnamemodify(expand("%"),":p") . " " . fnamemodify(expand("%"),":p:r") . ".dvi"
20108 In case of troubles:
20111 If reverse searching do not works for you, and you get an error, that
20112 there is no reference to your tex file in the dvi file, then open
20113 your dvi file in an editor (Vim :) and check what is the name after
20114 'src:<line number>' (this are the source specials put by 'latex
20115 -src-specials' command). It should refer to your tex file. Xdvi
20116 will not recognize if you specify the full name of the tex file (i.e.
20117 with path) in the b:reverse_search (as we do above using the
20118 modifier :p and the function fnamemodify in
20119 'fnamemodify(expand("%"),":p")' the other one with ":p:r" is OK!)
20120 and in the dvi file there is written just the name without the
20121 path (and vice versa, if you give just the name in
20122 b:reverse_search and in the file there is full path).
20124 There is an excellent web pages on inverse/reverse searching with
20126 http://xdvi.sourceforge.net/inverse-search.html
20127 < 'tip': You can put in your atprc file |atprc| file >
20128 au BufEnter *.tex :SetXdvi
20129 < 'tip': If you want to change the name of the command this is also
20130 possible for example by putting in you atprc file: >
20131 augroup DelCommands
20132 au VimEnter *tex delcommand SetXdvi
20133 au VimEnter *tex delcommand SetXpdf
20135 command! -buffer Xdvi :call SetXdvi()
20136 command! -buffer Xpdf :call SetXpdf()
20139 ================================================================================
20142 If you have any nice tip on editing (La)TeX with vim or ATP :) you can share it
20143 here (my email you'll find on top of the help file), or put them on the script
20146 :g/^[^%]*\\usepackge/# List loaded packages with line numbers
20148 y/\\begin{document}/ When standing on 1st line - copy the preambule
20149 (possibly to a register)
20150 :g/^\s*%/d Delete comment lines
20152 :g/\(^\s*\n\)\{2,}/d Compress empty lines
20153 / when there are more than two empty
20154 lines it leaves just one /
20156 vipgq Format inner paragraph. Or even better:
20157 m`vipgq`` This is so nice that I added a map: >
20161 m`vip<`` Indent inner paragraph, they are mapped to: >
20164 < There are also defined maps: 2g>, 3g> , 4g>
20167 :TeXdoc ams<Ctrl-d> Show tex documentation which matches ams (the
20168 completion for TeXdoc command finds matches in
20169 alias files of texdoc :!texdoc -f).
20170 \ref{^thm:<Tab> will list all cross references to theorems (if
20171 you use the prefix thm: for theorems.
20173 If you want to change the name of a command,
20175 augroup DelCommands
20176 au VimEnter *tex delcommand SetXdvi
20177 au VimEnter *tex delcommand SetXpdf
20179 command! -buffer Xdvi :call SetXdvi()
20180 command! -buffer Xpdf :call SetXpdf()
20182 However, not all functions are defined without
20183 <SID> (you can always try to reach me).
20185 :'<,'>WrapSelection @q Wrap a visual area with wrapper from the
20186 register q and with the default '}' end
20188 :'<,'>WrapSelection @q,@w As above but with the end wrapper from
20191 :map ]= ]sz= Goto the first spelling error and list
20192 :map [= [sz= suggestions. Another version is to use
20193 ]S and [S instead of ]s and [s.
20196 ================================================================================
20197 COLOUR HIGHLIGHTING AND SYNTAX GROUPS *atp-highlight*
20199 When the cursor is positioned on \begin{envname} or \end{envname} both
20200 corresponding \begin:\end get highlighted with syntax group MatchParen.
20201 To disable it type this in ex mode or put it in your atprc file: >
20202 augroup LatexBox_HighlightPairs
20207 There is a color scheme included: coots-beauty-256. You need 256 colors to use
20208 it (in the terminal).
20210 These are the highlights groups defined for various files and the default
20214 highlight atp_FileName Title
20215 highlight atp_LineNr LineNr
20216 highlight atp_Number Number
20217 highlight atp_Chapter Label
20218 highlight atp_Section Label
20219 highlight atp_SubSection Label
20220 highlight atp_Abstract Label
20221 < *this group highlights abstract and all the unnubered chapters
20222 and the bibliography.
20224 The chapter group highlights or chapters, or sections, or parts, depending
20225 what is your top level section in your latex document. This applies,
20226 accordingly, to other groups.
20229 highlight atp_label_FileName Title
20230 highlight atp_label_LineNr LineNr
20231 highlight atp_label_Name Label
20232 highlight atp_label_Counter Keyword
20235 this is very much the same as the standard syntax for bib files. Groups
20236 are named bibsearch<NAME> instead of bib<NAME>. There is one more group
20239 highlight bibsearchInfo
20241 which highlights the line number of the bib entry in the bib file. All
20242 bibsearch groups are by default linked to the bib groups.
20244 Yet, there is no default highlighting, try coots-beauty-256 color scheme.
20245 If you like it, I'm glad, if you have a nice (non standard) color scheme,
20246 I'm happy to get it, if you like to share it.
20249 The notification message that your compiler is running can be highlighted.
20250 For this set the variables: >
20251 g:atp_notification_{g:colors_name}_gui
20252 g:atp_notification_{g:colors_name}_guifg
20253 g:atp_notification_{g:colors_name}_guibg
20254 < Their values will be passed to gui guifg and guibg values of the highlight
20255 command. The g:colors_name variable is set by color scheme. Usually it is
20256 just the color scheme name but there might be a difference, for example:
20257 the provided color scheme file name is 'coots-beauty-256' but the variable
20258 is set to 'coots_beauty_256'. Example: >
20259 let g:atp_notification_coots_beauty_256_gui="DeepPink4"
20260 < will set the foreground color of 'pdfLaTeX' message to DeepPink4.
20262 *atp-highlight-notification*
20263 The status message 'LaTeX' ( if you use latex or 'pdfLaTeX' when you use
20264 pdflatex, and so on) can be highlighted. There are several variables to
20266 g:atp_notification_{g:colors_name}_gui
20267 g:atp_notification_{g:colors_name}_guifg
20268 g:atp_notification_{g:colors_name}_guibg
20270 g:atp_notification_{g:colors_name}_cterm
20271 g:atp_notification_{g:colors_name}_ctermfg
20272 g:atp_notification_{g:colors_name}_ctermbg
20273 < where g:colors_name is the name of the color scheme, for example the
20274 supplied color scheme with atp 'runtimepath/colors/coots-beauty-256' has
20275 name 'coots_beauty_256' so the first variable should be >
20276 g:atp_highlight_coots_beauty_256_gui
20277 < value of these variables are used to set highlight for the group UserN
20278 where N is the value of g:atp_statusNotifHi. Its value should be
20279 0,1,...,9. Where 0 means no highlight for status notification (which is
20280 the default). If it is set to positive value then the default values of
20281 these variables should give the same color as the status line has.
20283 The variable g:atp_StatusLine is stores the value of vim option
20284 'statusline'; actually 'statusline' option is set by: >
20285 set statusline=%!g:atp_StatusLine
20288 ================================================================================
20289 FINAL REMARKS *atp-remarks*
20291 To see some messages that are issued you can use :messages command
20294 If you find this plugin useful and have some comments you are
20295 cordially invited to write to the author: <mszamot@gmail.com>.
20297 There are other ways to make such an automatic plugin. The crucial
20298 step is to make the plugin know that tex is already in use (if you run
20299 to tex compilers on the same file at the same time the effect won't be
20302 For several month I was using a different code which was not using
20303 temporary copies but was checking if the tex is running or not. It was
20304 working very good but I didn't understand why (silly isn't it), and
20305 when I started making changes it stopped working: the issue is that
20306 it is difficult to make a function sleep until tex stops working not
20307 putting whole Vim into sleep - this is the time that we want to save.
20308 However, the advantage of using temporary files is smoothness (changes
20309 appear faster in the output file).
20311 Best regards, and hopefully you will find this useful :)
20315 ================================================================================
20316 COPY RIGHTS *atp-copy-rights*
20319 " Copyright: Copyright (C) 2010 Marcin Szamotulski Permission is hereby
20320 " granted to use and distribute this code, with or without
20321 " modifications, provided that this copyright notice is copied
20322 " with it. Like anything else that's free, Automatic TeX Plugin
20323 " is provided *as is* and comes with no warranty of any kind,
20324 " either expressed or implied. By using this plugin, you agree
20325 " that in no event will the copyright holder be liable for any
20326 " damages resulting from the use of this software.
20329 im:tw=75:ts=8:ft=help:norl:
20330 doc/latexhelp.txt [[[1
20332 *latexhelp.txt* For Vim version 6.0. Last change: 2001 Dec 20
20336 translated (with minor changes) for vim
20337 by Mikolaj Machowski
20339 This file documents LaTeX2e, a document preparation system. LaTeX2e is a
20340 macro package for TeX.
20342 This is edition 1.6 of the LaTeX2e documentation, and is for the Texinfo
20343 that is distributed as part of Version 19 of GNU Emacs. It uses version
20344 2.134 or later of the texinfo.tex input file.
20346 This is translated from LATEX.HLP v1.0a in the VMS Help Library. The
20347 pre-translation version was written by George D. Greenwade of Sam Houston
20350 The LaTeX 2.09 version was written by Stephen Gilmore <stg@dcs.ed.ac.uk>.
20352 The LaTeX2e version was adapted from this by Torsten Martinsen
20353 <bullestock@dk-online.dk>.
20355 Version for vim of this manual was written by Mikolaj Machowski
20358 Copyright 1988,1994 Free Software Foundation, Inc. Copyright 1994-1996
20359 Torsten Martinsen. Copyright for `translation' for vim Mikolaj Machowski 2001.
20361 Permission is granted to make and distribute verbatim copies of this manual
20362 provided the copyright notice and this permission notice are preserved on
20365 Permission is granted to copy and distribute modified versions of this
20366 manual under the conditions for verbatim copying, provided that the entire
20367 resulting derived work is distributed under the terms of a permission
20368 notice identical to this one.
20370 Permission is granted to copy and distribute translations of this manual
20371 into another language, under the above conditions for modified versions,
20372 except that the sections entitled "Distribution" and "General Public
20373 License" may be included in a translation approved by the author instead of
20374 in the original English.
20376 ==============================================================================
20379 The LaTeX command typesets a file of text using the TeX program and the LaTeX
20380 Macro package for TeX. To be more specific, it processes an input file
20381 containing the text of a document with interspersed commands that describe how
20382 the text should be formatted.
20384 1. Commands |latex-commands|
20385 2. Counters |latex-counters|
20386 3. Cross References |latex-references|
20387 4. Definitions |latex-definitions|
20388 5. Document Classes |latex-classes|
20389 6. Layout |latex-layout|
20390 7. Environments |latex-environments|
20391 8. Footnotes |latex-footnotes|
20392 9. Lengths |latex-lengths|
20393 10. Letters |latex-letters|
20394 11. Line & Page Breaking |latex-breaking|
20395 12. Making Paragraphs |latex-paragraphs|
20396 13. Margin Notes |latex-margin-notes|
20397 14. Math Formulae |latex-math|
20398 15. Modes |latex-modes|
20399 16. Page Styles |latex-page-styles|
20400 17. Sectioning |latex-sectioning|
20401 18. Spaces & Boxes |latex-spaces-boxes|
20402 19. Special Characters |latex-special-char|
20403 20. Splitting the Input |latex-inputting|
20404 21. Starting & Ending |latex-start-end|
20405 22. Table of Contents |latex-toc|
20406 23. Terminal Input/Output |latex-terminal|
20407 24. Typefaces |latex-typefaces|
20408 25. Parameters |latex-parameters|
20410 ==============================================================================
20411 1. Commands *latex-commands*
20413 A LaTeX command begins with the command name, which consists of a \ followed
20415 (a) a string of letters or
20416 (b) a single non-letter.
20418 Arguments contained in square brackets, [], are optional while arguments
20419 contained in braces, {}, are required.
20421 NOTE: LaTeX is case sensitive. Enter all commands in lower case unless
20422 explicitly directed to do otherwise.
20424 ==============================================================================
20425 2. Counters *latex-counters*
20427 |\addtocounter| Add a quantity to a counter
20428 |\alph| Print value of a counter using letters
20429 |\arabic| Print value of a counter using numerals
20430 |\fnsymbol| Print value of a counter using symbols
20431 |\newcounter| Define a new counter
20432 |\refstepcounter| Add to counter, resetting subsidiary counters
20433 |\roman| Print value of a counter using roman numerals
20434 |\setcounter| Set the value of a counter
20435 |\stepcounter| Add to counter, resetting subsidiary counters
20436 |\usecounter| Use a specified counter in a list environment
20437 |\value| Use the value of a counter in an expression
20439 Everything LaTeX numbers for you has a counter associated with it. The name of
20440 the counter is the same as the name of the environment or command that
20441 produces the number, except with no |\\|. (|lc-enumi| - |lc-enumiv| are used
20442 for the nested |\enumerate| environment.) Below is a list of the counters
20443 used in LaTeX's standard document classes to control numbering.
20445 |part| |paragraph| |figure| |enumi| |itemi|
20446 |chapter| |subparagraph| |table| |enumii| |itemii|
20447 |section| |page| |footnote| |enumiii| |itemiii|
20448 |subsection| |equation| |mpfootnote| |enumiv| |itemiv|
20452 \addtocounter{counter}{value} *\addtocounter*
20453 Increments the {counter} by the amount specified by the
20454 {value} argument. The {value} argument can be negative.
20456 \alph{counter} *\alph* *\Alph*
20458 This command causes the value of the counter to be printed in
20459 alphabetic characters. |\alph| command uses lower case
20460 alphabetic alphabetic characters, i.e., a, b, c... while the
20461 |\Alph| command uses upper case alphabetic characters, i.e.,
20464 \arabic{counter} *\arabic*
20465 Causes the value of the {counter} to be printed in Arabic
20468 \fnsymbol{counter} *\fnsymbol*
20469 Causes the value of the {counter} to be printed in a specific
20470 sequence of nine symbols that can be used for numbering
20472 Note: counter must have a value between 1 and 9 inclusive.
20474 \newcounter{foo}[counter] *\newcounter*
20475 Defines a new counter named {foo}. The counter is initialized
20476 to zero. The optional argument [counter] causes the counter
20477 {foo} to be reset whenever the counter named in the optional
20478 argument is incremented.
20480 \refstepcounter{counter} *\refstepcounter*
20481 Command works like |\stepcounter|, except it also defines the
20482 current |\ref| value to be the result of \thecounter.
20484 \roman{counter} *\roman* *\Roman*
20486 Causes the value of the {counter} to be printed in Roman
20487 numerals. The |\roman| command uses lower case Roman numerals,
20488 i.e., i, ii, iii..., while the |\Roman| command uses upper case
20489 Roman numerals, i.e., I, II, III....
20491 \stepcounter{counter} *\stepcounter*
20492 Adds one to the {counter} and resets all subsidiary counters.
20494 \setcounter{counter}{value} *\setcounter*
20495 Sets the value of the {counter} to that specified by the
20498 \usecounter{counter} *\usecounter*
20499 Command is used in the second argument of the |list|
20500 environment to allow the {counter} specified to be used to
20501 number the list items.
20503 \value{counter} *\value*
20504 Produces the value of the {counter} named in the mandatory
20505 argument. It can be used where LaTeX expects an integer or
20506 number, such as the second argument of a |\setcounter| or
20507 |\addtocounter| command, or in: >
20508 \hspace{\value{foo}\parindent}
20509 < It is useful for doing arithmetic with counters.
20511 ==============================================================================
20512 3. Cross References *latex-references*
20514 One reason for numbering things like figures and equations is to refer the
20515 reader to them, as in "See Figure 3 for more details."
20517 |\label| Assign a symbolic name to a piece of text
20518 |\pageref| Refer to a page number
20519 |\ref| Refer to a section, figure or similar
20522 \label{key} *\label*
20523 Command appearing in ordinary text assigns to the {key} the
20524 number of the current sectional unit; one appearing inside a
20525 numbered environment assigns that number to the {key}.
20527 A {key} can consist of any sequence of letters, digits, or
20528 punctuation characters. Upper and lowercase letters are
20531 To avoid accidentally creating two labels with the same name,
20532 it is common to use labels consisting of a prefix and a suffix
20533 separated by a colon. The prefixes conventionally used are
20534 * 'cha' for chapters
20535 * 'sec' for lower-level sectioning commands
20536 * 'fig' for figures
20538 * 'eq' for equations
20539 Thus, a label for a figure would look like: >
20540 \label{fig:bandersnatch}
20542 \pageref{key} *\pageref*
20543 Command produces the page number of the place in the text
20544 where the corresponding |\label| command appears. ie. where
20545 \label{key} appears.
20548 Command produces the number of the sectional unit, equation
20549 number, ... of the corresponding |\label| command.
20551 ==============================================================================
20552 4. Definitions *latex-definitions*
20554 |\newcommand| Define a new command
20555 |\newenvironment| Define a new environment
20556 |\newtheorem| Define a new theorem-like environment
20557 |\newfont| Define a new font name
20560 \newcommand{cmd}[args]{definition} *\newcommand* *\renewcommand*
20561 \newcommand{cmd}[args][default]{definition}
20562 \renewcommand{cmd}[args]{definition}
20563 \renewcommand{cmd}[args][default]{definition}
20565 These commands define (or redefine) a command.
20567 {cmd} A command name beginning with a |\\|. For |\newcommand| it must
20568 not be already defined and must not begin with |\end|; for
20569 |\renewcommand| it must already be defined.
20571 {args} An integer from 1 to 9 denoting the number of arguments of the
20572 command being defined. The default is for the command to have
20575 {default} If this optional parameter is present, it means that the
20576 command's first argument is optional. The default value of the
20577 optional argument is default.
20579 {definition} The text to be substituted for every occurrence of {cmd}; a
20580 parameter of the form #n in {cmd} is replaced by the text of
20581 the nth argument when this substitution takes place.
20583 *\newenvironment* *\renewenvironment*
20584 \newenvironment{nam}[args]{begdef}{enddef}
20585 \newenvironment{nam}[args][default]{begdef}{enddef}
20586 \renewenvironment{nam}[args]{begdef}{enddef}
20588 These commands define or redefine an environment.
20590 {nam} The name of the environment. For |\newenvironment| there must
20591 be no currently defined environment by that name, and the
20592 command \nam must be undefined. For |\renewenvironment| the
20593 environment must already be defined.
20595 {args} An integer from 1 to 9 denoting the number of arguments of
20596 the newly-defined environment. The default is no arguments.
20598 {default} If this is specified, the first argument is optional, and
20599 default gives the default value for that argument.
20601 {begdef} The text substituted for every occurrence of \begin{nam}; a
20602 parameter of the form #n in {cmd} is replaced by the text of
20603 the nth argument when this substitution takes place.
20605 {enddef} The text substituted for every occurrence of \end{nam}. It
20606 may not contain any argument parameters.
20609 \newtheorem{envname}{caption}[within] *\newtheorem*
20610 \newtheorem{envname}[numberedlike]{caption}
20612 This command defines a theorem-like environment.
20614 {envname} The name of the environment to be defined. A string of
20615 letters. It must not be the name of an existing environment or
20618 {caption} The text printed at the beginning of the environment, right
20619 before the number. This may simply say "Theorem", for example.
20621 {within} The name of an already defined counter, usually of a sectional
20622 unit. Provides a means of resetting the new theorem counter
20623 within the sectional unit.
20625 {numberedlike} The name of an already defined theorem-like environment.
20627 The |\newtheorem| command may have at most one optional argument.
20630 \newfont{cmd}{fontname} *\newfont*
20631 Defines the command name {cmd}, which must not be currently
20632 defined, to be a declaration that selects the font named
20633 {fontname} to be the current font.
20635 ==============================================================================
20636 5. Document Classes *latex-classes*
20639 \documentclass[options]{class} *\documentclass*
20641 Valid LaTeX document classes include:
20642 *article *article-class*
20643 *report *report-class*
20644 *letter *letter-class*
20646 *slides *slides-class*
20648 All the standard classes (except slides) accept the following options for
20649 selecting the typeface size (10 pt is default):
20653 All classes accept these options for selecting the paper size (default is
20656 a4paper, a5paper, b5paper, letterpaper, legalpaper, executivepaper
20658 Miscellaneous options:
20660 landscape *landscape*
20661 Selects landscape format. Default is portrait.
20663 titlepage, notitlepage *notitlepage*
20664 Selects if there should be a separate title page.
20666 leqno *leqno* *rqno*
20667 Equation number on left side of equations. Default is
20671 Displayed formulas flush left. Default is centred.
20674 Use "open" bibliography format.
20676 draft, final *draft* *final*
20677 Mark/do not mark overfull boxes with a rule. Default is
20680 These options are not available with the slides class:
20682 oneside, twoside *oneside* *twoside*
20683 Selects one- or twosided layout. Default is oneside,
20684 except for the book class.
20686 openright, openany *openright* *openany*
20687 Determines if a chapter should start on a right-hand page.
20688 Default is openright for book.
20690 onecolumn, twocolumn *onecolumn* *twocolumn*
20691 One or two columns. Defaults to one column.
20693 The slides class offers the option clock for printing the time at the bottom
20696 If you specify more than one option, they must be separated by a comma.
20698 \usepackage[options]{pkg} *\usepackage*
20699 Additional packages are loaded by this. If you
20700 specify more than one package, they must be separated by a
20703 Any options given in the |\documentclass| command that are unknown by the
20704 selected document class are passed on to the packages loaded with |\usepackage|.
20706 ==============================================================================
20707 6. Layout *latex-layout*
20709 Miscellaneous commands for controlling the general layout of the page.
20711 |\flushbottom| Make all text pages the same height.
20712 |\onecolumn| Use one-column layout.
20713 |\raggedbottom| Allow text pages of differing height.
20714 |\twocolumn| Use two-column layout.
20716 \flushbottom *\flushbottom*
20717 Makes all text pages the same height, adding extra vertical
20718 space when necessary to fill out the page. This is the
20719 standard if twocolumn mode is selected.
20721 \onecolumn *\onecolumn*
20722 Starts a new page and produces single-column output.
20724 \raggedbottom *\raggedbottom*
20725 Makes all pages the height of the text on that page. No extra
20726 vertical space is added.
20728 \twocolumn[text] *\twocolumn*
20729 Starts a new page and produces two-column output. If the
20730 optional [text] argument is present, it is typeset in
20733 ==============================================================================
20734 7. Environments *latex-environments*
20737 LaTeX provides a number of different paragraph-making environments. Each
20738 environment begins and ends in the same manner: >
20740 \begin{environment-name}
20744 \end{environment-name}
20746 a. |array| Math arrays
20747 b. |center| Centred lines
20748 c. |description| Labelled lists
20749 d. |enumerate| Numbered lists
20750 e. |eqnarray| Sequences of aligned equations
20751 f. |equation| Displayed equation
20752 g. |figure| Floating figures
20753 h. |flushleft| Flushed left lines
20754 i. |flushright| Flushed right lines
20755 j. |itemize| Bulleted lists
20756 k. |letter| Letters
20757 l. |list| Generic list environment
20758 m. |minipage| Miniature page
20759 n. |picture| Picture with text, arrows, lines and circles
20760 o. |quotation| Indented environment with paragraph indentation
20761 p. |quote-l| Indented environment with no paragraph indentation
20762 q. |tabbing| Align text arbitrarily
20763 r. |table| Floating tables
20764 s. |tabular| Align text in columns
20765 t. |thebibliography| Bibliography or reference list
20766 u. |theorem| Theorems, lemmas, etc
20767 v. |titlepage| For hand crafted title pages
20768 x. |verbatim| Simulating typed input
20769 y. |verse| For poetry and other things
20771 ==============================================================================
20774 \begin{array}{col1col2...coln}
20775 column 1 entry & column 2 entry ... & column n entry \\
20781 Math arrays are produced with the |array| environment. It has a single mandatory
20782 argument describing the number of columns and the alignment within them. Each
20783 column, coln, is specified by a single letter that tells how items in that row
20784 should be formatted.
20786 * l -- for flush left
20787 * r -- for flush right
20788 Column entries must be separated by an |&|. Column entries may include other
20789 LaTeX commands. Each row of the array must be terminated with the string |\\|.
20791 Note that the |array| environment can only be used in |math-mode|, so normally
20792 it is used inside an |equation| environment.
20794 ==============================================================================
20805 The |\center| environment allows you to create a paragraph consisting of lines
20806 that are centred within the left and right margins on the current page. Each
20807 line must be terminated with the string |\\|.
20809 \centering *\centering*
20810 This declaration corresponds to the |center| environment. This
20811 declaration can be used inside an environment such as
20812 |quote-l| or in a |\parbox|. The text of a |figure| or |table|
20813 can be centred on the page by putting a |\centering| command
20814 at the beginning of the |figure| or |table| environment.
20815 Unlike the |center| environment, the |\centering| command does
20816 not start a new paragraph; it simply changes how LaTeX formats
20817 paragraph units. To affect a paragraph unit's format, the
20818 scope of the declaration must contain the blank line or |\end|
20819 command (of an environment like |quote-l|) that ends the
20822 ==============================================================================
20823 c. description *description*
20825 \begin{description}
20826 \item [label] First item
20827 \item [label] Second item
20833 The |description| environment is used to make labelled lists. The label is
20834 bold face and flushed right.
20836 ==============================================================================
20837 d. enumerate *enumerate*
20847 The |enumerate| environment produces a numbered list. Enumerations can be
20848 nested within one another, up to four levels deep. They can also be nested
20849 within other paragraph-making environments.
20851 \item Each item of an enumerated list begins with an |\item|
20852 command. There must be at least one |\item| command
20853 within the environment.
20855 The |enumerate| environment uses the |\enumi| through |\enumiv| counters (see
20856 section |latex-counters|). The type of numbering can be changed by redefining
20859 ==============================================================================
20860 e. eqnarray *eqnarray*
20870 The |eqnarray| environment is used to display a sequence of equations or
20871 inequalities. It is very much like a three-column |array| environment, with
20872 consecutive rows separated by |\\| and consecutive items within a row separated
20875 \nonumber *\nonumber*
20876 An equation number is placed on every line unless that
20877 line has a |\nonumber| command.
20879 \lefteqn *\lefteqn*
20880 The command |\lefteqn| is used for splitting long
20881 formulas across lines. It typesets its argument in
20882 display style flush left in a box of zero width.
20884 ==============================================================================
20885 f. equation *equation*
20891 The |equation| environment centres your equation on the page and places the
20892 equation number in the right margin.
20894 ==============================================================================
20897 \begin{figure}[placement]
20899 \caption{figure title}
20902 Figures are objects that are not part of the normal text, and are usually
20903 "floated" to a convenient place, like the top of a page. Figures will not be
20904 split between two pages.
20906 The optional argument [placement] determines where LaTeX will try to place
20907 your figure. There are four places where LaTeX can possibly put a float:
20909 h (Here) at the position in the text where the figure
20910 environment appears.
20911 t (Top) at the top of a text page.
20912 b (Bottom) at the bottom of a text page.
20913 p (Page of floats) on a separate float page, which is a page containing
20914 no text, only floats.
20916 The standard |report-class| and |article-class| use the default placement
20919 The body of the |figure| is made up of whatever text, LaTeX commands, etc. you
20922 The \caption command allows you to title your figure.
20924 ==============================================================================
20925 h. flushleft *flushleft*
20935 The |flushleft| environment allows you to create a paragraph consisting of
20936 lines that are flushed left, to the left-hand margin. Each line must be
20937 terminated with the string |\\|.
20939 \raggedright *\raggedright*
20940 This declaration corresponds to the |flushleft| environment.
20941 This declaration can be used inside an environment such as
20942 |quote-l| or in a |\parbox|. Unlike the |flushleft|
20943 environment, the |\raggedright| command does not start a new
20944 paragraph; it simply changes how LaTeX formats paragraph
20945 units. To affect a paragraph unit's format, the scope of the
20946 declaration must contain the blank line or |\end| command (of
20947 an environment like |quote-l|) that ends the paragraph unit.
20949 ==============================================================================
20950 i. flushright *flushright*
20960 The |flushright| environment allows you to create a paragraph consisting of
20961 lines that are flushed right, to the right-hand margin. Each line must be
20962 terminated with the string |\\|.
20964 \raggedleft *\raggedleft*
20965 This declaration corresponds to the |flushright| environment.
20966 This declaration can be used inside an environment such as
20967 |quote-l| or in a |\parbox|. Unlike the |flushright|
20968 environment, the |\raggedleft| command does not start a new
20969 paragraph; it simply changes how LaTeX formats paragraph
20970 units. To affect a paragraph unit's format, the scope of the
20971 declaration must contain the blank line or |\end| command (of
20972 an environment like |quote-l|) that ends the paragraph unit.
20974 ==============================================================================
20975 j. itemize *itemize*
20985 The |itemize| environment produces a "bulleted" list. Itemizations can be
20986 nested within one another, up to four levels deep. They can also be nested
20987 within other paragraph-making environments.
20990 Each item of an itemized list begins with an |\item| command.
20991 There must be at least one |\item| command within the
20994 The itemize environment uses the |\itemi| through |\itemiv| counters (see
20995 section |latex-counters|). The type of numbering can be changed by redefining
20998 ==============================================================================
20999 k. letter *\letter*
21001 This environment is used for creating letters. See section |latex-letters|.
21003 ==============================================================================
21006 The |list| environment is a generic environment which is used for defining many
21007 of the more specific environments. It is seldom used in documents, but often
21010 \begin{list}{label}{spacing}
21018 'label' The {label} argument specifies how items should be labelled.
21019 This argument is a piece of text that is inserted in a box to
21020 form the {label}. This argument can and usually does contain
21021 other LaTeX commands.
21023 'spacing' The {spacing} argument contains commands to change the spacing
21024 parameters for the |list|. This argument will most often be
21025 null, i.e., {}. This will select all default spacing which
21026 should suffice for most cases.
21028 ==============================================================================
21029 m. minipage *minipage*
21031 \begin{minipage}[position]{width}
21035 The |minipage| environment is similar to a |\parbox| command. It takes the
21036 same optional [position] argument and mandatory {width} argument. You may use
21037 other paragraph-making environments inside a |minipage|. Footnotes in a
21038 minipage environment are handled in a way that is particularly useful for
21039 putting footnotes in figures or tables. A |\footnote| or |\footnotetext|
21040 command puts the footnote at the bottom of the minipage instead of at the
21041 bottom of the page, and it uses the |\mpfootnote| counter instead of the
21042 ordinary footnote counter. See sections |latex-counters| and
21045 NOTE: Don't put one |minipage| inside another if you are using footnotes; they
21046 may wind up at the bottom of the wrong minipage.
21048 ==============================================================================
21049 n. picture *picture*
21052 \begin{picture}(width,height)(x offset,y offset)
21060 The |picture| environment allows you to create just about any kind of picture
21061 you want containing text, lines, arrows and circles. You tell LaTeX where to
21062 put things in the picture by specifying their coordinates. A coordinate is a
21063 number that may have a decimal point and a minus sign -- a number like 5, 2.3
21064 or -3.1416. A coordinate specifies a length in multiples of the unit length
21065 |\unitlength|, so if |\unitlength| has been set to 1cm, then the coordinate
21066 2.54 specifies a length of 2.54 centimetres. You can change the value of
21067 |\unitlength| anywhere you want, using the |\setlength| command, but strange
21068 things will happen if you try changing it inside the |picture| environment.
21070 A position is a pair of coordinates, such as (2.4,-5), specifying the point
21071 with x-coordinate 2.4 and y-coordinate -5. Coordinates are specified in the
21072 usual way with respect to an origin, which is normally at the lower-left
21073 corner of the |picture|.
21074 Note that when a position appears as an argument, it is not enclosed in
21075 braces; the parentheses serve to delimit the argument.
21077 The |picture| environment has one mandatory argument, which is a position. It
21078 specifies the size of the picture. The environment produces a rectangular box
21079 with width and height determined by this argument's x- and y-coordinates.
21081 The |picture| environment also has an optional position argument, following
21082 the size argument, that can change the origin. (Unlike ordinary optional
21083 arguments, this argument is not contained in square brackets.) The optional
21084 argument gives the coordinates of the point at the lower-left corner of the
21085 picture (thereby determining the origin). For example, if |\unitlength| has
21086 been set to 1mm, the command: >
21087 \begin{picture}(100,200)(10,20)
21089 produces a picture of width 100 millimetres and height 200 millimetres, whose
21090 lower-left corner is the point (10,20) and whose upper-right corner is
21091 therefore the point (110,220). When you first draw a picture, you will omit
21092 the optional argument, leaving the origin at the lower-left corner. If you
21093 then want to modify your picture by shifting everything, you just add the
21094 appropriate optional argument.
21096 The environment's mandatory argument determines the nominal size of the
21097 picture. This need bear no relation to how large the picture really is; LaTeX
21098 will happily allow you to put things outside the picture, or even off the
21099 page. The picture's nominal size is used by LaTeX in determining how much room
21102 Everything that appears in a picture is drawn by the |\put| command. The
21104 \put (11.3,-.3){...}
21106 puts the object specified by ... in the picture, with its
21107 reference point at coordinates (11.3,-.3). The reference points for various
21108 objects will be described below.
21110 The |\put| creates an LR box (|lrbox|). You can put anything in the text
21111 argument of the |\put| that you'd put into the argument of an |\mbox| and
21112 related commands. When you do this, the reference point will be the lower left
21116 |\circle| Draw a circle
21117 |\dashbox| Draw a dashed box
21118 |\frame| Draw a frame around an object
21119 |\framebox(picture)| Draw a box with a frame around it
21120 |\line| Draw a straight line
21121 |\linethickness| Set the line thickness
21122 |\makebox(picture)| Draw a box of the specified size
21123 |\multiput| Draw multiple instances of an object
21124 |\oval| Draw an ellipse
21125 |\put| Place an object at a specified place
21126 |\shortstack| Make a pile of objects
21127 |\vector| Draw a line with an arrow
21129 \circle[*]{diameter} *\circle*
21130 Command produces a circle with a {diameter} as close to the
21131 specified one as possible. If the *-form of the command is
21132 used, LaTeX draws a solid circle.
21133 Note: only circles up to 40 pt can be drawn.
21136 \dashbox{dashlength}(width,height){...} *\dashbox*
21137 Draws a box with a dashed line. The |\dashbox| has an extra
21138 argument which specifies the width of each dash. A dashed box
21139 looks best when the width and height are multiples of the
21142 \frame{...} *\frame*
21143 Puts a rectangular frame around the object specified in the
21144 argument. The reference point is the bottom left corner of the
21145 frame. No extra space is put between the frame and the object.
21147 \framebox(width,height)[position]{...} *\picture-framebox*
21148 The |\framebox| command is exactly the same as the
21149 |picture-makebox| command, except that it puts a frame around
21150 the outside of the box that it creates. The |\framebox|
21151 command produces a rule of thickness |\fboxrule|, and leaves a
21152 space |\fboxsep| between the rule and the contents of the box.
21154 \line(x slope,y slope){length} *\line*
21155 Draws a line of the specified length and slope.
21156 Note: LaTeX can only draw lines with slope = x/y, where x and
21157 y have integer values from -6 through 6.
21159 \linethickness{dimension} *\linethickness*
21160 Declares the thickness of horizontal and vertical lines in a
21161 |picture| environment to be dimension, which must be a
21162 positive length. It does not affect the thickness of slanted
21163 lines (|\line|) and circles (|circle|), or the quarter circles
21164 drawn by |\oval| to form the corners of an oval.
21166 \makebox(width,height)[position]{...} *picture-makebox*
21167 The makebox command for the |picture| environment is similar
21168 to the normal |\makebox| command except that you must specify
21169 a width and height in multiples of |\unitlength|.
21170 The optional argument, [position], specifies the quadrant that
21171 your text appears in. You may select up to two of the
21173 t - Moves the item to the top of the rectangle
21174 b - Moves the item to the bottom
21175 l - Moves the item to the left
21176 r - Moves the item to the right
21179 \multiput(x coord,y coord)(delta x,delta y){no of copies}{object}
21180 This command can be used when you are putting the same
21181 object in a regular pattern across a picture.
21183 \oval(width,height)[portion] *\oval*
21184 Produces a rectangle with rounded corners. The optional
21185 argument, [portion], allows you to select part of the oval.
21190 Note: the "corners" of the oval are made with quarter circles
21191 with a maximum radius of 20 pt, so large "ovals" will look
21192 more like boxes with rounded corners.
21194 \put(x coord,y coord){ ... } *\put*
21195 Places the item specified by the mandatory argument at the
21198 \shortstack[position]{... \\ ... \\ ...} *\shortstack*
21199 The |\shortstack| command produces a stack of objects.
21200 The valid positions are:
21201 r - right of the stack
21202 l - left of the stack
21203 c - centre of the stack (default)
21205 \vector(x slope,y slope){length} *\vector*
21206 Draws a line with an arrow of the specified length and slope.
21207 The x and y values must lie between -4 and +4, inclusive.
21209 ==============================================================================
21210 o. quotation *quotation*
21216 The margins of the |quotation| environment are indented on the left and the
21217 right. The text is justified at both margins and there is paragraph
21218 indentation. Leaving a blank line between text produces a new paragraph.
21220 ==============================================================================
21227 The margins of the |quote-l| environment are indented on the left and the right.
21228 The text is justified at both margins. Leaving a blank line between text
21229 produces a new paragraph.
21231 ==============================================================================
21232 q. tabbing *tabbing*
21235 text \= more text \= still more text \= last text \\
21236 second row \> \> more \\
21242 The |tabbing| environment provides a way to align text in columns. It works by
21243 setting tab stops and tabbing to them much the way you do with an ordinary
21246 It is best suited for cases where the width of each column is constant and
21249 This environment can be broken across pages, unlike the |tabular| environment.
21250 The following commands can be used inside a tabbing environment:
21253 \= Sets a tab stop at the current position.
21256 \> Advances to the next tab stop.
21259 \< This command allows you to put something to the left of the
21260 local margin without changing the margin. Can only be used at
21261 the start of the line.
21264 \+ Moves the left margin of the next and all the following
21265 commands one tab stop to the right.
21268 \- Moves the left margin of the next and all the following
21269 commands one tab stop to the left.
21272 \' Moves everything that you have typed so far in the current
21273 column, i.e. everything from the most recent \> (|tab>|), \<
21274 (|tab<|), \' (|tab'|), |\\|, or |\kill| command, to the right
21275 of the previous column, flush against the current column's tab
21279 \` Allows you to put text flush right against any tab stop,
21280 including tab stop 0. However, it can't move text to the right
21281 of the last column because there's no tab stop there. The \`
21282 (|tab`|) command moves all the text that follows it, up to the
21283 |\\| or \end{tabbing} command that ends the line, to the right
21284 margin of the tabbing environment. There must be no \>
21285 (|tab>|) or \' (|tab'|) command between the \` (|tab`|) and
21286 the command that ends the line.
21289 \kill Sets tab stops without producing text. Works just like |\\|
21290 except that it throws away the current line instead of
21291 producing output for it. The effect of any \= (|tab=|), \+
21292 (|tab+|) or \- (|tab-|) commands in that line remain in
21296 \pushtabs Saves all current tab stop positions. Useful for temporarily
21297 changing tab stop positions in the middle of a tabbing
21298 environment. Also restores the tab stop positions saved by the
21302 \a In a tabbing environment, the commands \= (|tab=|), \'
21303 (|tab'|) and \` (|tab`|) do not produce accents as normal.
21304 Instead, the commands \a=, \a' and \a` are used.
21306 This example typesets a Pascal function in a traditional format:
21309 function \= fact(n : integer) : integer;\\
21311 \> if \= n $>$ 1 then \+ \\
21312 fact := n * fact(n-1) \- \\
21318 ==============================================================================
21321 \begin{table}[placement]
21323 \caption{table title}
21326 Tables are objects that are not part of the normal text, and are usually
21327 "floated" to a convenient place, like the top of a page. Tables will not be
21328 split between two pages.
21330 The optional argument [placement] determines where LaTeX will try to place
21331 your table. There are four places where LaTeX can possibly put a float:
21333 h (Here) at the position in the text where the table
21334 environment appears.
21335 t (Top) at the top of a text page.
21336 b (Bottom) at the bottom of a text page.
21337 p (Page of floats) on a separate float page, which is a page
21338 containing no text, only floats.
21340 The standard |report-class| and |article-class| use the default placement [tbp].
21342 The body of the table is made up of whatever text, LaTeX commands, etc., you
21345 The \caption command allows you to title your table.
21347 ==============================================================================
21348 s. tabular *tabular*
21350 \begin{tabular}[pos]{cols}
21351 column 1 entry & column 2 entry ... & column n entry \\
21359 \begin{tabular*}{width}[pos]{cols}
21360 column 1 entry & column 2 entry ... & column n entry \\
21366 These environments produce a box consisting of a sequence of rows of items,
21367 aligned vertically in columns. The mandatory and optional arguments consist
21370 {width} Specifies the width of the tabular* environment. There must be
21371 rubber space between columns that can stretch to fill out the
21374 [pos] Specifies the vertical position; default is alignment on the
21375 centre of the environment.
21376 t - align on top row
21377 b - align on bottom row
21379 {cols} Specifies the column formatting. It consists of a sequence of
21380 the following specifiers, corresponding to the sequence of
21381 columns and intercolumn material.
21382 l - A column of left-aligned items.
21384 r - A column of right-aligned items.
21386 c - A column of centred items.
21388 | - A vertical line the full height and depth of the
21391 @{text} - This inserts text in every row. An @-expression
21392 suppresses the intercolumn space normally inserted
21393 between columns; any desired space between the
21394 inserted text and the adjacent items must be included
21395 in text. An \extracolsep{wd} command in an
21396 @-expression causes an extra space of width {wd} to
21397 appear to the left of all subsequent columns, until
21398 countermanded by another |\extracolsep| command. Unlike
21399 ordinary intercolumn space, this extra space is not
21400 suppressed by an @-expression. An |\extracolsep|
21401 command can be used only in an @-expression in the
21404 p{wd} - Produces a column with each item typeset in a |\parbox|
21405 of width {wd}, as if it were the argument of a
21406 \parbox[t]{wd} command. However, a |\\| may not appear
21407 in the item, except in the following situations:
21408 1. inside an environment like |minipage|, |array|, or
21410 2. inside an explicit |\parbox|.
21411 3. in the scope of a |\centering|, |\raggedright|, or
21412 |\raggedleft| declaration. The latter declarations must
21413 appear inside braces or an environment when used in a
21416 {num}{cols} - Equivalent to num copies of cols, where num is any positive
21417 integer and cols is any list of column-specifiers,
21418 which may contain another -expression.
21420 These commands can be used inside a tabular environment:
21422 |\cline| Draw a horizontal line spanning some columns.
21423 |\hline| Draw a * horizontal line spanning all columns.
21424 |\multicolumn| Make an item spanning * several columns.
21425 |\vline| Draw a vertical line.
21428 \cline{i-j} *\cline*
21429 The |\cline| command draws horizontal lines across the columns
21430 specified, beginning in column i and ending in column j,
21431 which are identified in the mandatory argument.
21434 The |\hline| command will draw a horizontal line the width of
21435 the table. It's most commonly used to draw a line at the top,
21436 bottom, and between the rows of the table.
21438 \multicolumn{cols}{pos}{text} *\multicolumn*
21439 The |\multicolumn| is used to make an entry that spans several
21440 columns. The first mandatory argument, {cols}, specifies the
21441 number of columns to span. The second mandatory argument,
21442 {pos}, specifies the formatting of the entry:
21446 The third mandatory argument, {text}, specifies what text is
21447 to make up the entry.
21450 The |\vline| command will draw a vertical line extending the
21451 full height and depth of its row. An |\hfill| command can be
21452 used to move the line to the edge of the column. It can also
21453 be used in an @-expression.
21455 ==============================================================================
21456 t. thebibliography *\thebibliography*
21458 \begin{thebibliography}{widestlabel}
21459 \bibitem[label]{cite_key}
21463 \end{thebibliography}
21465 The |\thebibliography| environment produces a bibliography or reference list.
21467 In the |article-class|, this reference list is labelled "References"; in the
21468 |report-class|, it is labelled "Bibliography".
21470 {widestlabel} Text that, when printed, is approximately as wide as the
21471 widest item label produces by the |\bibitem| commands.
21473 |\bibitem| Specify a bibliography item.
21474 |\cite| Refer to a bibliography item.
21475 |\nocite| Include an item in the bibliography.
21476 |BibTeX| Automatic generation of bibliographies.
21478 \bibitem *\bibitem*
21479 \bibitem[label]{citekey}
21480 The |\bibitem| command generates an entry labelled by [label].
21481 If the [label] argument is missing, a number is generated as
21482 the label, using the |\enumi| counter. The {citekey} is any
21483 sequence of letters, numbers, and punctuation symbols not
21484 containing a comma. This command writes an entry on the `.aux'
21485 file containing {citekey} and the item's label. When this
21486 `.aux' file is read by the \begin{document} command, the
21487 item's label is associated with {citekey}, causing the
21488 reference to {citekey} by a |\cite| command to produce the
21492 \cite[text]{keylist}
21493 The {keylist} argument is a list of citation keys. This
21494 command generates an in-text citation to the references
21495 associated with the keys in {keylist} by entries on the `.aux'
21496 file read by the \begin{document} command.
21497 The optional text argument will appear after the
21500 < might produce `[Knuth, p. 2]'.
21504 The |\nocite| command produces no text, but writes
21505 {keylist}, which is a list of one or more citation
21506 keys, on the `.aux' file.
21508 BibTeX *BibTeX* *bibtex*
21509 *\bibliographystyle*
21510 If you use the BibTeX program by Oren Patashnik (highly recommended if you
21511 need a bibliography of more than a couple of titles) to maintain your
21512 bibliography, you don't use the |thebibliography| environment. Instead, you
21515 \bibliographystyle{style}
21516 \bibliography{bibfile}
21518 where {style} refers to a file style.bst, which defines how your citations
21519 will look. The standard styles distributed with BibTeX are:
21521 {alpha} Sorted alphabetically. Labels are formed from name of author and year
21523 {plain} Sorted alphabetically. Labels are numeric.
21524 {unsrt} Like plain, but entries are in order of citation.
21525 {abbrv} Like plain, but more compact labels.
21527 In addition, numerous other BibTeX style files exist tailored to the demands
21528 of various publications.
21531 The argument to |\bibliography| refers to the file bibfile.bib, which should
21532 contain your database in BibTeX format. Only the entries referred to via
21533 |\cite| and |\nocite| will be listed in the bibliography.
21535 ==============================================================================
21536 u. theorem *theorem*
21542 The |theorem| environment produces "Theorem x" in boldface followed by your
21545 ==============================================================================
21546 v. titlepage *titlepage*
21552 The |titlepage| environment creates a title page, i.e. a page with no printed
21553 page number or heading. It also causes the following page to be numbered page
21554 one. Formatting the title page is left to you. The |\today| command comes in
21555 handy for title pages.
21557 Note that you can use the |\maketitle| to produce a standard title page.
21559 ==============================================================================
21560 x. verbatim *verbatim*
21566 The |verbatim| environment is a paragraph-making environment that gets LaTeX
21567 to print exactly what you type in. It turns LaTeX into a typewriter with
21568 carriage returns and blanks having the same effect that they would on a
21572 \verb char literal_text char
21573 \verb*char literal_text char
21574 Typesets literal_text exactly as typed, including
21575 special characters and spaces, using a typewriter |\tt|
21576 type style. There may be no space between |\verb| or
21577 |\verb|* and char (space is shown here only for
21578 clarity). The *-form differs only in that spaces are
21579 printed as `\verb*| |\'.
21581 ==============================================================================
21588 The |verse| environment is designed for poetry, though you may find other uses
21591 The margins are indented on the left and the right. Separate the lines of each
21592 stanza with |\\|, and use one or more blank lines to separate the stanzas.
21594 ==============================================================================
21595 8. Footnotes *latex-footnotes*
21597 Footnotes can be produced in one of two ways. They can be produced with one
21598 command, the |\footnote| command. They can also be produced with two commands,
21599 the |\footnotemark| and the |\footnotetext| commands. See the specific command for
21600 information on why you would use one over the other.
21602 |\footnote| Insert a footnote
21603 |\footnotemark| Insert footnote mark only
21604 |\footnotetext| Insert footnote text only
21606 \footnote[number]{text} *\footnote*
21607 Command places the numbered footnote text at the bottom of the
21608 current page. The optional argument, number, is used to change
21609 the default footnote number. This command can only be used in
21610 outer paragraph mode; i.e., you cannot use it in sectioning
21611 commands like |\chapter|, in |\figure|, |\table| or in a
21612 |\tabular| environment.
21614 \footnotemark *\footnotemark*
21615 Command puts the footnote number in the text. This command can
21616 be used in inner paragraph mode. The text of the footnote is
21617 supplied by the |\footnotetext| command.
21618 This command can be used to produce several consecutive
21619 footnote markers referring to the same footnote by using
21621 \footnotemark[\value{footnote}]
21623 after the first |\footnote| command.
21625 \footnotetext[number]{text} *\footnotetext*
21626 Command produces the text to be placed at the bottom of the
21627 page. This command can come anywhere after the |\footnotemark|
21628 command. The |\footnotetext| command must appear in outer
21629 paragraph mode. The optional argument, number, is used to
21630 change the default footnote number.
21632 ==============================================================================
21633 9. Lengths *latex-lengths*
21635 A length is a measure of distance. Many LaTeX commands take a length as an
21638 |\newlength| Define a new length.
21639 |\setlength| Set the value of a length.
21640 |\addtolength| Add a quantity to a length.
21641 |\settodepth| Set a length to the depth of something.
21642 |\settoheight| Set a length to the height of something.
21643 |\settowidth| Set a length to the width of something.
21644 |pre-lengths| Lengths that are, like, predefined.
21646 \newlength{\gnat} *\newlength*
21647 The |\newlength| command defines the mandatory argument, \gnat,
21648 as a length command with a value of 0in. An error occurs if a
21649 \gnat command already exists.
21651 \setlength{\gnat}{length} *\setlength*
21652 The |\setlength| command is used to set the value of a \gnat
21653 command. The {length} argument can be expressed in any terms
21654 of length LaTeX understands, i.e., inches (in), millimetres
21655 (mm), points (pt), etc.
21657 \addtolength{\gnat}{length} *\addtolength*
21658 The |\addtolength| command increments a \gnat by the amount
21659 specified in the {length} argument. It can be a negative
21662 \settodepth{\gnat}{text} *\settodepth*
21663 The |\settodepth| command sets the value of a \gnat command
21664 equal to the depth of the {text} argument.
21666 \settoheight{\gnat}{text} *\settoheight*
21667 The |\settoheight| command sets the value of a \gnat command
21668 equal to the height of the {text} argument.
21670 \settowidth{\gnat}{text} *\settowidth*
21671 The |\settowidth| command sets the value of a \gnat command
21672 equal to the width of the {text} argument.
21674 Predefined lengths *pre-lengths*
21679 \totalheight *\totalheight*
21680 These length parameters can be used in the arguments of the
21681 box-making commands See section Spaces & Boxes. They specify
21682 the natural width etc. of the text in the box.
21683 \totalheight equals \height + \depth.
21684 To make a box with the text stretched to double the natural
21686 \makebox[2\width]{Get a stretcher}
21688 ==============================================================================
21689 10. Letters *latex-letters*
21691 You can use LaTeX to typeset letters, both personal and business. The letter
21692 document class is designed to make a number of letters at once, although you
21693 can make just one if you so desire.
21695 Your `.tex' source file has the same minimum commands as the other document
21696 classes, i.e., you must have the following commands as a minimum: >
21697 \documentclass{letter}
21704 Each letter is a letter environment, whose argument is the name and address of
21705 the recipient. For example, you might have: >
21708 2345 Princess St. \\
21709 Edinburgh, EH1 1AA}
21713 The letter itself begins with the |\opening| command. The text of the letter
21714 follows. It is typed as ordinary LaTeX input. Commands that make no sense in
21715 a letter, like |\chapter|, do not work. The letter closes with a |\closing|
21718 After the closing, you can have additional material. The |\cc| command produces
21719 the usual "cc: ...". There's also a similar |\encl| command for a list of
21720 enclosures. With both these commands, use|\\| to separate the items.
21722 These commands are used with the letter class:
21723 |\address| Your return address.
21724 |\cc| Cc list. closing Saying goodbye.
21725 |\encl| List of enclosed material.
21726 |\location| Your organisation's address.
21727 |\makelabels| Making address labels.
21728 |\name| Your name, for the return address.
21729 |\opening| Saying hello.
21730 |\ps| Adding a postscript.
21731 |\signature| Your signature.
21732 |\startbreaks| Allow page breaks.
21733 |\stopbreaks| Disallow page breaks.
21734 |\telephone| Your phone number.
21736 \address{Return address} *\address*
21737 The return address, as it should appear on the letter and the
21738 envelope. Separate lines of the address should be separated
21739 by |\\| commands. If you do not make an |\address| declaration,
21740 then the letter will be formatted for copying onto your
21741 organisation's standard letterhead. (See section Overview of
21742 LaTeX and Local Guide, for details on your local
21743 implementation). If you give an |\address| declaration, then
21744 the letter will be formatted as a personal letter.
21746 \cc{Kate Schechter\\Rob McKenna} *\cc*
21747 Generate a list of other persons the letter was sent to. Each
21748 name is printed on a separate line.
21750 \closing{text} *\closing*
21751 The letter closes with a |\closing| command, i.e., >
21752 \closing{Best Regards,} \encl{CV\\Certificates}
21753 < Generate a list of enclosed material.
21755 \location{address} *\location*
21756 This modifies your organisation's standard address. This only
21757 appears if the firstpage pagestyle is selected.
21759 \makelabels{number} *\makelabels*
21760 If you issue this command in the preamble, LaTeX will create a
21761 sheet of address labels. This sheet will be output before the
21764 \name{June Davenport} *\name*
21765 Your name, used for printing on the envelope together with the
21768 \opening{text} *\opening*
21769 The letter begins with the |\opening| command. The mandatory
21770 argument, text, is whatever text you wish to start your
21772 \opening{Dear Joe,}
21775 Use this command before a postscript.
21777 \signature{Harvey Swick} *\signature*
21778 Your name, as it should appear at the end of the letter
21779 underneath the space for your signature. Items that should go
21780 on separate lines should be separated by |\\| commands.
21782 \startbreaks *\startbreaks*
21783 Used after a |\stopbreaks| command to allow page breaks again.
21785 \stopbreaks *\stopbreaks*
21786 Inhibit page breaks until a |\startbreaks| command occurs.
21788 \telephone{number} *\telephone*
21789 This is your telephone number. This only appears if the
21790 firstpage pagestyle is selected.
21792 ==============================================================================
21793 11. Line & Page Breaking *latex-breaking*
21795 The first thing LaTeX does when processing ordinary text is to translate your
21796 input file into a string of glyphs and spaces. To produce a printed document,
21797 this string must be broken into lines, and these lines must be broken into
21798 pages. In some environments, you do the line breaking yourself with the |\\|
21799 command, but LaTeX usually does it for you.
21801 |\\| Start a new line
21802 |hyph-| Insert explicit hyphenation
21803 |\cleardoublepage| Start a new right-hand page
21804 |\clearpage| Start a new page
21805 |\enlargethispage| Enlarge the current page a bit
21806 |\fussy| Be fussy about line breaking
21807 |\hyphenation| Tell LaTeX how to hyphenate a word
21808 |\linebreak| Break the line
21809 |\newline| Break the line prematurely
21810 |\newpage| Start a new page
21811 |\nolinebreak| Don't break the current line
21812 |\nopagebreak| Don't make a page break here
21813 |\pagebreak| Please make a page break here
21814 |\sloppy| Be sloppy about line breaking
21816 \\[*][extraspace] *\\* *\\\\*
21817 The |\\| command tells LaTeX to start a new line. It has an
21818 optional argument, [extraspace], that specifies how much extra
21819 vertical space is to be inserted before the next line. This
21820 can be a negative amount.
21821 The \\* command is the same as the ordinary |\\| command
21822 except that it tells LaTeX not to start a new page after the
21826 The \- command tells LaTeX that it may hyphenate the word at
21827 that point. LaTeX is very good at hyphenating, and it will
21828 usually find all correct hyphenation points. The \- command is
21829 used for the exceptional cases.
21830 Note: when you insert \- commands in a word, the word will
21831 only be hyphenated at those points and not at any of the
21832 hyphenation points that LaTeX might otherwise have chosen.
21834 \cleardoublepage *\cleardoublepage*
21835 The |\cleardoublepage| command ends the current page and causes
21836 all figures and tables that have so far appeared in the input
21837 to be printed. In a two-sided printing style (|twoside|), it
21838 also makes the next page a right-hand (odd-numbered) page,
21839 producing a blank page if necessary.
21841 \clearpage *\clearpage*
21842 The |\clearpage| command ends the current page and causes all
21843 figures and tables that have so far appeared in the input to
21846 \enlargethispage{size} *\enlargethispage*
21847 \enlargethispage*{size}
21848 Enlarge the textheight for the current page by the
21849 specified amount; e.g.: >
21851 \enlargethispage{\baselineskip}
21853 will allow one additional line. The starred form
21854 tries to squeeze the material together on the page as
21855 much as possible. This is normally used together with
21856 an explicit |\pagebreak|.
21859 This declaration (which is the default) makes TeX more fussy
21860 about line breaking. This can avoids too much space between
21861 words, but may produce overfull boxes. This command cancels
21862 the effect of a previous |\sloppy| command.
21864 \hyphenation{words} *\hyphenation*
21865 The |\hyphenation| command declares allowed hyphenation points,
21866 where words is a list of words, separated by spaces, in which
21867 each hyphenation point is indicated by a - character.
21869 \linebreak[number] *\linebreak*
21870 The |\linebreak| command tells LaTeX to break the current line
21871 at the point of the command. With the optional argument,
21872 number, you can convert the |\linebreak| command from a demand
21873 to a request. The [number] must be a number from 0 to 4. The
21874 higher the number, the more insistent the request is. The
21875 |\linebreak| command causes LaTeX to stretch the line so it
21876 extends to the right margin.
21878 \newline *\newline*
21879 The |\newline| command breaks the line right where it is. It
21880 can only be used in paragraph mode.
21882 \newpage *\newpage*
21883 The |\newpage| command ends the current page.
21885 \nolinebreak[number] *\nolinebreak*
21886 The |\nolinebreak| command prevents LaTeX from breaking the
21887 current line at the point of the command. With the optional
21888 argument, [number], you can convert the |\nolinebreak| command
21889 from a demand to a request. The [number] must be a number from 0
21890 to 4. The higher the number, the more insistent the request
21893 \nopagebreak[number] *\nopagebreak*
21894 The |\nopagebreak| command prevents LaTeX from breaking the
21895 current page at the point of the command. With the optional
21896 argument, [number], you can convert the |\nopagebreak| command
21897 from a demand to a request. The [number] must be a number from
21898 0 to 4. The higher the number, the more insistent the request
21901 \pagebreak[number] *\pagebreak*
21902 The |\pagebreak| command tells LaTeX to break the current page
21903 at the point of the command. With the optional argument,
21904 [number], you can convert the |\pagebreak| command from a
21905 demand to a request. The [number] must be a number from 0 to
21906 4. The higher the number, the more insistent the request is.
21909 This declaration makes TeX less fussy about line breaking.
21910 This can prevent overfull boxes, but may leave too much space
21912 Lasts until a |\fussy| command is issued.
21914 ==============================================================================
21915 12. Making Paragraphs *latex-paragraphs*
21917 A paragraph is ended by one or more completely blank lines -- lines not
21918 containing even a |\%|. A blank line should not appear where a new paragraph
21919 cannot be started, such as in math mode or in the argument of a sectioning
21922 |\indent| Indent this paragraph.
21923 |\noindent| Do not indent this paragraph.
21924 |\par| Another way of writing a blank line.
21927 This produces a horizontal space whose width equals the width
21928 of the paragraph indentation. It is used to add paragraph
21929 indentation where it would otherwise be suppressed.
21931 \noindent *\noindent*
21932 When used at the beginning of the paragraph, it suppresses the
21933 paragraph indentation. It has no effect when used in the
21934 middle of a paragraph.
21937 Equivalent to a blank line; often used to make command or
21938 environment definitions easier to read.
21940 ==============================================================================
21941 13. Margin Notes *latex-margin-notes*
21943 \marginpar[left]{right} *\marginpar*
21944 This command creates a note in the margin. The first line will
21945 be at the same height as the line in the text where the
21946 |\marginpar| occurs.
21948 When you only specify the mandatory argument {right}, the text
21950 * in the right margin for one-sided layout
21951 * in the outside margin for two-sided layout (|twoside|)
21952 * in the nearest margin for two-column layout (|twocolumn|)
21954 \reversemarginpar *\reversemarginpar*
21955 By issuing the command |\reversemarginpar|, you can force the
21956 marginal notes to go into the opposite (inside) margin.
21958 When you specify both arguments, left is used for the left margin, and right
21959 is used for the right margin.
21961 The first word will normally not be hyphenated; you can enable hyphenation by
21962 prefixing the first word with a \hspace{0pt} command (|hspace|).
21964 ==============================================================================
21965 14. Math Formulae *latex-math*
21967 There are three environments (|latex-environments|) that put LaTeX in math
21969 |math| For Formulae that appear right in the text.
21970 |displaymath| For Formulae that appear on their own line.
21971 |equation| The same as the displaymath environment except that it adds an
21972 equation number in the right margin.
21974 The |math| environment can be used in both paragraph and LR mode, but the
21975 |displaymath| and |equation| environments can be used only in paragraph mode. The
21976 |math| and |displaymath| environments are used so often that they have the
21977 following short forms:
21978 \(...\) instead of \begin{math}...\end{math}
21979 \[...\] instead of \begin{displaymath}...\end{displaymath}
21981 In fact, the math environment is so common that it has an even shorter form:
21982 $ ... $ instead of \(...\)
21984 |sub-sup| Also known as exponent or index.
21985 |math-symbols| Various mathematical squiggles.
21986 |math-spacing| Thick, medium, thin and negative spaces.
21987 |math-misc| Stuff that doesn't fit anywhere else.
21990 Subscripts & Superscripts *sub-sup*
21991 *subscripts* *superscripts*
21993 To get an expression exp to appear as a subscript, you just type _{exp}. To
21994 get exp to appear as a superscript, you type ^{exp}. LaTeX handles
21995 superscripted superscripts and all of that stuff in the natural way. It even
21996 does the right thing when something has both a subscript and a superscript.
21999 Math Symbols *math-symbols*
22001 LaTeX provides almost any mathematical symbol you're likely to need. The
22002 commands for generating them can be used only in math mode. For example, if
22005 in your source, you will get the symbol in your output.
22008 Spacing in Math Mode *math-spacing*
22010 In a math environment, LaTeX ignores the spaces you type and puts in the
22011 spacing that it thinks is best. LaTeX formats mathematics the way it's done in
22012 mathematics texts. If you want different spacing, LaTeX provides the following
22013 four commands for use in math mode:
22014 \; - a thick space *math;*
22015 \: - a medium space *math:*
22016 \, - a thin space *math,*
22017 \! - a negative thin space *math!*
22020 Math Miscellany *math-misc*
22023 Produces a horizontal ellipsis where the dots are raised to
22024 the centre of the line.
22026 Produces a diagonal ellipsis.
22027 \frac{num}{den} *\frac*
22028 Produces the fraction num divided by den.
22030 Produces an ellipsis. This command works in any mode, not just
22032 \overbrace{text} *\overbrace*
22033 Generates a brace over text.
22034 \overline{text} *\overline*
22035 Causes the argument text to be overlined.
22036 \sqrt[root]{arg} *\sqrt*
22037 Produces the square root of its argument. The optional
22038 argument, [root], determines what root to produce, i.e., the
22039 cube root of x+y would be typed as: >
22041 \underbrace{text} *\underbrace*
22042 Generates text with a brace underneath.
22043 \underline{text} *\underline*
22044 Causes the argument text to be underlined. This command can
22045 also be used in paragraph and LR mode.
22047 Produces a vertical ellipsis.
22049 ==============================================================================
22050 15. Modes *latex-modes*
22052 When LaTeX is processing your input text, it is always in one of three modes:
22053 Paragraph mode *paragraph-mode*
22054 Math mode *math-mode*
22055 Left-to-right mode, called LR mode for short. *lr-mode*
22057 LaTeX changes mode only when it goes up or down a staircase to a different
22058 level, though not all level changes produce mode changes. Mode changes occur
22059 only when entering or leaving an environment, or when LaTeX is processing the
22060 argument of certain text-producing commands.
22062 |paragraph-mode| is the most common; it's the one LaTeX is in when processing
22063 ordinary text. In that mode, LaTeX breaks your text into lines and breaks the
22064 lines into pages. LaTeX is in |math-mode| when it's generating a mathematical
22065 formula. In |lr-mode|, as in |paragraph-mode|, LaTeX considers the output that
22066 it produces to be a string of words with spaces between them. However, unlike
22067 |paragraph-mode|, LaTeX keeps going from left to right; it never starts a new
22068 line in |lr-mode|. Even if you put a hundred words into an |\mbox|, LaTeX would
22069 keep typesetting them from left to right inside a single box, and then
22070 complain because the resulting box was too wide to fit on the line.
22072 LaTeX is in |lr-mode| when it starts making a box with an |\mbox| command. You
22073 can get it to enter a different mode inside the box - for example, you can
22074 make it enter |math-mode| to put a formula in the box. There are also several
22075 text-producing commands and environments for making a box that put LaTeX in
22076 |paragraph-mode|. The box make by one of these commands or environments will be
22077 called a |\parbox|. When LaTeX is in |paragraph-mode| while making a box, it is
22078 said to be in "inner paragraph mode". Its normal |paragraph-mode|, which it
22079 starts out in, is called "outer paragraph mode".
22081 ==============================================================================
22082 16. Page Styles *latex-page-styles*
22084 The |\documentclass| command determines the size and position of the page's head
22085 and foot. The page style determines what goes in them.
22087 |\maketitle| Generate a title page.
22088 |\pagenumbering| Set the style used for page numbers.
22089 |\pagestyle| Change the headings/footings style.
22090 |\thispagestyle| Change the headings/footings style for this page.
22092 \maketitle *\maketitle*
22093 The |\maketitle| command generates a title on a separate title
22094 page - except in the |\article| class, where the title normally
22095 goes at the top of the first page. Information used to
22096 produce the title is obtained from the following declarations:
22098 |\author| Who wrote this stuff?
22099 |\date| The date the document was created.
22100 |\thanks| A special form of footnote.
22101 |\title| How to set the document title.
22103 \author{names} *\author* *\and*
22104 The |\author| command declares the author(s), where
22105 names is a list of authors separated by \and commands.
22106 Use |\\| to separate lines within a single author's
22107 entry -- for example, to give the author's institution
22110 \date{text} *\date*
22111 The |\date| command declares text to be the document's
22112 date. With no |\date| command, the current date is
22115 \thanks{text} *\thanks*
22116 The |\thanks| command produces a |\footnote| to the
22119 \title{text} *\title*
22120 The |\title| command declares text to be the title. Use
22121 |\\| to tell LaTeX where to start a new line in a long
22124 \pagenumbering{numstyle} *\pagenumbering*
22125 Specifies the style of page numbers. Possible values of
22127 arabic - Arabic numerals *arabic*
22128 roman - Lowercase Roman numerals *roman*
22129 Roman - Uppercase Roman numerals *Roman*
22130 alph - Lowercase letters *alph*
22131 Alph - Uppercase letters *Alph*
22133 \pagestyle{option} *\pagestyle*
22134 *plain* *empty* *headings*
22135 The |\pagestyle| command changes the style from the current
22136 page on throughout the remainder of your document.
22137 The valid options are:
22138 plain - Just a plain page number.
22139 empty - Produces empty heads and feet no page numbers.
22140 headings - Puts running headings on each page. The document
22141 style specifies what goes in the headings.
22142 myheadings - You specify what is to go in the heading with the
22143 |\markboth| or the |\markright| commands.
22145 |\markboth| Set left and right headings.
22146 |\markright| Set right heading only.
22148 \markboth{left head}{right head} *\markboth*
22149 The |\markboth| command is used in conjunction with the
22150 page style myheadings for setting both the left and
22152 Note that a "left-hand heading" is generated by the
22153 last |\markboth| command before the end of the page,
22154 while a "right-hand heading" is generated by the first
22155 |\markboth| or |\markright| that comes on the page if
22156 there is one, otherwise by the last one before the
22160 \markright{right head} *\markright*
22161 The |\markright| command is used in conjunction with
22162 the page style |\myheadings| for setting the right
22163 heading, leaving the left heading unchanged.
22164 Note that a "left-hand heading" is generated by the
22165 last |\markboth| command before the end of the page,
22166 while a "right-hand heading" is generated by the first
22167 |\markboth| or |\markright| that comes on the page if
22168 there is one, otherwise by the last one before the
22171 \thispagestyle{option} *\thispagestyle*
22172 The |\thispagestyle| command works in the same manner as the
22173 |\pagestyle| command except that it changes the style for the
22176 ==============================================================================
22177 17. Sectioning *latex-sectioning*
22179 Sectioning commands provide the means to structure your text into units.
22181 |\chapter| (report and book class only)
22188 All sectioning commands take the same general form, i.e.,
22191 *\chapter* (report and book class only)
22192 *\section* *\subsection* *\subsubsection*
22193 *\paragraph* *\subparagraph*
22194 \chapter[optional]{title}
22195 In addition to providing the heading in the text, the
22196 mandatory argument of the sectioning command can appear in two
22198 1. The table of contents
22199 2. The running head at the top of the page. You may not want
22200 the same thing to appear in these other two places as
22201 appears in the text heading. To handle this situation, the
22202 sectioning commands have an optional argument that provides
22203 the text for these other two purposes.
22205 All sectioning commands have *\-forms that print a title, but do not include a
22206 number and do not make an entry in the table of contents.
22208 \appendix *\appendix*
22209 The |\appendix| command changes the way sectional units are
22210 numbered. The |\appendix| command generates no text and does
22211 not affect the numbering of parts. The normal use of this
22212 command is something like: >
22213 \chapter{The First Chapter}
22215 \appendix \chapter{The First Appendix}
22218 ==============================================================================
22219 18. Spaces & Boxes *latex-spaces-boxes*
22221 All the predefined length parameters See section Predefined lengths can be
22222 used in the arguments of the box-making commands.
22226 |\dotfill| Stretchable horizontal dots.
22227 |\hfill| Stretchable horizontal space.
22228 |\hrulefill| Stretchable horizontal rule.
22229 |\hspace| Fixed horizontal space.
22233 |\addvspace| Fixed vertical space.
22234 |\bigskip| Fixed vertical space.
22235 |\medskip| Fixed vertical space.
22236 |\smallskip| Fixed vertical space.
22237 |\vfill| Stretchable vertical space.
22238 |\vspace| Fixed vertical space.
22243 |\framebox| Framebox, adjustable position.
22244 |\lrbox| An environment like |\sbox|.
22245 |\makebox| Box, adjustable position.
22247 |\newsavebox| Declare a name for saving a box.
22248 |\parbox| Box with text in paragraph mode.
22249 |\raisebox| Raise or lower text.
22250 |\rule| Lines and squares.
22251 |\savebox| Like |\makebox|, but save the text for later use.
22252 |\sbox| Like |\mbox|, but save the text for later use.
22253 |\usebox| Print saved text.
22255 Horizontal space: *latex-hor-space*
22257 LaTeX removes horizontal space that comes at the end of a line. If you don't
22258 want LaTeX to remove this space, include the optional * argument. Then the
22259 space is never removed.
22261 \dotfill *\dotfill*
22262 The |\dotfill| command produces a "rubber length" that produces
22263 dots instead of just spaces.
22266 The |\hfill| fill command produces a "rubber length" which can
22267 stretch or shrink horizontally. It will be filled with spaces.
22269 \hrulefill *\hrulefill*
22270 The |\hrulefill| fill command produces a "rubber length" which
22271 can stretch or shrink horizontally. It will be filled with a
22274 \hspace[*]{length} *\hspace*
22275 The |\hspace| command adds horizontal space. The length of the
22276 space can be expressed in any terms that LaTeX understands,
22277 i.e., points, inches, etc. You can add negative as well as
22278 positive space with an |\hspace| command. Adding negative space
22279 is like backspacing.
22282 Vertical space: *latex-ver-space*
22284 LaTeX removes vertical space that comes at the end of a page. If you don't
22285 want LaTeX to remove this space, include the optional * argument. Then the
22286 space is never removed.
22288 \addvspace{length} *\addvspace*
22289 The |\addvspace| command normally adds a vertical space of
22290 height length. However, if vertical space has already been
22291 added to the same point in the output by a previous
22292 |\addvspace| command, then this command will not add more space
22293 than needed to make the natural length of the total vertical
22294 space equal to length.
22296 \bigskip *\bigskip*
22297 The |\bigskip| command is equivalent to \vspace{bigskipamount}
22298 where bigskipamount is determined by the document class.
22300 \medskip *\medskip*
22301 The |\medskip| command is equivalent to \vspace{medskipamount}
22302 where medskipamount is determined by the document class.
22304 \smallskip *\smallskip*
22305 The |\smallskip| command is equivalent to
22306 \vspace{smallskipamount} where smallskipamount is determined
22307 by the document class.
22310 The |\vfill| fill command produces a rubber length which can
22311 stretch or shrink vertically.
22313 \vspace[*]{length} *\vspace*
22314 The |\vspace| command adds vertical space. The length of the
22315 space can be expressed in any terms that LaTeX understands,
22316 i.e., points, inches, etc. You can add negative as well as
22317 positive space with an |\vspace| command.
22320 Boxes: *latex-boxes*
22322 \fbox{text} *\fbox*
22323 The |\fbox| command is exactly the same as the |\mbox| command,
22324 except that it puts a frame around the outside of the box that
22327 \framebox[width][position]{text} *\framebox*
22328 The |\framebox| command is exactly the same as the |\makebox|
22329 command, except that it puts a frame around the outside of the
22330 box that it creates.
22331 The |\framebox| command produces a rule of thickness
22332 |\fboxrule|, and leaves a space |\fboxsep| between the rule and
22333 the contents of the box.
22336 \begin{lrbox}{cmd} text \end{lrbox}
22337 This is the environment form of |\sbox|.
22338 The text inside the environment is saved in the box cmd, which
22339 must have been declared with |\newsavebox|.
22341 \makebox[width][position]{text} *\makebox*
22342 The |\makebox| command creates a box just wide enough to
22343 contain the text specified. The width of the box is specified
22344 by the optional [width] argument. The position of the text
22345 within the box is determined by the optional [position]
22347 c -- centred (default)
22350 s -- stretch from left to right margin. The text must
22351 contain stretchable space for this to work.
22352 See section |\picture-makebox|.
22354 \mbox{text} *\mbox*
22355 The |\mbox| command creates a box just wide enough to hold the
22356 text created by its argument.
22357 Use this command to prevent text from being split across
22360 \newsavebox{cmd} *\newsavebox*
22361 Declares {cmd}, which must be a command name that is not
22362 already defined, to be a bin for saving boxes.
22365 \parbox[position][height][innerpos]{width}{text} *\parbox*
22366 A parbox is a box whose contents are created in
22367 |\paragraph-mode|. The |\parbox| has two
22369 Mandatory arguments:
22370 'width' specifies the width of the parbox
22371 'text' the text that goes inside the parbox.
22373 Optional arguments:
22374 'position' LaTeX will position a parbox so its centre lines up with the
22375 centre of the text line. The optional position argument allows
22376 you to line up either the top or bottom line in the parbox
22379 'height' If the height argument is not given, the box will have the
22380 natural height of the text.
22382 'innerpos' The inner-pos argument controls the placement of the text
22383 inside the box. If it is not specified, position is used.
22384 t -- text is placed at the top of the box
22385 c -- text is centred in the box
22386 b -- text is placed at the bottom of the box
22387 s -- stretch vertically. The text must contain
22388 vertically stretchable space for this to work.
22390 A |\parbox| command is used for a parbox containing a small
22391 piece of text, with nothing fancy inside. In particular, you
22392 shouldn't use any of the paragraph-making environments inside
22393 a |\parbox| argument. For larger pieces of text, including ones
22394 containing a paragraph-making environment, you should use a
22395 |\minipage| environment.
22397 \raisebox{distance}[extendabove][extendbelow]{text} *\raisebox*
22398 The |\raisebox| command is used to raise or lower text. The
22399 first mandatory argument specifies how high the text is to be
22400 raised (or lowered if it is a negative amount). The text
22401 itself is processed in LR mode.
22402 Sometimes it's useful to make LaTeX think something has a
22403 different size than it really does - or a different size than
22404 LaTeX would normally think it has. The |\raisebox| command
22405 lets you tell LaTeX how tall it is.
22406 The first optional argument, extend-above, makes LaTeX think
22407 that the text extends above the line by the amount specified.
22408 The second optional argument, extend-below, makes LaTeX think
22409 that the text extends below the line by the amount specified.
22411 \rule[raiseheight]{width}{thickness} *\rule*
22412 The |\rule| command is used to produce horizontal lines. The
22413 arguments are defined as follows:
22414 'raiseheight' specifies how high to raise the rule (optional)
22415 'width' specifies the length of the rule (mandatory)
22416 'thickness' specifies the thickness of the rule (mandatory)
22418 \savebox{cmd}[width][pos]{text} *\savebox*
22419 This command typeset text in a box just as for |\makebox|.
22420 However, instead of printing the resulting box, it saves it in
22421 bin cmd, which must have been declared with |\newsavebox|.
22423 \sbox{text} *\sbox*
22424 This commands typeset text in a box just as for |\mbox|.
22425 However, instead of printing the resulting box, it saves it in
22426 bin cmd, which must have been declared with |\newsavebox|.
22428 \usebox{cmd} *\usebox*
22429 Prints the box most recently saved in bin cmd by a |\savebox|
22432 ==============================================================================
22433 19. Special Characters *latex-special*
22435 The following characters play a special role in LaTeX and are called "special
22436 printing characters", or simply "special characters". >
22437 # $ % & ~ _ ^ \ { }
22438 Whenever you put one of these special characters into your file, you are doing
22439 something special. If you simply want the character to be printed just as any
22440 other letter, include a \ in front of the character. For example, \$ will
22441 produce $ in your output.
22443 One exception to this rule is the \ itself because |\\| has its own special
22444 meaning. A \ is produced by typing $\backslash$ in your file.
22446 Also, \~ means `place a tilde accent over the following letter', so you will
22447 probably want to use |\verb| instead.
22449 In addition, you can access any character of a font once you know its number
22450 by using the |\symbol| command. For example, the character used for displaying
22451 spaces in the |\verb|* command has the code decimal 32, so it can be typed as
22454 You can also specify octal numbers with ' or hexadecimal numbers with ", so
22455 the previous example could also be written as \symbol{'40} or \symbol{"20}.
22457 ==============================================================================
22458 20. Splitting the Input *latex-inputting*
22460 A large document requires a lot of input. Rather than putting the whole input
22461 in a single large file, it's more efficient to split it into several smaller
22462 ones. Regardless of how many separate files you use, there is one that is the
22463 root file; it is the one whose name you type when you run LaTeX.
22465 |\include| Conditionally include a file
22466 |\includeonly| Determine which files are included
22467 |\input| Unconditionally include a file
22469 \include{file} *\include*
22470 The \include command is used in conjunction with the
22471 |\includeonly| command for selective inclusion of
22472 files. The file argument is the first name of a file,
22473 denoting `file.tex' . If file is one the file names in
22474 the file list of the |\includeonly| command or if there
22475 is no |\includeonly| command, the \include command is
22477 \clearpage \input{file} \clearpage
22479 except that if the file `file.tex' does not exist,
22480 then a warning message rather than an error is
22481 produced. If the file is not in the file list, the
22482 \include command is equivalent to |\clearpage|.
22484 The |\include| command may not appear in the preamble or in a
22485 file read by another |\include| command.
22487 \includeonly{filelist} *\includeonly*
22488 The |\includeonly| command controls which files will be read in
22489 by an |\include| command. {filelist} should be a
22490 comma-separated list of filenames. Each filename must match
22491 exactly a filename specified in a |\include| command. This
22492 command can only appear in the preamble.
22494 \input{file} *\input*
22495 The |\input| command causes the indicated file to be read and
22496 processed, exactly as if its contents had been inserted in the
22497 current file at that point. The file name may be a complete
22498 file name with extension or just a first name, in which case
22499 the file `file.tex' is used.
22500 ==============================================================================
22501 21. Starting & Ending *latex-start-end*
22503 Your input file must contain the following commands as a minimum:
22504 \documentclass{class} |\documentclass|
22505 \begin{document} |\begin|
22506 ... your text goes here ...
22507 \end{document} |\end|
22509 where the class selected is one of the valid classes for LaTeX.
22510 See |\classes|for details of the various document classes.
22512 You may include other LaTeX commands between the |\documentclass| and the
22513 \begin{document} commands (i.e., in the `preamble').
22514 ==============================================================================
22515 22. Table of Contents *latex-toc*
22518 A table of contents is produced with the |\tableofcontents| command. You put
22519 the command right where you want the table of contents to go; LaTeX does the
22520 rest for you. It produces a heading, but it does not automatically start a new
22521 page. If you want a new page after the table of contents, include a |\newpage|
22522 command after the |\tableofcontents| command.
22524 *\listoffigures* *\listoftables*
22525 There are similar commands |\listoffigures| and |\listoftables| for producing a
22526 list of figures and a list of tables, respectively. Everything works exactly
22527 the same as for the table of contents.
22530 NOTE: If you want any of these items to be generated, you cannot have the
22531 \nofiles command in your document.
22533 |\addcontentsline| Add an entry to table of contents etc.
22534 |\addtocontents| Add text directly to table of contents file etc.
22536 \addcontentsline{file}{secunit}{entry} *\addcontentsline*
22537 The |\addcontentsline| command adds an entry to the specified
22538 list or table where:
22539 {file} is the extension of the file on which information is to be
22541 toc (table of contents),
22542 lof (list of figures),
22543 lot (list of tables).
22544 {secunit} controls the formatting of the entry. It should be one of the
22545 following, depending upon the value of the file argument:
22546 toc -- the name of the sectional unit, such as part or
22550 {entry} is the text of the entry.
22552 \addtocontents{file}{text} *\addtocontents*
22553 The |\addtocontents| command adds text (or formatting commands)
22554 directly to the file that generates the table of contents or
22555 list of figures or tables.
22556 {file} is the extension of the file on which information is to be written:
22557 toc (table of contents),
22558 lof (list of figures),
22559 lot (list of tables).
22560 {text} is the information to be written.
22562 ==============================================================================
22563 23. Terminal Input/Output *latex-terminal*
22565 |\typein| Read text from the terminal.
22566 |\typeout| Write text to the terminal.
22568 \typein[cmd]{msg} *\typein*
22569 Prints {msg} on the terminal and causes LaTeX to stop and wait
22570 for you to type a line of input, ending with return. If the
22571 [cmd] argument is missing, the typed input is processed as if
22572 it had been included in the input file in place of the
22573 |\typein| command. If the [cmd] argument is present, it must be
22574 a command name. This command name is then defined or redefined
22575 to be the typed input.
22577 \typeout{msg} *\typeout*
22578 Prints {msg} on the terminal and in the `.log' file. Commands
22579 in {msg} that are defined with |\newcommand| or |\renewcommand|
22580 are replaced by their definitions before being printed.
22583 LaTeX's usual rules for treating multiple spaces as a single space and
22584 ignoring spaces after a command name apply to {msg}. A |\space| command in {msg}
22585 causes a single space to be printed. A ^^J in {msg} prints a newline.
22587 ==============================================================================
22588 24. Typefaces *latex-typefaces*
22590 The typeface is specified by giving the "size" and "style". A typeface is also
22592 |font-styles| Select roman, italics etc.
22593 |font-size| Select point size.
22594 |font-lowlevelcommands| Commands for wizards.
22596 Styles *font-styles*
22598 The following type style commands are supported by LaTeX.
22600 These commands are used like: >
22601 \textit{italics text}.
22602 The corresponding command in parenthesis is the "declaration form", which
22603 takes no arguments. The scope of the declaration form lasts until the next
22604 type style command or the end of the current group.
22606 The declaration forms are cumulative; i.e., you can say: >
22608 to get sans serif boldface.
22610 You can also use the environment form of the declaration forms; e.g.: >
22611 \begin{ttfamily}...\end{ttfamily}.
22613 \textrm (\rmfamily) *\textrm* *\rmfamily*
22616 \textit (\itshape) *\textit* *\itshape* *\emph*
22617 Emphasis (toggles between |\textit| and |\textrm|).
22619 \textmd (\mdseries) *\textmd* *\mdseries*
22620 Medium weight (default). The opposite of boldface.
22622 \textbf (\bfseries) *\textbf* *\bfseries*
22625 \textup (\upshape) *\textup* *\upshape*
22626 Upright (default). The opposite of slanted.
22628 \textsl (\slshape) *\textsl* *\slshape*
22631 \textsf (\sffamily) *\textsf* *\sffamily*
22634 \textsc (\scshape) *\textsc* *\scshape*
22637 \texttt (\ttfamily) *\texttt* *\ttfamily*
22640 \textnormal (\normalfont) *\textnormal* *\normalfont*
22641 Main document font.
22644 Roman, for use in math mode.
22647 Boldface, for use in math mode.
22650 Sans serif, for use in math mode.
22653 Typewriter, for use in math mode.
22656 Italics, for use in math mode, e.g. variable names with
22659 \mathnormal *\mathnormal*
22660 For use in math mode, e.g. inside another type style
22663 \mathcal *\mathcal*
22664 `Calligraphic' letters, for use in math mode.
22667 In addition, the command \mathversion{bold} can be used for switching to bold
22668 letters and symbols in formulas. \mathversion{normal} restores the default.
22673 The following standard type size commands are supported by LaTeX.
22675 The commands as listed here are "declaration forms". The scope of the
22676 declaration form lasts until the next type style command or the end of the
22679 You can also use the environment form of these commands; e.g. >
22680 \begin{tiny}...\end{tiny}
22683 \scriptsize *\scriptsize*
22684 \footnotesize *\footnotesize*
22686 \normalsize(default) *\normalsize*
22694 Low-level font commands *font-lowlevelcommands*
22696 These commands are primarily intended for writers of macros and packages. The
22697 commands listed here are only a subset of the available ones. For full
22698 details, you should consult Chapter 7 of The LaTeX Companion.
22700 \fontencoding{enc} *\fontencoding*
22701 Select font encoding. Valid encodings include OT1 and T1.
22703 \fontfamily{family} *\fontfamily*
22704 Select font family. Valid families include:
22705 cmr for Computer Modern Roman
22706 cmss for Computer Modern Sans Serif
22707 cmtt for Computer Modern Typewriter
22708 and numerous others.
22710 \fontseries{series} *\fontseries*
22711 Select font series. Valid series include:
22717 and various other combinations.
22719 \fontshape{shape} *\fontshape*
22720 Select font shape. Valid shapes are:
22723 sl Slanted (oblique)
22727 The two last shapes are not available for most font families.
22729 \fontsize{size}{skip} *\fontsize*
22730 Set font size. The first parameter is the font size to switch
22731 to; the second is the \baselineskip to use. The unit of both
22732 parameters defaults to pt. A rule of thumb is that the
22733 baselineskip should be 1.2 times the font size.
22735 \selectfont *\selectfont*
22736 The changes made by calling the four font commands described
22737 above do not come into effect until |\selectfont| is called.
22739 \usefont{enc}{family}{series}{shape} *\usefont*
22740 Equivalent to calling |\fontencoding|, |\fontfamily|,
22741 |\fontseries| and |\fontshape| with the given parameters,
22742 followed by |\selectfont|.
22744 ==============================================================================
22745 25. Parameters *latex-parameters*
22747 The input file specification indicates the file to be formatted; TeX uses
22748 `.tex' as a default file extension. If you omit the input file entirely, TeX
22749 accepts input from the terminal. You specify command options by supplying a
22750 string as a parameter to the command; e.g. >
22752 latex "\scrollmode\input foo.tex"
22754 will process `foo.tex' without pausing after every error.
22756 Output files are always created in the current directory. When you fail to
22757 specify an input file name, TeX bases the output names on the file
22758 specification associated with the logical name TEX_OUTPUT, typically
22761 vim:tw=78:ts=8:ft=help:norl:
22762 syntax/bibsearch_atp.vim [[[1
22764 " Title: Vim syntax file
22765 " Author: Bernd Feige <Bernd.Feige@gmx.net>
22766 " Modified: Marcin Szamotulski
22767 " Note: This file is a part of Automatic Tex Plugin for Vim.
22768 " URL: https://launchpad.net/automatictexplugin
22770 " This is a modification of the standard syntax/bib.vim
22774 " For version 5.x: Clear all syntax items
22775 " For version 6.x: Quit when a syntax file was already loaded
22778 elseif exists("b:current_syntax")
22781 " First we source syntax/bib.vim file
22782 source $VIMRUNTIME/syntax/bib.vim
22788 syn keyword bibsearchType contained article book booklet conference inbook
22789 syn keyword bibsearchType contained incollection inproceedings manual
22790 syn keyword bibsearchType contained mastersthesis misc phdthesis
22791 syn keyword bibsearchType contained proceedings techreport unpublished
22792 syn keyword bibsearchType contained string
22793 syn keyword bibsearchEntryKw contained address author booktitle annote chapter
22794 syn keyword bibsearchEntryKw contained crossref edition editor issn howpublished
22795 syn keyword bibsearchEntryKw contained institution fjournal journal key month mrclass
22796 syn keyword bibsearchEntryKw contained note number organization pages publisher
22797 syn keyword bibsearchEntryKw contained school series type title volume year
22799 syn keyword bibsearchNSEntryKw contained abstract isbn issn keywords url
22803 syn cluster bibsearchVarContents contains=bibsearchUnescapedSpecial,bibsearchBrace,bibsearchParen
22804 " This cluster is empty but things can be added externally:
22805 "syn cluster bibsearchCommentContents
22809 syn match bibsearchUnescapedSpecial contained /[^\\][%&]/hs=s+1
22810 syn match bibsearchKey contained /\s*[^ \t}="]\+,/hs=s,he=e-1 nextgroup=bibsearchField
22811 syn match bibsearchVariable contained /[^{}," \t=]/
22812 syn region bibsearchQuote contained start=/"/ end=/"/ contains=@bibsearchVarContents
22813 syn region bibsearchBrace contained start=/{/ end=/}/ contains=@bibsearchVarContents
22814 syn region bibsearchParen contained start=/(/ end=/)/ contains=@bibsearchVarContents
22815 syn region bibsearchField contained start="\S\+\s*=\s*" end=/[}),]/me=e-1 contains=bibsearchEntryKw,bibsearchNSEntryKw,bibsearchBrace,bibsearchParen,bibsearchQuote,bibsearchVariable
22816 syn region bibsearchEntryData contained start=/[{(]/ms=e+1 end=/[})]/me=e-1 contains=bibsearchKey,bibsearchField
22817 " Actually, 5.8 <= Vim < 6.0 would ignore the `fold' keyword anyway, but Vim<5.8 would produce
22818 " an error, so we explicitly distinguish versions with and without folding functionality:
22820 syn region bibsearchEntry start=/@\S\+[{(]/ end=/^\s*[})]/ transparent contains=bibsearchType,bibsearchEntryData nextgroup=bibsearchComment
22822 syn region bibsearchEntry start=/@\S\+[{(]/ end=/^\s*[})]/ transparent fold contains=bibsearchType,bibsearchEntryData nextgroup=bibsearchComment
22824 syn region bibComment2 start=/@Comment[{(]/ end=/^\s*@/me=e-1 contains=@bibsearchCommentContents nextgroup=bibsearchEntry
22828 syn sync match All grouphere bibsearchEntry /^\s*@/
22829 syn sync maxlines=200
22830 syn sync minlines=50
22834 syn region bibsearchComment start=/./ end=/\s*@/me=e-1 contains=@bibsearchCommentContents,@bibsearchSearchInfo nextgroup=bibsearchEntry
22835 syn region bibsearchInfo start=/\s*\d/ end=/\s@/me=e-1 contained containedin=bibsearchComment
22837 " Highlighting defaults
22838 " =====================
22839 " Define the default highlighting.
22840 " For version 5.7 and earlier: only when not done already
22841 " For version 5.8 and later: only when an item doesn't have highlighting yet
22842 if version >= 508 || !exists("did_bib_syn_inits")
22844 let did_bib_syn_inits = 1
22845 command -nargs=+ HiLink hi link <args>
22847 command -nargs=+ HiLink hi def link <args>
22849 HiLink bibsearchType bibType
22850 HiLink bibsearchEntryKw bibEntryKw
22851 HiLink bibsearchNSEntryKw bibNSEntryKw
22852 HiLink bibsearchKey bibKey
22853 HiLink bibsearchVariable bibVariable
22854 HiLink bibsearchUnescapedSpecial bibUnescapedSpecial
22855 HiLink bibsearchComment bibComment
22856 HiLink bibsearchComment2 bibsearchComment
22857 HiLink bibsearchQuote bibQuote
22858 HiLink bibsearchBrace bibBrace
22859 HiLink bibsearchParen bibParen
22860 HiLink bibsearchInfo Number
22863 let b:current_syntax = "bibsearch"
22864 syntax/labels_atp.vim [[[1
22866 " Title: Vim syntax file
22867 " Author: Marcin Szamotulski
22868 " Note: This file is a part of Automatic Tex Plugin for Vim.
22869 " URL: https://launchpad.net/automatictexplugin
22871 syntax region atp_Label_Line start=/^/ end=/$/ transparent contains=atp_Label_CounterValue,atp_Label_Name,atp_Label_LineNr oneline nextgroup=atp_Label_Section
22872 syntax match atp_Label_CounterValue /^\%(\d\%(\d\|\.\)*[[:alpha:]]\=\)\|\%(\C[IXVL]\+\)/ nextgroup=atp_Label_Counter,atp_Label_Name
22873 syntax match atp_Label_Name /\s\S.*\ze(/ contains=atp_label_Counter
22874 syntax match atp_Label_Counter /\[\w\=\]/ contained
22875 syntax match atp_Label_LineNr /(\d\+)/ nextgroup=atp_Label_LineNr
22876 syntax match atp_Label_FileName /^\(\S\&\D\).*(\/[^)]*)$/
22878 hi link atp_Label_FileName Title
22879 hi link atp_Label_LineNr LineNr
22880 hi link atp_Label_Name Label
22881 hi link atp_Label_Counter Keyword
22882 syntax/log_atp.vim [[[1
22884 " Title: Syntax file for tex log messages
22885 " Author: Marcin Szamotulski
22886 " Note: This file is a part of Automatic Tex Plugin for Vim.
22887 " URL: https://launchpad.net/automatictexplugin
22889 syntax keyword texlogKeyword LuaTeX LaTeX2e Babel pdfTeXk pdfTeX Web2C pdflatex latex teTeX TeXLive ON OFF
22891 " There is a small bug with this:
22892 " syntax keyword texlogLatexKeyword LaTeX contained
22894 syntax match texlogBrackets '(\|)\|{\|}\|\\@<!\[\|\\@<!\]\|<\|>'
22896 syntax match texlogOpenOut '\\openout\d\+'
22898 syntax match texlogDate '\%(\s\|<\)\zs\%(\d\d\s\w\w\w\s\d\d\d\d\s\d\d:\d\d\|\d\d\d\d\/\d\d\/\d\d\)\ze\%(\s\|>\|$\)'
22899 syntax match texlogVersion '\%(v\|ver\)\s*\d*\.\d*\w'
22901 " keywords: obsolete, undefined, not available
22902 syntax match texlogWarningKeyword 'o\n\?b\n\?s\n\?o\n\?l\n\?e\n\?t\n\?e\|u\n\?n\n\?d\n\?e\n\?f\n\?i\n\?n\n\?e\n\?d\|n\n\?o\n\?t\_s\+a\n\?v\n\?a\n\?i\n\?l\n\?a\n\?b\n\?l\n\?e'
22904 syntax match texlogLatexInfo 'LaTeX Info:' contains=NONE
22905 syntax match texlogLatexFontInfo 'LaTeX Font Info:' contains=NONE
22906 syntax match texlogEndInfo 'Output written on\s\+\%(\S\|\.\|\\\s\|\n\)*' contains=texlogOutputWritten,texlogFileName transparent
22907 syntax match texlogOutputWritten 'Output written on' contained
22908 syntax match texlogPages '\zs\_d\+\_s\+pages\ze,\_s*\_d\+\_s\+bytes'
22910 syntax match texlogPath '\%(\/\%(\w\|-\|\\.\|\s\|\n\)\+\)\+\%(\.\_w\+\ze\%($\|)\)\)\+'
22911 syntax match texlogPathB '\%(<\|{\|\n\=\)\%(\/\%(\w\|-\|\\.\|\s\|\n\)\+\)\+\%(\.\_w\+\ze\%($\|)\|\n\=\)\)\+\%(>\|}\)'
22912 syntax match texlogFont '\\\=\%(OT\d\|T\d\|OMS\|OML\|U\|OMX\|PD\d\)\n\?\%(\/\_w\+\)\+'
22913 syntax match texlogFontB '\%(OT\d\|T\d\|OMS\|OML\|U\|OMX\|PD\d\)\n\?+\_w\+'
22914 syntax match texlogFontSize '<\d\+\%(\.\d\+\)\?>'
22916 syntax match texlogLatexWarning 'LaTeX Warning:' contains=NONE
22917 " is visible in synstack but is not highlighted.
22918 syntax match texlogLatexFontWarning 'LaTeX Font Warning:' contains=NONE
22920 syntax match texlogPdfTeXWarning 'pdfTeX warning' contains=NONE
22922 syntax match texlogPackageWarning 'Package\s\+\_w\+\_s\+Warning'
22923 syntax match texlogPackageInfo 'Package\s\+\_w\+\_s\+Info'
22925 syntax match texlogError '^!.*$' contains=texlogLineNr
22927 syntax match texlogOverfullBox 'Overfull\_s\\[hv]box'
22928 syntax match texlogUnderfullBox 'Underfull\_s\\[hv]box'
22929 syntax match texlogTooWide 't\n\?o\n\?o\_sw\n\?i\n\?d\n\?e'
22930 syntax match texlogMultiplyDefined 'm\n\?u\n\?l\n\?t\n\?i\n\?p\n\?l\n\?y\%(\_s\s\?\|\n\?-\n\?\)\n\?d\n\?e\n\?f\n\?i\n\?n\n\?e\n\?d'
22931 syntax match texlogRedefining '\cr\n\?e\n\?d\n\?e\n\?f\n\?i\n\?n\n\?i\n\?n\n\?g'
22932 syntax match texlogRedeclaring '\cr\n\?e\n\?d\n\?e\n\?c\n\?l\n\?a\n\?r\n\?i\n\?n\n\?g'
22933 syntax match texlogSourceSpecials 'S\n\?o\n\?u\n\?r\n\?c\n\?e\_ss\n\?p\n\?e\n\?c\n\?i\n\?a\n\?l\n\?s'
22934 syntax match texlogLineParsing '%\n\?&\n\?-\n\?l\n\?i\n\?n\n\?e\_sp\n\?a\n\?r\n\?s\n\?i\n\?n\n\?g'
22935 syntax match texlogEnabled 'e\n\?n\n\?a\n\?b\n\?l\n\?e\n\?d'
22937 syntax match texlogLineNr '\%(^l\.\|\so\n\?n\_si\n\?n\n\?p\n\?u\n\?t\_sl\n\?i\n\?n\n\?e\_s*\)\_d\+\s\?\|\s\?a\n\?t\n\?\_sl\n\?i\n\?n\n\?e\n\?s\_s\+\_d\+--\_d\+\s\?'
22938 syntax match texlogPageNr '\[\_d\+\%(\_s*{[^}]*}\)\?\]\|\s\?o\n\?n\n?\_sp\n\?a\n\?g\n\?e\_s\_d\+'
22940 syntax match texlogDocumentClass 'Document Class:\s\+\S*'
22941 syntax match texlogPackage 'Package:\s\+\S*'
22942 syntax match texlogFile 'File:\s\+\S*'
22943 syntax match texlogFileName '\/\zs\%(\w\|\\\s\|-\|\n\)\+\.\%(dvi\|pdf\|ps\)' contained
22944 syntax match texlogCitation 'Citation\s\+\`[^']*\'' contains=texlogScope
22945 syntax match texlogReference 'Reference\s\+\`[^']*\'' contains=texlogScope
22946 syntax match texlogScope '\%(^\|\s\)\%(\`\|\'\)\zs[^']*\ze\'\%($\|\s\|\.\)'
22948 syntax match texlogFontShapes '\Cfont shapes'
22949 syntax match texlogChapter 'Chapter\s\+\%(\d\|\.\)\+'
22951 " syntax match texlogDelimiter '(\|)'
22953 " This works only with 'sync fromstart'.
22954 " syntax region texlogBracket start="(" skip="\\[()]" end=")" transparent contains=texlogPath,texlogPathB,texlogLatexInfo,texlogFontInfo,texlogEndInfo,texlogOutputWritten,texlogLatexWarning,texlogLatexFontInfo,texlogLatexFontWarning,texlogPackageWarning,texlogPackageInfo,texlogError,texlogLineNr,texlogPageNr,texlogPackage,texlogDocumentClass,texlogFile,texlogCitation,texlogReference,texlogKeyword,texlogLatexKeyword,texlogScope,texlogFont,texlogFontB,texlogFontSize,texlogOverfullBox,texlogUnderfullBox,texlogTooWide,texlogRedefining,texlogRedeclaring,texlogDate,texlogVersion,texlogWarningKeyword,texlogPages,texlogFontShapes,texlogOpenOut,texlogPdfTeXWarning,texlogBrackets,texlogEndInfo,texlogFileName,texlogPages,texlogChapter,texlogMultiplyDefined,texlogEnabled
22956 " syntax sync fromstart
22958 hi def link texlogKeyword Keyword
22959 hi def link texlogLatexKeyword Keyword
22960 hi def link texlogBrackets Special
22961 hi def link texlogOpenOut Statement
22962 hi def link texlogWarningKeyword Identifier
22963 hi def link texlogPath Include
22964 hi def link texlogPathB texlogPath
22966 hi def link texlogLatexInfo String
22968 hi def link texlogOutputWritten String
22969 hi def link texlogFileName Identifier
22970 hi def link texlogPages Identifier
22971 hi def link texlogChapter String
22973 hi def link texlogLatexFontInfo String
22974 hi def link texlogLatexWarning Identifier
22975 hi def link texlogLatexFontWarning Identifier
22976 hi def link texlogPackageWarning Identifier
22977 hi def link texlogPdfTeXWarning Identifier
22978 hi def link texlogPackageInfo String
22979 hi def link texlogError Error
22981 hi def link texlogLineNr Number
22982 hi def link texlogPageNr Number
22984 hi def link texlogDocumentClass String
22985 hi def link texlogPackage String
22986 hi def link texlogFile String
22987 hi def link texlogCitation String
22988 hi def link texlogReference String
22989 hi def link texlogOverfullBox Function
22990 hi def link texlogUnderfullBox Function
22991 hi def link texlogTooWide Function
22992 hi def link texlogRedefining Function
22993 hi def link texlogRedeclaring Function
22994 hi def link texlogSourceSpecials Keyword
22995 hi def link texlogEnabled Keyword
22996 hi def link texlogLineParsing Keyword
22997 hi def link texlogMultiplyDefined Function
22998 hi def link texlogScope Label
23000 hi def link texlogFont Label
23001 hi def link texlogFontB Label
23002 hi def link texlogFontSize Label
23003 hi def link texlogFontShapes String
23005 hi def link texlogDate Number
23006 hi def link texlogVersion Number
23007 syntax/toc_atp.vim [[[1
23009 " Title: Vim syntax file
23010 " Author: Marcin Szamotulski
23011 " Note: This file is a part of Automatic Tex Plugin for Vim.
23012 " URL: https://launchpad.net/automatictexplugin
23014 syntax match atp_FileName /^\s*\D.*$/
23015 syntax match atp_LineNr /^\s*\d\+/ skipwhite nextgroup=atp_Number,atp_Abstract
23016 syntax match atp_Number /\t\%(\d\+\.\?\)\+/ms=b+1,me=e contained nextgroup=atp_SectionTitle,atp_SubSectionTitle
23018 syntax match atp_Abstract /\t\+\s\s\(\S\&\D\).*$/
23020 syntax match atp_Chapter /^\s*\d\+\t\+\d\+\s.*/ contains=atp_LineNr,atp_Number,atp_ChapterTitle
23021 " syntax region atp_ChapterTctle matchgroup=atp_ChapterTitle start=/\d\s\(\S\&\D\)/ms=e-1 end=/$/me=e contained oneline
23023 syntax match atp_Section /^\s*\d\+\t\+\(\d\+\.\d\+\|\s\{3,}\)\s.\+/ contains=atp_LineNr,atp_Number,atp_SectionTitle
23024 " syntax region atp_SectionTitle matchgroup=atp_SectionTitle start=/\d\s\t\@<!/ms=e+1,ms=e+1 end=/$/me=e contained oneline
23026 syntax match atp_SubSection /^\s*\d\+\t\+\(\d\+\.\d\+\.\d\+\|\s\{5,}\)\s.\+/ contains=atp_LineNr,atp_Number,atp_SubSectionTitle
23027 " syntax region atp_SubSectionTitle matchgroup=atp_SubSectionTitle start=/\d\s\t\@<!/ms=e+1,ms=e+1 end=/$/me=e contained oneline
23029 hi link atp_FileName Title
23030 hi link atp_LineNr LineNr
23031 hi link atp_Number Number
23032 hi link atp_Abstract Label
23033 hi link atp_Chapter Label
23034 hi link atp_Section Label
23035 hi link atp_SubSection Label
23037 " hi link atp_ChapterTitle Title
23038 " hi link atp_SectionTitle Title
23039 " hi link atp_SubsectionTitle Title
23040 colors/coots-beauty-256.vim [[[1
23042 " Description: Vim color file
23043 " Maintainer: Marcin Szamotulski <mszamot at gmail dot com>
23044 " Note: This file is a part of Automatic Tex Plugin for Vim.
23045 " URL: https://launchpad.net/automatictexplugin
23047 " This color scheme was based on "Ocean237" theme by Chris Vertonghen.
23049 set background=dark
23052 if exists("syntax_on")
23056 let g:colors_name="coots_beauty_256"
23058 highlight Normal cterm=none ctermfg=250 ctermbg=233 guifg=white guibg=#1c1c1c
23059 highlight NonText cterm=none ctermfg=105 ctermbg=233 guifg=#1c1c1c guibg=#1c1c1c
23061 highlight Visual ctermbg=238 guibg=gray35
23062 highlight VisualNOS cterm=bold,underline ctermfg=57 ctermbg=233
23064 highlight Cursor cterm=none ctermfg=15 ctermbg=93 guifg=#000000 guibg=#8A4C98
23065 highlight CursorIM cterm=bold ctermfg=15 ctermbg=93 guifg=#000000 guibg=#8A4C98
23066 "highlight CursorColumn
23067 highlight CursorLine cterm=none ctermfg=none ctermbg=53 guibg=#111111 gui=none
23069 highlight Directory ctermfg=5 ctermbg=233 guifg=DarkViolet guibg=#1c1c1c
23071 highlight DiffAdd cterm=none ctermfg=15 ctermbg=56 guifg=white guibg=SlateBlue4 gui=bold
23072 highlight DiffDelete cterm=none ctermfg=19 ctermbg=56 guifg=VioletRed guibg=SlateBlue4
23073 highlight DiffChange cterm=none ctermfg=173 ctermbg=125 guifg=salmon guibg=DeepPink4
23074 highlight DiffText cterm=bold ctermfg=white ctermbg=125 guifg=white guibg=DeepPink4
23076 highlight Question cterm=bold ctermfg=33 ctermbg=233 guifg=#0087ff guibg=#1c1c1c
23077 highlight ErrorMsg cterm=bold ctermfg=160 ctermbg=233 guifg=#d70000 guibg=#1c1c1c
23078 highlight ModeMsg ctermfg=33 ctermbg=233 guifg=#0087ff guibg=#1c1c1c
23079 highlight MoreMsg ctermfg=39 ctermbg=233 guifg=#00afff guibg=#1c1c1c
23080 highlight WarningMsg cterm=bold ctermfg=161 ctermbg=233 guifg=#d7005f guibg=#1c1c1c
23082 highlight LineNr ctermfg=57 ctermbg=233 guifg=#837598 guibg=#1c1c1c
23083 highlight Folded ctermfg=57 ctermbg=233 guifg=#837598 guibg=#1a1a1a
23084 highlight FoldColumn cterm=none ctermfg=green ctermbg=233 guifg=#5CB80C guibg=#1c1c1c
23085 "highlight SignColumn
23087 highlight Search cterm=bold ctermfg=black ctermbg=226 guifg=black guibg=yellow
23088 highlight IncSearch cterm=bold ctermfg=black ctermbg=red guifg=gold guibg=#1c1c1c
23089 highlight MatchParen ctermfg=233 ctermbg=226 guifg=#1c1c1c guibg=gold
23091 highlight PMenu ctermbg=18 ctermfg=39
23092 highlight PMenuSel ctermbg=39 ctermfg=18
23093 highlight PMenuSBar ctermbg=white ctermfg=33
23094 highlight PMenuThumb ctermbg=white ctermfg=33
23096 highlight SpecialKey ctermfg=129 ctermbg=233 guifg=DarkViolet
23097 highlight StatusLine cterm=none ctermfg=226 ctermbg=232 guifg=#111111 guibg=wheat1
23098 highlight StatusLineNC cterm=none ctermfg=245 ctermbg=232 guifg=#111111 guibg=snow4
23099 highlight default User1 cterm=bold ctermfg=226 ctermbg=232 gui=bold guifg=DeepPink4 guibg=#111111
23100 highlight default User2 cterm=none ctermfg=red ctermbg=232 guifg=Khaki1 guibg=#111111
23101 highlight default User3 cterm=none ctermfg=226 ctermbg=232 guifg=BlueViolet guibg=#111111
23103 highlight VertSplit cterm=none ctermfg=green ctermbg=233 guifg=#1c1c1c guibg=DeepSkyBlue4
23104 highlight WildMenu cterm=bold ctermfg=0 ctermbg=118
23106 highlight Title cterm=bold ctermfg=226 ctermbg=232
23109 "highlight Scrollbar
23113 highlight Comment cterm=none ctermfg=90 ctermbg=233 guifg=Magenta4
23115 highlight Constant ctermfg=125 ctermbg=233 guifg=DeepPink3
23116 highlight String cterm=none ctermfg=27 ctermbg=233 guifg=RoyalBlue1
23117 "highlight Character
23118 highlight Number cterm=none ctermfg=161 ctermbg=233 guifg=DeepPink2
23119 highlight Boolean cterm=none ctermfg=161 ctermbg=233 guifg=DeepPink1
23122 highlight Identifier ctermfg=39 guifg=DodgerBlue
23123 highlight Function cterm=bold ctermfg=White guifg=White gui=bold
23125 highlight Statement cterm=none ctermfg=135 guifg=MediumOrchid
23127 highlight Conditional cterm=none ctermfg=27 ctermbg=233 guifg=SlateBlue2
23128 highlight Repeat cterm=none ctermfg=82 ctermbg=233
23130 highlight Operator cterm=none ctermfg=40 ctermbg=233 guifg=Chartreuse1
23131 highlight Keyword cterm=none ctermfg=197 ctermbg=233 guifg=DeepPink1
23132 highlight Exception cterm=none ctermfg=82 ctermbg=233 guifg=Chartreuse1
23134 highlight PreProc ctermfg=82 guifg=DeepPink1
23135 highlight Include cterm=none ctermfg=130 ctermbg=233
23136 highlight Define cterm=none ctermfg=39 ctermbg=233
23137 highlight Macro cterm=none ctermfg=39 ctermbg=233
23138 highlight PreCondit cterm=bold ctermfg=125 ctermbg=233
23140 highlight Type cterm=none ctermfg=82 guifg=LawnGreen
23141 highlight StorageClass cterm=none ctermfg=21 ctermbg=233
23142 highlight Structure cterm=none ctermfg=21 ctermbg=233
23143 highlight Typedef cterm=none ctermfg=21 ctermbg=233
23146 highlight Special cterm=none ctermfg=93 guifg=BlueViolet
23149 "highlight SpecialChar
23151 "highlight Delimiter
23152 "highlight SpecialComment
23155 highlight Underlined cterm=underline ctermfg=102 ctermbg=233 gui=underline
23156 highlight Ignore ctermfg=67
23158 "highlight SpellBad ctermfg=21 ctermbg=233
23159 "highlight SpellCap ctermfg=19 ctermbg=233
23160 "highlight SpellRare ctermfg=18 ctermbg=233
23161 "highlight SpellLocal ctermfg=17 ctermbg=233
23163 highlight Todo ctermfg=21 ctermbg=233 guifg=DeepPink guibg=#1c1c1c gui=underline,bold
23165 highlight helpNormal ctermbg=235
23166 highlight helpHyperTextJump ctermfg=57
23167 highlight helpBar ctermfg=57
23168 highlight helpStar ctermfg=27
23170 highlight TabLine cterm=none ctermfg=white ctermbg=240
23171 highlight TabLineFill cterm=none ctermfg=white ctermbg=240
23172 highlight TabLineSel cterm=bold ctermfg=white ctermbg=57
23173 "highlight TabLineSel cterm=bold ctermfg=white ctermbg=197
23175 highlight texDelimiter ctermfg=161 ctermbg=233 guifg=MediumVioletRed
23177 highlight texSectionMarker ctermfg=238 ctermbg=233 guifg=FireBrick gui=bold
23178 highlight texSection cterm=bold ctermfg=242 ctermbg=233 guifg=FireBrick2 gui=bold
23179 " highlight texSectionName guifg=FireBrick
23180 highlight texDocType ctermfg=90 ctermbg=233 guifg=DeepPink4
23181 highlight texInputFile ctermfg=90 ctermbg=233 guifg=DeepPink4
23182 highlight texDocTypeArgs ctermfg=204 ctermbg=233 guifg=DeepPink2
23183 highlight texInputFileopt ctermfg=204 ctermbg=233 guifg=DeepPink2
23184 highlight texType ctermfg=40 ctermbg=233 guifg=green3
23185 highlight texTypeStyle ctermfg=40 ctermbg=233 guifg=green3
23186 highlight texMath ctermfg=245 ctermbg=233 guifg=DarkKhaki
23187 highlight texStatement ctermfg=245 ctermbg=233 guifg=DeepPink3
23188 highlight texString ctermfg=39 ctermbg=233 guifg=DodgerBlue
23189 highlight texSpecialChar ctermfg=39 ctermbg=233 guifg=DodgerBlue
23190 highlight texRefZone guifg=DeepPink2 gui=bold
23191 highlight texCite guifg=DeepPink4
23192 highlight texRefOption guifg=HotPink4
23194 " texlog /syntax file available in Automatic Tex Package/
23195 hi texlogKeyword ctermfg=90 cterm=bold guifg=magenta4 gui=bold
23196 hi texlogLatexKeyword ctermfg=white cterm=bold guifg=white gui=bold
23197 " hi texlogBrackets Special
23198 hi texlogOpenOut guibg=magenta4 guifg=white
23199 hi texlogWarningKeyword guifg=DeepPink4 gui=bold
23200 hi texlogPath guifg=PaleVioletRed4
23202 hi texlogLatexInfo ctermfg=90 cterm=bold guifg=magenta4 gui=bold
23204 hi texlogOutputWritten ctermfg=90 cterm=bold guifg=magenta4 gui=bold
23205 hi texlogFileName guifg=magenta4 gui=bold
23206 hi texlogPages guifg=magenta4 gui=bold
23207 hi texlogChapter ctermfg=90 cterm=bold guifg=magenta4 gui=bold
23209 hi texlogLatexFontInfo ctermfg=90 cterm=bold guifg=magenta4 gui=bold
23210 hi texlogLatexWarning guifg=OrangeRed guibg=DeepPink4 gui=bold
23211 hi texlogLatexFontWarning guifg=DeepPink4 gui=bold
23212 hi texlogPackageWarning guifg=DeepPink4 gui=bold
23213 hi texlogPdfTeXWarning guifg=OrangeRed guibg=DeepPink4 gui=bold
23214 hi texlogPackageInfo ctermfg=90 cterm=bold guifg=magenta4 gui=bold
23215 " hi texlogError Error
23217 hi texlogLineNr guifg=OrangeRed3
23218 hi texlogPageNr guifg=OrangeRed3
23220 hi texlogDocumentClass ctermfg=57 cterm=none guifg=BlueViolet gui=none
23221 hi texlogPackage ctermfg=90 cterm=bold guifg=magenta4 gui=bold
23222 hi texlogFile ctermfg=90 cterm=bold guifg=magenta4 gui=bold
23223 hi texlogCitation ctermfg=90 cterm=bold guifg=magenta4 gui=bold
23224 hi texlogReference ctermfg=90 cterm=bold guifg=magenta4 gui=bold
23225 hi texlogOverfullBox guifg=PaleGoldenRod
23226 hi texlogUnderfullBox guifg=PaleGoldenRod
23227 hi texlogTooWide guifg=PaleGoldenRod
23228 hi texlogRedefining guifg=PaleGoldenRod
23229 hi texlogRedeclaring guifg=PaleGoldenRod
23230 hi link texlogSourceSpecials texlogKeyword
23231 hi link texlogEnabled texlogKeyword
23232 hi link texlogLineParsing texlogKeyword
23233 hi texlogMultiplyDefined guifg=PaleGoldenRod
23234 hi texlogScope guifg=DarkOrange3
23236 hi texlogFont guifg=DarkOrange4
23237 hi texlogFontB guifg=DarkOrange4
23238 hi texlogFontSize guifg=DarkOrange4
23239 hi texlogFontShapes ctermfg=90 cterm=bold guifg=magenta4 gui=bold
23241 hi texlogDate guifg=purple3
23242 hi texlogVersion guifg=purple3
23243 " \chapter, \section, ... {theorem} {definition}
23245 highlight Error ctermfg=196 ctermbg=233
23246 highlight SpellErrors cterm=underline ctermfg=darkred ctermbg=233
23247 highlight SpellBad ctermfg=196 ctermbg=233
23248 highlight SpellCap ctermfg=202 ctermbg=233
23249 highlight SpellRare ctermfg=203 ctermbg=233
23250 highlight SpellLocal ctermfg=202 ctermbg=233
23252 hi bibsearchInfo ctermfg=33 guibg=DeepPink
23253 hi bibsearchComment cterm=bold ctermfg=27 guifg=blue gui=bold
23254 hi bibComment2 cterm=bold ctermfg=30 guifg=SeaGreen4 gui=bold
23255 hi bibsearchCommentContents cterm=none ctermfg=30 guifg=SeaGreen4 gui=none
23256 hi bibsearchType ctermfg=24 guifg=MediumVioletRed
23257 " hi bibsearchEntryData ctermfg=magenta
23258 hi bibsearchKey cterm=bold ctermfg=white guifg=white gui=bold
23259 hi bibsearchEntry ctermfg=33 guifg=DeepSkyBlue
23260 hi bibsearchField ctermfg=green guifg=SlateBlue4
23261 hi bibsearchEntryKw ctermfg=white guifg=SlateBlue3
23262 hi bibsearchBrace cterm=bold guifg=white gui=bold
23263 hi bibsearchVariable ctermfg=white guifg=white
23266 highlight atp_filename guifg=FireBrick
23267 highlight atp_linenumber cterm=bold ctermfg=27 guifg=PeachPuff4
23268 highlight atp_number ctermfg=33 guifg=sienna
23269 highlight atp_chapter cterm=bold ctermfg=white guifg=seashell2 gui=bold
23270 highlight atp_section ctermfg=30 guifg=seashell4
23271 highlight atp_subsection ctermfg=24 guifg=seashell4
23272 highlight atp_abstract cterm=bold ctermfg=gray guifg=seashell2 gui=bold
23275 highlight atp_label_filename guifg=DeepPink4 gui=bold
23276 highlight atp_label_linenr cterm=bold ctermfg=white guifg=maroon
23277 " highlight atp_label_name ctermfg=green guifg=chartreuse
23278 highlight atp_label_name guifg=DeepPink2 gui=bold
23280 highlight atp_statusline cterm=bold ctermfg=green ctermbg=233
23282 highlight atp_statustitle cterm=bold ctermfg=grey ctermbg=233
23283 highlight atp_statussection cterm=bold ctermfg=yellow ctermbg=233
23284 highlight atp_statusoutdir ctermfg=grey ctermbg=233
23286 highlight link atp_Todo Normal
23288 highlight ywtxt_todo guifg=yellow gui=bold
23289 highlight ywtxt_note guifg=yellow gui=bold
23291 highlight ywtxt_heading1 guifg=slateblue1 gui=bold
23292 highlight ywtxt_heading2 guifg=slateblue gui=bold
23293 highlight ywtxt_heading3 guifg=slateblue4 gui=bold
23294 highlight ywtxt_heading4 guifg=darkslateblue gui=bold
23295 highlight ywtxt_bold cterm=bold gui=bold
23296 highlight ywtxt_italic cterm=italic gui=italic
23297 highlight ywtxt_underline cterm=underline gui=underline
23298 highlight ywtxt_comment guifg=honeydew4
23301 highlight vimCommentTitle cterm=bold ctermfg=white