19.02.09

Vim settings per directory

When hacking on b2evolution using vim, I often forget to ":set noet" (to not expand tabs) and it's really annoying to change this global setting everytime I open a b2evo related file.

According to the mantra, to search for a shortcut when a task becomes repetitive, I've finally searched for it and found a plugin, which looks for _vimrc_local.vim files (in the parent directories (and $HOME)).

Now, I can have a single _vimrc_local.vim file in the directory where all my b2evo related directories/branches reside - and override my global settings therein; It gets sourced/executed whenever I'm opening a file "below".

For more information see the Question on Stack Overflow and the actual plugin by Luc Hermitte. Thanks! :)

Update: as noted on Reddit, you could also use the following code in a vimrc file (e.g. ~/.vimrc):

:au! BufRead,BufNewFile /path/to/project/* setlocal noet

I still like the approach of having local override files in the directory structure though, which might come in handy for projects: if somebody has installed the plugin already there's no need to edit any .vimrc file (if the project ships the _vimrc_local.vim file in the project's root directory).

No feedback yet

Leave a comment


Your email address will not be revealed on this site.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)
You can just use your OpenID to provide your name, e-mail and url.
Seitenleiste