简体   繁体   中英

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? 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.

And according to source code serverRegisterName() in if_xcmdsrv.c is called from three places:

  • main() function
  • X11 main window initialization
  • GTK+ main window initialization

So the answer to your question is no, you can't set server name in your .vimrc or anywhere else except command line arguments.

For a sufficiently new of vim there's the function 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. according to VimTeX documentation

So you can simply start vim with no servername and start one in vimrc.

Note : Vim will automatically change the servername (append 1, 2, etc.) to avoid conflict if there are multiple running Vim instances.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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