Vim/Neovim — Managing Multiple Project Settings

alpha2phi
5 min readMar 20, 2021

Managing project-specific settings for Vim/Neovim projects.

Photo by Octavian Dan on Unsplash

Overview

I talked about managing multiple databases and projects in my previous articles. On some occasions, you may have a need to manage multiple projects with configurations only specific to the projects.

In this article, let’s explore the available options we have in Vim/Neovim. I will start with the simplest solution and then move on to explore plugins we can use.

exrc, vimrc, nvimrc

If you set the exrc option in your .vimrc or init.vim file, Vim/Neovim will execute .exrc (for both Vim/Neovim), .vimrc (Vim), .nvimrc (Neovim) found in the current directory when Vim/Neovim is started.

set exrc

For security reasons, you may also want to set the secure option together (refer to :h secure)

set secure exrc

When secure is on, :autocmd, shell and write commands are not allowed in .nvimrc, .vimrc and .exrc in the current directory and map commands are displayed.

From the documentation for the secure option,

When on, “:autocmd”, shell and write commands are not allowed in
“.nvimrc” and “.exrc” in the current directory and map commands are
displayed. Switch it off only if you know that you will not run into
problems, or when the ‘exrc’ option is off. On Unix this option is
only used if the “.nvimrc” or “.exrc” is not owned by you. This can be
dangerous if the systems allows users to do a “chown”. You better set
‘secure’ at the end of your |init.vim| then
.
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.