[vim/vim] Feat: Allow 'exrc' to search recursively upward for local configuration files (Issue #21218)

3 views
Skip to first unread message

rbalaji-cell

unread,
Sep 4, 2026, 1:58:59 AM (yesterday) Sep 4
to vim/vim, Subscribed
rbalaji-cell created an issue (vim/vim#21218)

Unable to load local root .vimrc when opening files from nested project subdirectories via 'exrc',
which limits having project specific settings.

Problem

The current exrc feature only searches for a local configuration file in the immediate current working directory (pwd). If a user opens a file nested deep inside a project's subdirectories (e.g., project/src/components/file.v), a local .vimrc located at the project root (project/.vimrc) is entirely missed.

With modern project structures, users often launch Vim or open files from subdirectories, rendering exrc ineffective without external plugins or complex autocommands.

Solution / Proposal

Introduce a built-in mechanism or a new option (for example, set exrcupward or modifying exrc behavior) that allows Vim to search recursively upwards for a local configuration file until it hits the root directory or the user's home directory.

Alternative or Current Workaround

Currently, users have to write custom Vimscript in their global ~/.vimrc to mimic this behavior:

function! LoadLocalVimrc()
  let l:local_vimrc = findfile('.vimrc', expand('%:p:h') . ';')
  if !empty(l:local_vimrc) && fnamemodify(l:local_vimrc, ':p') != expand('~/.vimrc')
    execute 'source ' . fnameescape(l:local_vimrc)
  endif
endfunction
autocmd BufNewFile,BufRead * call LoadLocalVimrc()

Having this natively optimized in C or as a core option like set exrc=upward would immensely benefit anyone working in multi-layered language projects (like Verilog, C++, or Web development).


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21218@github.com>

Reply all
Reply to author
Forward
0 new messages