vim

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.


Solution

  • 2023 update

    As pointed out by @user202729 in his answer (give him credit), it's possible to do since 8.0.0475 patch (18 March 2017) by starting Vim with --servername= (by default some unique name is generated) and then using call remote_startserver('TEX') in vimrc.

    Original (outdated) answer from 2012

    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:

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