tags:

views:

225

answers:

3

I have one folder synced between two computers (using one of online sync tools). I have gVim installed in this folder and I am wondering, is there a way, that I can distinguish those two computers in _vimrc file?

I know that testing with

if has("win32")
    ...
elseif has("macunix")
    ...
endif

I can check different operating systems - but is there an similar function/variable to test ie. name of the PC on which gVim is running?

I will also mention, that both PC's are running Windows XP.

+16  A: 

There is a vim builtin routine named hostname() to get the host machine's name.

arsane
Thank You, that is just what I was looking for.
zeroDivisible
+3  A: 

As an additional tip you can store your vimrc file on the net and load it (you may break down its functionality by hostname() as outlined above.

fu! gNetVimrc(hhtpvimrc)
source $VIMRUNTIME/plugin/netrwPlugin.vim
Nread a:*hhtpvimrc*
let tf = tempname()
save! tf
source tf
delete(tf)
ene
endf

Add this to your .vimrc on all computers you want to share the vimrc file for

:call gNetVimrc("http://www.mydomain.com/myvimrc")
ojblass
+1  A: 

Personally I put my dotfiles in git and maintain branches per differing computer.

Daenyth