- 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.
To make it work without starting a new vim instance, allowing to link to an already open file, I think you just have to use a fixed servername, i.e.
vimura:
and put this alias in .bashrc (or equivalent)
alias vim='/usr/bin/vim --servername vim'
At least it works for my basic usage of vim, I don’t know if there are side effects with gvim and/or more advanced usage of vim.
You could also keep the "vimura" script as it is and launch vim with the corresponding servername (i.e. the .tex filename).