sponsor Vim development Vim logo Vim Book Ad

localvimrc : load subdirectory specific vimrc files

 script karma  Rating 320/117, Downloaded by 8997  Comments, bugs, improvements  Vim wiki

created by
Markus Braun
 
script type
utility
 
description
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
 
install details
localvimrc is now distributed as a vimball (see :help vimball)

vim localvimrc.vmb
:so %
:q

and that's all!
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
localvimrc.vmb 3.2.0 2024-10-25 7.4 Markus Braun - add command |LocalVimRCDebugDump| to write debug messages to a file.
- add support for Lua scripts when using Neovim.
- for search path fallback to the current working directory, it checks for an existing directory of the current buffer rather than an empty directory name.
- fix a bug with printing error messages
localvimrc.vmb 3.1.0 2020-05-20 7.4 Markus Braun - add option to disable probing of Python versions
- prevent recursive sourcing of local vimrc files
- better handling of syntax errors in sourced local vimrc files
- compatibility with current development versions of Vim
localvimrc.vmb 3.0.1 2018-08-21 7.4 Markus Braun - fix a compatibility issue with unavailable |v:true| and |v:false| in Vim version 7.4
localvimrc.vmb 3.0.0 2018-08-17 7.4 Markus Braun IMPORTANT NOTICE: The checksum algorithm was changed since last release thus all persistent answers are invalid and asked again on loading a local vimrc file for the first time after updateing the plugin.

- use SHA256 as for calculating checksums and use FNV-1 as fallback.
- add command |LocalVimRCCleanup| to remove all unusable persistence data.
- add command |LocalVimRCForget| to remove persistence data for given files.
- add command |LocalVimRCDebugShow| to show debug messages.
- add setting |g:localvimrc_debug_lines| to limit the number of stored debug messages.
localvimrc.vmb 2.7.0 2018-03-19 7.4 Markus Braun - add setting |g:localvimrc_enable| and commands |LocalVimRCEnable| and |LocalVimRCDisable| to globally disable processing of local vimrc files.
- add setting |g:localvimrc_event_pattern| to change the pattern for which the autocommand is executed.
localvimrc.vmb 2.6.1 2018-02-20 7.4 Markus Braun - fix a bug with missing uniq() in Vim version 7.4
localvimrc.vmb 2.6.0 2018-01-22 7.4 Markus Braun - add command LocalVimRCEdit to edit sourced local vimrc files for the current buffer.
- bug fixes
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
  settings.
- 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: 44.220.255.141

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.
   
Vim at Github