VIM - Plugin - dirsettings
This is a simple plugin that allows per directory settings for your favourite editor VIM. This plugin is mainly inspired by the already existing plugin named dirsettings, see:
But this plugin goes a little step further. It walks the whole directory tree up to the root and on its way back it sources each found ".vimrc". This allows to overwrite specific settings even in subdirectories which inherit the settings of each parent directory. Furthermore if a .vim folder is found in one of the parent directories it is added to the runtime path and therefore treated as the .vim folder inside the home dir.
Additionally it checks for a ".vim/tags" file and appends it to the tag list. This is better than a "tags" file in the current working directory for source control reasons.
The plugin uses four autocommands (
BufNewFile, BufReadPre, BufWinEnter,
BufEnter) with the autocommand group dirsettings (by default). It calls an
internally used function to load directory specific settings, and sets a flag
for the own autocommands so that they are not executed twice which would result
in an endless recursion. After the flag was set, the current event is recalled
which executes all other defined autocommands. This explains why the call to
dirsettings#Install() should be the very first command in your
Otherwise it could happen that previously defined autocommands are called
This is the tested way to install and use the plugin, however it should work with every other bundle manager or even without one.
Change into the directory where pathogen expects your bundles:
git clone <github-url> ./dirsettings.git
Create a symbolic link to the autoload vimscript provided by this package:
ln -s <path-of-this-package>/autoload/dirsettings.vim ~/.vim/autoload/
Or copy the provided autoload vimscript into your autoload directory:
cp <path-of-this-package>/autoload/dirsettings.vim ~/.vim/autoload/
Add the following content at the top of your
.vimrc(if you want to be able to modify the runtimepath before pathogen is invoked, it is important that this statement is executed before
Tips and tricks
- In order to set directory specific settings, try to use always
set. Otherwise these settings will affect other buffers.
Global settings affect all buffers
It is perfectly fine to set global options within a per-directory-vimrc-file but you have to understand that these global options will affect all buffers of the currently running vim instance. As I know it is not possible to use global options on a buffer level. Feel free to send me an email if you have any suggestions to solve this issue. However, if you want to use this plugin to run a vim instance inside a directory which uses global per-directory-settings which are fine to affect all buffers inside this vim instance and you run another vim instance inside another directory which does not load these directory-settings, it works like a charm.
Thanks to Jakob Westhoff for adding support for .vim folders.