How to share one vimrc file among multiple clients?

I am not a very neat person from time to time, and I often find myself in a situation of losing my old completely modified vimrc file and having to start all over again. Or have different versions of vimrc files for different clients. As this mess gets out of me, I would like to know if there is a good way to manage my vimrc file.

My first initiative puts my _vimrc on subversion (Google Code), and I intend to support it. Other ideas are welcome.

Update

I decided to use the following solution:

  • Download .vimrc and .gvimrc to the online code repository in the directory named Vim . Use the file _vimrc and _gvimrc so that they are not hidden and are compatible with Windows.

  • Checkout the repository in the target system

  • Mac OSX / Linux creates symbolic links:

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

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

  • On Windows, I check the Vim folder above the folder in the Program Files folder. SVN complains about existing files, but you can add them to the ignore list.

+51
vim
Jun 23 '09 at 8:49
source share
8 answers

I am using Dropbox . I created a vim folder in my Dropbox that contains my .vimrc directories (actually: vimrc.vim ) and colors , plugin , etc.

Dropbox pushes all these files to all of my computers (home, work, laptop, Bootcamp), so every time I want to change my vimrc , I can do this and I don’t have to worry about copying the correct directory or checking the file from SVN or something else. Everything happens automatically!

My actual .vimrc contains only what is needed to download the material that I have in my Dropbox. On OSX and Linux, it looks like this:

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

On Windows, for example:

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

What is it!

(Actually, I put vimrc higher in my Dropbox, so I don’t need to remember them every time I set up a new computer or reinstall an old one.)

The free version of Dropbox will give you a 30-day change history, the paid one will give you a complete change history. Please note: if you are running Linux, this is easiest if you are using GNOME, for which Dropbox has a nice client.

Conditional settings

If you have small configuration changes that you would like to use on different machines, this is a convenient 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 

Alternatives to Dropbox

There are many cloud storage and sync 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 the solution that best suits your needs.

+83
Jul 26 '09 at 15:54
source share

I put these files in a version control system, in particular subversion, but it doesn’t matter which one. This gives me a history of all such configuration files, and it's just a matter of checking the configuration file when I want it to be on a different / different computer or user account.

+20
Jun 23 '09 at 9:52
source share

Use git. I have .vim and .vimrc files in the git repository and I am deploying them for different systems. So I have a branch for lappy, one branch for debian-based, one for RH, etc.

I run repositions on all my servers and merge the changes around as I see fit. Then, when I lose one, any of the others will serve ..vim / .vimrc are great examples of files that should be in DVCS.

+13
Jun 23 '09 at 8:59
source share

What works best for me is to put the following in my .vimrc file:

 set nocompatible let $localcloudpath = $MYVIMRC . '_cloud' let $cloudurl = '!curl https://bitbucket.org/<USERNAME>/vimrc/raw/master/global -o '. $localcloudpath silent execute $cloudurl source $localcloudpath 

Thus, every time I run vim, it downloads and uses the latest .vimrc file from my BitBucket repository. It will use the last downloaded .vimrc if the Internet connection does not exist.

The requirement is only (except for an active Internet connection) you need CURL .




If you don't want to load the last .vimrc every time, then just comment out the curl line:

 " let $cloudurl = '!curl https://bitbucket.org/<USERNAME>/vimrc/raw/master/global -o '. $localcloudpath 

BitBucket is also a personal preference, because I can easily edit the file on the Internet without any obligation, but you can place your .vimrc file anywhere with a public URL (Dropbox, Google Drive, GitHub, etc.)




UPDATE (10/16/2017)

Using the updated curl command below will always get a fresh .vimrc from the bitpack. It will also be disconnected and will use the last downloaded .vimrc_cloud if you are offline or on a slow connection.

 let $cloudurl = '!curl -H "Cache-Control: no-cache" --max-time 10 https://bitbucket.org/<USERNAME>/vimrc/raw/master/global -o '. $localcloudpath 
+4
Jan 14 '16 at 14:09
source share

Like others, they said: use a version control system.

Here is a project that is easy to develop and expand: http://github.com/ryanb/dotfiles

It handles not only vim.rc, but also any configuration and comes with a configuration script.

+3
Jun 26 2018-10-06T00: 00Z
source share


There is also a very good way to install plugins using version control, since most of the VIM plugin is available on GITHUB, it also helps. See this article for how to save a .VIM file using GIT and load the plugin as an add-on using the PATHOGEN plugin.

Use GIT to Sync VI Plugins

In addition to what is mentioned in vimcast, and I quote a blog.

+2
Apr 26 '13 at 10:53 on
source share

If you use vundle, you can do it this way. Git supports vimrc and all other settings in sync, and vundle keeps track of your plugins / scripts.

Sync vim with vundle and git

+1
Oct 11 '13 at 11:59 on
source share

I keep a copy of my point files in google docs.

0
Jun 23 '09 at 10:15
source share



All Articles