Adding specific configs for a specific project in vim is actually quite easy. The first thing you need to realize is that vim doesn’t really have the notion of a project, so we’ll rely on folder structures and paths.
Setting up the environment
The first thing to do is to call a function to set up our environment whenever we open vim, open a file on a new buffer or open a new file.
That function will then check the current path and conditionally load config files.
1 2 3 4 5 6
project-names don’t have to be the same, but I find it makes sense if they
do. And they usually refer to the root directory of the project.
The specific configs
We can the add regular vim configs the
project-name.vim config file. Something
that I find useful is to map shortcuts to commonly used directories (kind of a
poor man’s Rails.vim
Now every time you write
%a in the command line it will be replaced with
app/resources/scripts/apps/. So you can just
:e %a and auto complete your
way into the file you want.
You can also add other settings such as number of spaces per tab, which may vary from project to project. It’s as easy as: