Tip #334: Loading scripts in .vimrc safely
tip karma |
Rating 33/11, Viewed by 748
|
created: |
|
September 30, 2002 9:59 |
|
complexity: |
|
basic |
author: |
|
[email protected] (Francis) |
|
as of Vim: |
|
6.0 |
If you copy your .vimrc to many places, you might get a problem:
writing a portable .vimrc is sometimes painful.
Maybe in some places you have latest VIM6.1, and in some places
you have VIM 5.x. And maybe you have some favorite scripts in
your own computer while other places does not.
Here're some tips and examples on writing portable .vimrc that will not make error
messages when environment changes:
(1) Check version:
if version >= 600
set foldcolumn=2
endif
(2) Use environment variables:
source $VIMRUNTIME/vimrc_example.vim
(3) Loading scripts(especially useful for scripts just merged into standard macros):
if filereadable($VIMRUNTIME . "/macros/matchit.vim")
source $VIMRUNTIME/macros/matchit.vim
endif
<<Syntax-based folding for c/c++/java |
Copy C++ function declaration into implementation file >>
Additional Notes
|