Vim logo vim online Vim Book Ad

 Tip #361: Use xdvi (or kdvi) in conjunction with gvim (or vim) and converse

 tip karma   Rating 16/4, Viewed by 428 

created:   November 5, 2002 14:07      complexity:   intermediate
author:   Christine Noot-Huyghe      as of Vim:   6.0

source: the xdvi man page

For recent xdvi versions (>= 22.38), (or recent Unix/Linux versions), xdvi can
interact with any editor provided with a client-server mode. We explain
here how to use xdvi in conjunction with vim (compiled with the client-server
option) or gvim (mostly compiled with this option). I have tested that
with Linux Mandrake 9.0. On that system, gvim is compiled with the
client-server option and vim is not.

0-Check that your xdvi version provides the "source-special" functions,
by typing 'xdvi -version' or 'man xdvi'

1-Configuration of the source file (file.tex)
Put the following line at the beginning of the latex file:
\usepackage[active]{srcltx}
or the following line at the beginning of the tex file
\include{srctex}

2-Configuration of xdvi
xdvi has to be called with the following options
xdvi -editor 'gvim --remote-wait +%l %f' file.dvi &
(or with 'xterm -e vim --remote-wait +%l %f' if vim has
been compiled with the client-server option).

To make it easier to use you can define an environement
variable XEDITOR to set the value of 'editor' or add
the following line in your .Xdefaults
xdvi.editor: gvim --remote-wait +%l %f
Launch 'xrdb -load ~/.Xdefaults' to make sure that
xdvi.editor is set to the good value.
If you have defined such a variable, xdvi will always be launched
with the -editor option. To avoid this unsafe behavior,
launch 'xdvi -safer'.

3-Conversely, if you call xdvi within gvim with the -sourceposition
option, cursor is placed in the dvi file on the corresponding position.
Syntax is:
xdvi -sourceposition l:cfile.tex file.dvi
l is the line number, c is the column number
(Be carefull: there is no space between "c" (column number) and
file.tex).
To make it easier to use, you can do the following
First create a file named for example "xdvi_source.vim"
with following lines
" This script calls xdvi source and puts cursor in xdvi viewer at
" the position corresponding to the position in the source file
"
:exec "silent !xdvi -sourceposition ".line(".").':'.col(".")."%".' '."%:r.dvi"

Then launch the following command within gvim editing the .tex
source file. Pressing simultaneously <CTRL> and -> will open
the dvi file at the right position:
:noremap <buffer> <C-Right> :so xdvi_source.vim<CR>

 rate this tip  Life Changing Helpful Unfulfilling 

<<':e <dir>' enter files and directories | matchit.vim and coldfusion (and perhaps others) >>

Additional Notes

Anonymous, November 19, 2002 23:04
Seems it doesn't work for multiple tex source files.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo