Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Same .vimrc, two different computers

Tags:

vim

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.

like image 400
zeroDivisible Avatar asked Jun 29 '09 05:06

zeroDivisible


People also ask

Where should we need to create .vimrc file?

On CentOS 7 and RHEL 7, the system wide configuration file for Vim is in /etc/vimrc. You can also do user specific configuration of Vim. All you have to do is to create a . vimrc file in the HOME directory of the user than you want to configure Vim for and add the required Vim configuration options there.

Where is vimrc stored?

Vim's user-specific configuration file is located in the home directory: ~/. vimrc , and Vim files of current user are located inside ~/. vim/ . The global configuration file is located at /etc/vimrc .

Where is the vimrc file on Windows?

vim/ directory ($HOME/vimfiles/ for MS-Windows). That makes it easy to copy it to another system.

How do I create a .vimrc file in Linux?

vimrc using vim. In vim, add the commands that you know you want to put in, then type :wq to save the file. Now open vim again. Once in vim you can just type: :scriptnames to print a list of scripts that have been sourced.


2 Answers

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

like image 88
Sam Liao Avatar answered Nov 15 '22 13:11

Sam Liao


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")
like image 25
ojblass Avatar answered Nov 15 '22 13:11

ojblass