Vim Tips Wiki

Backing up and commenting vimrc

1,612pages on
this wiki
Revision as of 19:40, May 12, 2014 by Fritzophrenic (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Tip 807 Printable Monobook Previous Next

created October 22, 2004 · complexity basic · author zzapper · version 5.7

Backing up vimrcEdit

You can always easily reinstall Vim however the loss of your vimrc file could be a catastrophe!

So remember to back it up in several places. One good place would be to store it as say vimrc.txt, on your free webspace then you can recover it from anywhere. Make sure there is no confidential data in your .vimrc of course.

A more robust method is to version control your .vimrc file and .vim folder. There are many version control systems available, including centralized systems like SVN or CVS, however for config files like the .vimrc and installed plugins, a distributed version control software (DVCS) like git or Mercurial makes more sense, so that you are not required to set up/communicate with a server. With this method the real .vimrc file and .vim folders are part of a version control repository, and you create symbolic links to them if needed.

One of the benefits of using version control system instead of just backups, is the ease of sharing the same configuration between several computers, and syncing changes. If desired, you can push to a DVCS hosting service like github or BitBucket, but you could just as easily share DVCS repositories using email, flash drives, and the like.

Commenting vimrcEdit

Commenting is simple: put a double quote to the left of the text you want to comment.

For example:

" open search result in a new window (the comment)
map zm :let @/=expand("<cword>") <BAR> split <BAR> execute 'normal n'<CR>

Something else you may find useful, is to store as a comment a few notes on how you configure FireFox, Cygwin etc. for using Vim, as these details are easy to forget.


The two topics in this tip (and the suggestions below) are unrelated. Perhaps we should split this tip into multiple at some point, or maybe there's a merge target. Or it could become a collection of tips for organizing/maintaining your Vim config.

You can also use folds in vimrc, which tends to do wonders for organization and readability as well.

In your vimrc you can read an environment variable to allow different command depending on which OS or PC you're on and thus have same vimrc.

if $USER == 'davidr'
echo "on home pc"
set .. etc
echo "on work pc"
set .. etc

Around Wikia's network

Random Wiki