Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share one vimrc file among multiple clients?

Tags:

vim

I am not a very orderly person at times and I often find myself in the situation of losing my old fully tweaked vimrc file and having to start over all again. Or having different versions of vimrc files on different clients. Since this mess is getting out of hand for me, I would like to know if there is a good way of managing my vimrc file.

My first initiative is put my _vimrc on subversion (Google Code) and I intend to maintain it. Other ideas are welcome.

Update

I settled with the following solution:

  • Upload the .vimrc and .gvimrc to an online code repository in a directory called Vim. Use filename _vimrc and _gvimrc so that they aren't hidden, and for compatibility with Windows.

  • Checkout the repository on the target system

  • On Mac OSX/Linux create symbolic links:

    ~ $ ln -s my_repository/Vim/_vimrc $HOME/.vimrc

    ~ $ ln -s my_repository/Vim/_gvimrc $HOME/.gvimrc

  • On Windows I checkout the Vim folder over the one in the Program Files directory. SVN complains about already existing files there, but you can add those to the ignore list.

like image 916
StackedCrooked Avatar asked Jun 23 '09 08:06

StackedCrooked


People also ask

Where are vimrc files saved?

The system vimrc should normally be left unmodified and is located in the $VIM * directory.

What type of file is vimrc?

Settings file used by Vim, a text editing program often used by source code developers and system administrators; saves the default settings for the editor when it is opened; allows users to customize options for the editor. VIMRC files are saved in a plain text format.

Is vimrc the same as INIT Vim?

vimrc is the default configuration file for vim. For neovim, simply copy the file to ~/. config/nvim/init. vim (You may need to create the nvim directory first).


3 Answers

I use Dropbox. I've created a folder vim in my dropbox, which contains my .vimrc (actually: vimrc.vim) and colors, plugin, etc. directories.

Dropbox pushes all these files to all my computers (home, work, laptop, Bootcamp), so every time I want to change my vimrc, I can do so and I don't have to worry about copying it to the correct directory or checking out the file from SVN or anything. Everything happens automagically!

My actual .vimrc contains only what's necessary to load the stuff I have in my Dropbox. On OSX and Linux, it looks like this:

set runtimepath^=~/Dropbox/vim
source ~/Dropbox/vim/vimrc.vim

On Windows, like this:

set runtimepath^=$HOME/My\ Documents/My\ Dropbox/vim
source $HOME\My Documents\My Dropbox\vim\vimrc.vim

And that's it!

(Actually, I put the vimrc's above in my Dropbox as well, so I don't have to remember them whenever I set up a new computer or re-install an old one.)

The free version of Dropbox will give you a 30 day revision history, the paid one will give you full revision history. Note that if you're on Linux, it's easiest if you use GNOME, for which Dropbox has a nice client.

Conditional Settings

If you have slight configuration changes you would like to use on different machines this is a handy solution:

create a small function in each of your .vimrc files to return the type of system you are on:

fun! MySys()
    return 'linux'
endfun 

then in your global vimrc.vim file:

if MySys() == "linux"
    set backupdir=./.backup,/tmp
    set directory=./.backup,/tmp 
elseif MySys() == "windows"
    set backupdir=$HOME/AppData/Local/backup,$HOME/AppData/Local/tmp
    set directory=$HOME/AppData/Local/backup,$HOME/AppData/Local/tmp
endif

Dropbox Alternatives

There are many cloud storage and syncing services, Dropbox is just one example. OpenSource services such as http://sparkleshare.org/ and http://one.ubuntu.com exist, but you are encouraged to search the internet for a solution that will fit your needs best.

like image 158
jqno Avatar answered Oct 07 '22 17:10

jqno


I put these files in a source control system, subversion specifically, but it doesn't matter which. That gives me a history of all such configuration files, and it's just a matter of checking out the config file when I want the same one on a new/other machine or useraccount.

like image 20
nos Avatar answered Oct 07 '22 17:10

nos


Use git. I have my .vim and .vimrc files in a git repo, and I branch them for different systems. So i have on branch for lappy, one branch for debian-based , one for RH based etc.

I fire the repos up onto all my servers, and merge changes around as I see fit. Then, when i lose one, any of the others will serve. .vim/.vimrc are an excellent examples of files that should be in a DVCS.

like image 13
chiggsy Avatar answered Oct 07 '22 19:10

chiggsy