is it possible to specify vim servername in .vimrc, or somewhere else, according to filetype?

岁酱吖の 提交于 2019-12-10 18:26:02

问题


I have to type

gvim --servername xdvi toto.tex

to enable inverse search from xdvi to latex.

Is there a way to encapsulate this in .vimrc: when vim detects the .tex file, an autocmd sets the servername to vimrc ? It seems it is too late once vim is launched, or?

If not in .vimrc, where ?


回答1:


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.



来源:https://stackoverflow.com/questions/13178335/is-it-possible-to-specify-vim-servername-in-vimrc-or-somewhere-else-according

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!