Applying Settings in vimrc Or gvimrc Based on v:servername

14 views
Skip to first unread message

joh...@nacs.net

unread,
Feb 11, 2020, 1:36:06 PM2/11/20
to Vim mailing list
While working on a Windows machine, I found that I could
selectively load settings or plugins based on the Vim
servername by do a regular expression check against the
v:servername variable right in vimrc.

Example:
if v:servername =~ '^\cHPWORK\d*'
ru HP/HPSpecificPlugin.vim
endif

I had been relying on this featured when sharing a vimrc
file for XWindows under Linux. What I found is that this
technique does not seem to work. I traced in the Vim
source code and it seems like v:servername is set fairly
late in start up process for Vim after the script files
have been run. Thus when vimrc is executed v:servername
is blank and all these v:servername checks are false.

Is there a place in the startup process or a sensable
technique under XWindows to trigger loading something
globally based on the v:servername value? I am using this
technique as an alternative to an auto command that
assumes a particular filename or file extension.

Tony Mechelynck

unread,
Feb 11, 2020, 1:41:17 PM2/11/20
to vim_use, Vim mailing list
Try placing the check in an autocommand for the VimEnter event, which
is triggered at the very end of startup. The autocommand can be
defined in your vimrc.

Best regards,
Tony.
Reply all
Reply to author
Forward
0 new messages