This time I have a quite easy task on my list for a better Vim LaTeX IDE. I want to start Latexmk automatically when I edit a .tex-file.
Latexmk is a great program which recognizes changes to your LaTeX files automatically and compiles them. The following code e.g. in your ~/.vim/ftplugin/tex.vim maps F10 to start latexmk:
function! s:InitLatexmk()
let g:firstInitLatexmk = 1
let s:origdir = fnameescape(getcwd())
exe "cd ".fnameescape(Tex_GetMainFileName(':p:h'))
exe "!xterm -e latexmk -pvc -pdf ".fnameescape(Tex_GetMainFileName(':p'))." &"
exe "cd ".s:origdir
return ''
endfunction
command! InitLatexmk silent call s:InitLatexmk()
if !hasmapto('<Plug>InitLatexmk')
map <silent< <f10> <Plug>InitLatexmk
endif
nnoremap <Plug>InitLatexmk :InitLatexmk<CR>
To start this when Vim starts and after your plugins like Vim-Latex have been loaded you have to add the following to e.g. your ~/.vim/ftplugin/after/tex.vim:
if !exists('g:firstInitLatexmk')
:InitLatexmk
endif
Note: Use instructions at your own risk! See Impressum for further details!
Thanks a lot! Works perfectly. A small error though:
In
map <silent< InitLatexmkit should be
Panos
Kommentar von Panos — 28. November 2011 @ 13:54