sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

localvimrc : load subdirectory specific vimrc files

 script karma  Rating 247/89, Downloaded by 4732    Comments, bugs, improvements  Vim wiki

created by
Markus Braun
script type
Sometimes, when you work on different projects, you have the problem, that they use different indentation, tab expansion and so on. You need vimrc for each project that overrides your prefered settings from ~/.vimrc

This plugin searches for local vimrc files in the file system tree of the currently opened file. By default it searches for all ".lvimrc" files from the file's directory up to the root directory and loads them in reverse order. The filename and amount of loaded files are customizable through global variables.

For security reasons it the plugin asks for confirmation before loading a local vimrc file and loads it using :sandbox command. The plugin asks once per session and local vimrc before loading it, if the file didn't change since previous loading.

It is possible to define a whitelist and a blacklist of local vimrc files that are loaded or ignored unconditionally.

If you think this plugin could be improved, fork on GitHub and send a pull request or just tell me your ideas.

GitHub: https://github.com/embear/vim-localvimrc
Bitbucket: https://bitbucket.org/embear/localvimrc
install details
localvimrc is now distributed as a vimball (see :help vimball)

vim localvimrc.vmb
:so %

and that's all!

Rating scripts is only available on the HTTPS page

script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
localvimrc.vmb 2.5.0 2017-03-09 7.2 Markus Braun - g:localvimrc_whitelist and g:localvimrc_blacklist now takes optionally a list of regular expressions.
- add convenience variables g:localvimrc_script_unresolved and g:localvimrc_script_dir_unresolved.
- add ability to view local vimrc before sourcing when g:localvimrc_ask is enabled.
- emit autocommands before and after sourcing files.
- add g:localvimrc_file_directory_only to limit sourcing to local vimrc files in the same directory as the edited file.
- add LocalVimRCFinish function to stop loading of remaining local vimrc files from within a local vimrc file.
- add unit tests.
localvimrc.vmb 2.4.0 2016-02-05 7.2 Markus Braun - add setting g:localvimrc_event which defines the autocommand events that trigger local vimrc file loading.
- make it possible to supply a list of local vimrc filenames in g:localvimrc_name
- ask user when sourcing local vimrc fails and g:localvimrc_sandbox and g:localvimrc_ask is set whether the file should be sourced without sandbox.
- don't lose persistence file on full partitions.
- fix a bug where local vimrc files are sourced in wrong order when some of them are symlinks to a different directory.
localvimrc.vba 2.3.0 2014-02-06 7.2 Markus Braun - private persistence file to enable persistence over concurrent vim instances.
- add convenience variables g:localvimrc_sourced_once and g:localvimrc_sourced_once_for_file.
localvimrc.vba 2.2.0 2013-11-09 7.2 Markus Braun - remove redraw calls for better performance and fixing a bug on windows.
- load local vimrc on event BufWinEnter to fix a bug with window local
- add g:localvimrc_reverse to change order of sourcing local vimrc files.
- add convenience variables g:localvimrc_file, g:localvimrc_file_dir,
  g:localvimrc_script and g:localvimrc_script_dir.
localvimrc.vba 2.1.0 2012-09-25 7.2 Markus Braun - add possibility to make decisions persistent
- use full file path when storing decisions
localvimrc.vba 2.0.0 2012-04-05 7.2 Markus Braun - added g:localvimrc_whitelist and g:localvimrc_blacklist settings.
- ask only once per session and local vimrc before loading it, if it didn't change.
localvimrc.vim 2758 2009-05-11 7.0 Markus Braun - source .lvimrc in a sandbox to better maintain security, configurable using g:localvimrc_sandbox
- ask user before sourcing any local vimrc file, configurable using g:localvimrc_ask  
localvimrc.vim 1870 2007-09-28 7.0 Markus Braun - new configuration variable g:localvimrc_name to change filename
- new configuration variable g:localvimrc_count to limit number of loaded files
localvimrc.vim 1613 2007-04-05 7.0 Markus Braun - switched to arrays in vim 7
- escape file/path names correctly
localvimrc.vim 1.2 2002-10-09 6.0 Markus Braun Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo