29. Juni 2011

Add latexmk support to vim-latex

Category: Allgemein,Howto / Tutorial — Tags: , , , , – Kay Smarczewski @ 00:00

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!

1 Kommentar »

  1. Thanks a lot! Works perfectly. A small error though:

    In
    map <silent< InitLatexmk

    it should be

    Panos

    Kommentar von Panos — 28. November 2011 @ 13:54

RSS Feed für Kommentare zu diesem Artikel. | TrackBack URI

Hinterlasse einen Kommentar

XHTML ( You can use these tags):
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .

Kay Smarczewski


mein Blog

Seiten

Kalender mit Posts

Juni 2011
M D M D F S S
« Dez    
 12345
6789101112
13141516171819
20212223242526
27282930  

Schlagwörter

Dieses Blog durchsuchen

© Kay Smarczewski – Powered by WordPress