sponsor Vim development Vim logo Vim Book Ad

basic Tip #807: Backing up and commenting .vimrc

 tip karma   Rating 0/9, Viewed by 1009 

created:   October 22, 2004 4:28      complexity:   basic
author:   zzapper      as of Vim:   5.7

Hi,
1) BACKING UP .VIMRC :You can always easily reinstall VIM however the loss of your .vimrc could be a catastrophe!

So remember to variously back it up. One good place is to store it as, say vimrc.txt, on your free webspace then you can recover it from anywhere.

2) COMMENTING .VIMRC : My .vimrc now has 348 lines, but about 50% is deadwood because it's no longer clear to me what it's supposed to do, wish I'd thought of this tip years ago!. In .vimrc you use the double quote as a comment

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

 rate this tip  Life Changing Helpful Unfulfilling 

<<Always keep quickfix window at specified height | how to overwrite a visual-block of text with another such block >>

Additional Notes

Anonymous, October 22, 2004 8:16
one thing that a co-worker turn me on to is storing your home dir in cvs.
That way not only can you recover from loss of files, but you can version them, and not
have to worry about reconciling changes you made to a file on one machine vs changes
you made on another.

It make things incredibly easy to manage and you can configure you environment on a new
machine in seconds.
sreny at rpyrpgvpjvmneq dot pbz (Rot13ed), October 24, 2004 12:18
You can also use folds in .vimrc, which tends to do wonders for organization and readability as well.
[email protected], October 26, 2004 3:30
Have a look at at your .vimrc now, is it ordered,commented? do you remember what your maps are supposed to do?
How about spring cleaning your .vimrc today?
What would happen if you had a disk-crash is it backed up?
anon, October 26, 2004 7:20
I divide my .vimrc (all dot files) into
personal/vimrc (in cvs) and  work/vimrc (gpl).
zzapper, November 2, 2004 12:07
In your .vimrc you can read an environment variable to allow different command depending on which O/S or PC you're on
and thus have same .vimrc

if $USER == 'davidr'
echo "on home pc"
set .. etc
else
echo "on work pc"
set .. etc
endif
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo