简体   繁体   English

在 vimrc 中设置服务器名而不是命令行开关

[英]Setting servername in vimrc as opposed to command line switch

Is it possible to set vim's servername from my vimrc instead of using the --servername command line switch?是否可以从我的 vimrc 设置 vim 的服务器名而不是使用--servername命令行开关? If I try one of如果我尝试其中之一

set v:servername="TEX"
let v:servername="TEX"

I get unknown option error and cannot overwrite read-only variable error respectively.我收到未知选项错误并且无法分别覆盖只读变量错误。

According to documentation ( :help v:servername ) the v:servername variable is read only. 根据文档( :help v:servername ), v:servername变量是只读的。

And according to source code serverRegisterName() in if_xcmdsrv.c is called from three places: 根据源代码, if_xcmdsrv.c serverRegisterName()从三个地方调用:

  • main() function main()函数
  • X11 main window initialization X11主窗口初始化
  • GTK+ main window initialization GTK +主窗口初始化

So the answer to your question is no, you can't set server name in your .vimrc or anywhere else except command line arguments. 因此,您的问题的答案是否定的,您不能在.vimrc或除命令行参数之外的任何其他地方设置服务器名称。

For a sufficiently new of vim there's the function remote_startserver .对于一个足够新的 vim 有函数remote_startserver

                    *remote_startserver()* *E941* *E942*
remote_startserver({name})
        Become the server {name}.  This fails if already running as a
        server, when |v:servername| is not empty.

        Can also be used as a |method|: >
            ServerName()->remote_startserver()

Available since Vim version 8.0.475.自 Vim 8.0.475 版起可用。 according to VimTeX documentation根据 VimTeX 文档

So you can simply start vim with no servername and start one in vimrc.所以你可以简单地启动没有服务器名的 vim 并在 vimrc 中启动一个。

Note : Vim will automatically change the servername (append 1, 2, etc.) to avoid conflict if there are multiple running Vim instances.注意:如果有多个运行的 Vim 实例,Vim 将自动更改服务器名称(附加 1、2 等)以避免冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM