Vim is an amazing editor and I have been using it for almost 5 years now. I am so used to vim that when I open a file in any other editor I type something and hit :w to save. ( Vim users know what I am talking about ). Over the years every one have their own settings, vim scripts (Plugins), themes etc. And every now and then you find some interesting setting which you want to add to your config (vimrc) or some new plugin for css3. Taking all your settings along with you is a pain if you didn’t sync them some where. I work in different hosts for different projects and keeping Vim in sync across is not easy. This is where Vundle and your favorite version control come into picture. The solution is simple and straight forward.You sync it somewhere using version control and get it to your working environment where you want to sync.
I use Git to sync it online. You are free to use any version control. Now what does Vundle do? Well Git keeps your Vimrc and other stuff like themes etc in sync and Vundle manages your plugins. Vundle is a package manager for vim, and these days almost all plugins are hosted at Git. So Vundle makes them easy to install,update or remove. All you need to do is add
Bundle 'mattn/emmet-vim' to install emmet plugin into your vim.
Sync Vim online
To sync vim online you have 2 steps. One is setting up your repo in github and getting your vim ready. Two is syncing when needed.
Setting up your Vim:
mv .vimrc ~/.vim/.vimrc
ln -s ~/.vim/.vimrc ~/.vimrc
Now Set up your Git:
git add --all
git commit -m "First commit for syncing dot vim"
Now create a guthub repo as you have a local repo ready. You can do that using this link. Read the Make a new repository on GitHub section and after creating a repo get the repo url usually
Now with this url add it to git remote
git remote add origin email@example.com:username/repository-name.git
git push origin master
Now your vimrc and other settings in your vim is stored in github. Now you need to manage plugins so install vundle.
see link for more installation help.
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
And add these lines to .vimrc
set nocompatible " be iMproved
filetype off " required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " let Vundle manage Vundle " required! Bundle 'gmarik/vundle' filetype plugin indent on " required!
To install bundles you add something like this to your vimrc
Bundle 'tpope/vim-fugitive' Bundle 'Lokaltog/vim-easymotion'
Now launch vim and run
Now you don’t want git to track your bundles as Vundle does the job for you. so create a
.gitignore file and add these lines to the file to tell git to ignore these files.
Now part 2. Setting sync in your other environment. Go to your environment where you want to sync vim and do the following
1) Cloning your dotvim. The repo that you created while setting up your git. git clone https://github.com/username/repository-name.git 2) soft link your vimrc ln -s ~/.vim/.vimrc ~/.vimrc 3) Seting up Vundle git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle 4) Installing the packages open vim and execute :BundleInstall
And voila… Your Vim is in sync!