How to share one vimrc file among multiple clients?

后端 未结 8 565
天涯浪人
天涯浪人 2021-01-29 19:03

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 differen

相关标签:
8条回答
  • 2021-01-29 19:48

    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
    

    This way, 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 connection to the internet doesn't exist.

    The only requirement (apart from an active internet connection) is you need CURL installed.


    If you don't want to download the latest .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 online without having to commit anything but you can host your .vimrc file anywhere with a publicly accessible URL (Dropbox, Google Drive, GitHub, etc.)


    UPDATE (16/10/2017)

    Using the below updated curl command will always get fresh .vimrc from bitbucket. It will also timeout and 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
    
    0 讨论(0)
  • 2021-01-29 19:50


    There is also a very nice way to install plugins using Version Control, Since most of the VIM plugin are available on GITHUB it also help. Please see this Article which tells you how to keep your .VIM file synchronized using GIT, and load plugin as a sub module with the help of PATHOGEN plugin.

    Use GIT for Syncing VI plugins

    In short of what is mentioned in the vimcast and i am quoting from the Blog.

    1. Keep your dotfiles in git
    2. Install plugins as submodules using this commands
      git submodule add http://github.com/tpope/vim-fugitive.git bundle/fugitive
    0 讨论(0)
提交回复
热议问题