Skip to content

Instantly share code, notes, and snippets.

@vext01
Last active February 14, 2024 03:36
Show Gist options
  • Star 59 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vext01/16df5bd48019d451e078 to your computer and use it in GitHub Desktop.
Save vext01/16df5bd48019d451e078 to your computer and use it in GitHub Desktop.
Vim+Zathura+Synctex

Vim+Zathura+Synctex

  • 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.

@charlie39
Copy link

charlie39 commented Jul 2, 2022

@mazunki
This is my tex autocmd group

  augroup latex
    autocmd! CursorMovedI *.tex call OpenZathura()
    autocmd! BufWritePost,BufReadPre *.tex silent !compiler %
  augroup end

Also a tiny detail:

Also imp to have the compiler (whaterver compiling script or command you have) mapped to a certain key binding without silent, for for debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment