- In a script called 'vimura':
#!/bin/sh
echo $1
zathura -s -x "gvim --servername $1 -c \"let g:syncpdf='$1'\" --remote +%{line} %{input}" $*
For zathura >= 0.3.2 remove -s
.
- In your vimrc:
function! Synctex()
" remove 'silent' for debugging
execute "silent !zathura --synctex-forward " . line('.') . ":" . col('.') . ":" . bufname('%') . " " . g:syncpdf
endfunction
map <C-enter> :call Synctex()<cr>
- Build your latex doc with synctex enabled
pdflatex -synctex=1 ...
-
Open PDF with vimura script.
-
CTRL+Click
in Zathura jumps to source in vim. -
CTRL+Enter
in vim jumps to corresponding position in PDF.
You can have it trigger on CursorMoveI events on *.tex file patterns.
With this whenever you enter insert and move around your cursor, zathura would do the same.
But this also implies that you have to compile (if it's not compiled ) before entering insert mode.
I have another command to compile any *.tex file on BufReadPost and BufWritePost so i don't have to always remember about compiling it first.
In my case it's not necessary to have zathura opened already. If the pdf file already exist , it (that function ) would open up without any problem