emacs keybindings in xpdf and xdvi

Emacs
Author

Vinh Nguyen

Published

May 10, 2011

I've been using xpdf and xdvi for reading documents I've downloaded or my LaTeX-generated documents on the laptop more and more these days due to their speed. The one thing I require (desire) in all programs I use on a day to day basis, especially when I have to navigate the file, is to have emacs keybindings.

To do so for the two readers, first, add the following to ~/.Xresources:

! look in man xdvi
xdvi.mainTranslations: #override 
Ctrlv: down-or-next()n
Altv: up-or-previous()n
Alt Shift <: goto-page(1)n
Alt Shift >: goto-page()n
Ctrlf: right(0.015)n
Ctrlb: left(0.015)n
Ctrln: down(0.015)n
Ctrlp: up(0.015)n
l: right(0.015)n
h: left(0.015)n
j: down(0.015)n
k: up(0.015)n
Ctrls: find()n
xdvi*geometry: 1350x700
xdvi*shrinkFactor: 4

! look in man xpdf and xpdfrc; ~/.xpdfrc
xpdf*geometry: 1350x700
xpdf*initialZoom: width

Also, create and add the following to ~/.xpdfrc:

initialZoom width
continuousView yes
bind ctrl-v any pageDown
bind alt-v any pageUp
bind alt-shift-< any gotoPage(1)
bind alt-shift-> any gotoLastPage
bind ctrl-n any scrollDown(16)
bind ctrl-p any scrollUp(16)
bind ctrl-f any scrollRight(16)
bind ctrl-b any scrollLeft(16)
bind h any scrollLeft(16)
bind l any scrollRight(16)
bind k any scrollUp(16)
bind j any scrollDown(16)
bind ctrl-s any find

Now I can at least navigate the file with emacs keybindings.

I would also like to get this to work on ghostview (for postscript files) or djview (for djvu files), but have yet to find out how to do so on these programs (or found programs for these formats that allow custom keybindings). I've written about using emacs' doc-view to view all my files, but it can be sub-optimal:

Please do let me know if you know how to make custom keybindings on ghostview or djview (or similar, fast programs). Also let me know if I am not aware of any features in doc-view that would make my life easier. Thanks!