Using latexmk with gvim + xdvi

Tuesday, December 22nd, 2009

To use latexmk with gvim + xdvi, I have the following lines in my .Xdefaults file:

xdvi.editor: gvim --servername xdvi --remote +%l %f
xdvi.watchFile: 1

One has to issue

xrdb -merge .Xdefaults

after changing the .Xdefaults file. The second line lets xdvi check every one second whether the dvi file has been updated and reloads it. Probably it’s not necessary because latexmk is updating the viewer anyway, but why not? Now, one only needs

latexmk -pvc -dvi latex-file.tex

Every time the tex file gets saved, latexmk will latex the file and update the viewer. Used with the forward and inverse search, you can save hours. Great!

Update on the usage of gvim + xdvi

Monday, December 21st, 2009

This is an update to the entry about gvim + xdvi. I found out why the forward search did not work: It was as always a trivial reason… I forgot to set the viewer for dvi to xdvi. So, the following lines in .vimrc will enable forward and inverse search with gvim and xdvi

let g:Tex_CompileRule_dvi = 'latex --interaction=nonstopmode --src-specials $*'
let g:Tex_ViewRule_dvi = 'xdvi'
let g:Tex_ViewRuleComplete_dvi = 'xdvi -editor "gvim --servername xdvi --remote +\%l \%f" $* &'

(I forgot the second line last time)

You have to launch gvim and xdvi using

gvim --servername xdvi file.tex
xdvi -editor "gvim --servername xdvi --remote +%l %f" file.dvi

These days, I’m using latexmk and it’s great! Next time, I’ll write down how to use it with gvim and xdvi.

Encoding settings in Vim and LaTeX to UTF-8

Sunday, November 23rd, 2008

My current setting for file encoding in vim (via hoepfl.de)

set encoding=utf-8
set fileencoding=
setglobal fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,latin1
set termencoding=latin1

  • New files are created in utf-8.
  • Existing files are treated as utf-8-bom, utf-8 and latin-1.
  • If the encoding of the file cannot be determined uniquely among those three, utf-8 is chosen.
  • If the encoding is none of those three, then the file is interpreted as latin-1.

Using this setting and using the following line in the LaTeX document

\usepackage[utf8]{inputenc}

one does not have to type for example Gau{\ss} or K\”ahler, but just Gauß and Kähler. This comes in handy particularly if one’s using the spell checker of Vim.

Changing the warning setting of the vim-latex

Wednesday, September 24th, 2008

If I compile LaTeX files using vim-latex, very often vim opens package files, e.g. xy.sty etc., because the LaTeX compiler had some – not that important for the most of the time – warnings. Then I have to re-open the tex file. It is really annoying. However to avoid this, you can add the following line to the .vimrc file

let g:Tex_IgnoredWarnings =
\'Underfull'."\n".
\'Overfull'."\n".
\'specifier changed to'."\n".
\'You have requested'."\n".
\'Missing number, treated as zero.'."\n".
\'There were undefined references'."\n".
\'Latex Warning:'."\n".
\'Citation %.%# undefined'
let g:Tex_IgnoreLevel = 8

I inserted the ‘Latex Warning:’ line and changed the ignore level to 8. The default is 7.

Forward & inverse searching with Vim, Xdvi and LaTeX

Tuesday, September 23rd, 2008

I’ve finally found out how to do the forward & inverse searching with (g)vim in combination with vim-latex and xdvi. For forward searching one adds the following line to the .vimrc

let g:Tex_CompileRule_dvi = 'latex --interaction=nonstopmode --src-specials $*'

For inverse searching one opens gvim using the following option

gvim --servername xdvi file.tex

and the xdvi using

xdvi -editor "gvim --servername xdvi --remote +%l %f" file.dvi

Yes, there’s only one dash in front of the editor option!

Additionally, if one wants the \lv command calling xdvi with this option, one inserts the following line to the .vimrc file

let g:Tex_ViewRuleComplete_dvi = 'xdvi -editor "gvim --servername xdvi --remote +\%l \%f" $* &'

It took quite some time to get the inverse searching working… Anyway, it’s working now: \ls for the forward and control-click for the inverse searching. It’s just GREAT!