HOW TO USE REVERSE AND FORWARD SEARCH WITH VIM AND ZATHURA
Light weight and with vim like key-sequence zathura is a great choice for reading pdf files. To install it simply run # apt-get install zathura
\synctex=1
$ pdflatex -synctex=1 foo.tex
Reverse Searching
First we need to edit zathurarc file, run $ vim $HOME/.config/zathura/zathurarc
# Adding reverse search between gvim and zathura
set synctex true
set synctex-editor-command "gvim --remote-silent +%{line} %{input}"
Test your settings
- Create a file foo.tex and compile it using pdflatex.
- Open the new created foo.pdf document using zathura.
- While reading foo.pdf hold the control key and left-click the mouse.
- The source file should be opened in the very same line where you have clicked.
Forward Searching
We can jump to line 511 column 1 in the file foo.pdf by using the command line, simply run: $ zathura --synctex-forward 511:1:foo.tex foo.pdf
$ vim $HOME/.vimrc
function! SyncTexForward()
let linenumber=line(".")
let colnumber=col(".")
let filename=bufname("%")
let filenamePDF=filename[:-4]."pdf"
let execstr="!zathura --synctex-forward " . linenumber . ":" . colnumber . ":" . filename . " " . filenamePDF . "&>/dev/null &"
exec execstr
endfunction
nmap :call SyncTexForward()
Test your settings
- Run:
$ vim foo.tex
- Move the cursor to a chosen line.
- Hold alt-s (that's alt and key character s at the same time).
- The file foo.pdf should be opened and forward to your chosen line.