LeoNerd.org.uk

Additional vimrc files

I find this script quite useful whenever I'm working on open source code, or other code that wasn't initially written by me. It allows me to place an extra .vimrc file in the source directory, or its immediate parent, and have the settings contained there apply to any file I open from that directory.

As a safety check, it ensures that any files it is about to load are owned by the user, to prevent a maliscious user placing a specially-constructed .vimrc in their home directory and having me view a file there; an operation that under normal circumstances is safe. This test is implemented with a tiny C library wrapped in its own plugin. And by "tiny", I mean it's 22 lines long. The compiled library is less than 7k on my system.

As a further safety feature when working on source code to which other users have write access but the files are still owned by the local user (e.g. public CVS / Arch / etc... controlled projects), a .vimrc file in your control can be marked:

let g:additionalrc_stop = 1
In the presence of such a mark, no scripts nested any further will be loaded. Typically such a mark will exist in a .vimrc file that is a sibling to the checked-out source code. This means that any .vimrc files contained in the checked-out code will not be loaded, but custom settings in the marked file (which you directly control, as it is not in the checked-out area) will be loaded, as they are known to be safe.

This script, therefore, differs from the exrc setting in vim in two ways. First, the extra .vimrc files can exist anywhere below the edited files, not just in the same directory. Secondly, the extra security features described above mean it is much safer to leave enabled when working with "public" code.

To build the filecheck library, unpack the tarball into your .vim/plugin directory and run make. No special dependancies are required.