Introduction

A mouse click (Ctrl-Button1 by default) in the xdvi window can open an editor
with the corresponding place in the (La)TeX source (also called `reverse search'), and

xdvi can jump to (and visually highlight) a position in the DVI file
that corresponds to a certain line number in the (La)TeX source file (`forward search').

This functionality is supported by xdvi(k) versions 22.38 and upwards. It uses
so-called `source specials' in the DVI file, which can be inserted via a macro package
or a command-line option to the (La)TeX program (executable).

The (La)TeX version that comes with
teTeX-2.0
provides a command line option `-src' to insert these specials
automatically. While the macro version might interact badly with other macro packages,
the option for the (La)TeX executable should be more
robust. However, both versions may affect the line breaks of your document, so
it's generally a good idea to disable source specials
for the final version of the document.

(X)Emacs and AUCTeX

AUCTeX (starting with version 11.50) supports inverse search out of the box:
When using TeX-source-specials-mode (which can be toggled with the key
combination C-c C-t C-s), it will start emacs-server or gnu-server
and xdvi(k) as required. Please see the AUCTeX manual for further details
(accessible via (info "(auctex) Viewing")).

You can also assign this command to a key.
An example for more sophisticated configuration settings is
available here.

Nedit and nc

Reverse search

Start nedit with the -server option.

As `editor' option/X resource for xdvi(k), use:

nc -noask +%l %f

Forward search

Nedit has a fairly powerful macro language that can be used to implement forward search.
The following macro might serve as a starting point - it's not perfect in that
it doesn't work with included files. Suggestions on this are welcome.

Put the above definition into your Nedit macro file (~/.neditmacros by default), then
launch Nedit and open the menu

Preferences > Default Settings > Customize Menus > Macro Menu

Enter a name for your macro, and as macro command enter: forward_search().
You may also want to define an accelerator key for
the menu entry as well as a keyboard shortcut (called "mnemonic" in
Nedit).

Other editors

All above examples are with editors that provide a `server mode', which allows
you to load a new file into the already running editor instance.
You can also use reverse search with editors that
don't have this functionality, with the slight disadvantage that
a new instance of the editor will be started for every reverse
search. One thing to keep in mind is that non-X editors should
be started in a separate window, to avoid clobbering the
editor display with xdvi's diagnostic output. To do this,
pass the editor command to the -e option of an xterm, e.g. for
classic vi, use the following `editor' option/X resource for
xdvi(k):

xterm -e vi +%l %f

If you set the editor via the VISUAL or EDITOR resources,
xdvi will pass it to an `xterm -e' command automatically.