3

我必须输入

gvim --servername xdvi toto.tex

启用从 xdvi 到 Latex 的反向搜索。

有没有办法将其封装在.vimrc:当 vim 检测到 .tex 文件时,autocmd 将 servername 设置为 vimrc ?一旦启动vim似乎为时已晚,或者?

如果不在.vimrc,在哪里?

4

1 回答 1

3

The special v:servername variable is read-only; you cannot change it from within Vim. If you need a certain servername, that has to be specified on startup via the --servername argument.

To avoid the additional typing, I would suggest a special shell alias (on Unix) or small batch wrapper (on Windows). Depending on how crucial this is, you could even add some scripting logic to check for .tex arguments, and only then set the servername.

The only way to achieve this from within Vim would be forking a new instance of Vim (via system()), passing all arguments plus the servername argument, and then closing the original Vim instance via :quit. But that's very cumbersome and not as simple to implement.

于 2012-11-01T14:19:02.233 回答