Reputation: 4360
Is it possible to use variables or lists to pass patterns to vim's autocmd?
Here is an example:
" Automatically source .vimrc if there have been any changes
let candidates = [ ".vimrc", "_vimrc", "vimrc", ".gvimrc", "_gvimrc", "gvimrc" ]
augroup AutoSourceVimrc
autocmd!
autocmd BufWritePost candidates so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END
The example above does not work - unfortunately.
Upvotes: 1
Views: 413
Reputation: 196466
Here is a simpler version of your command:
augroup AutoSourceVimrc
autocmd!
autocmd BufWritePost *vimrc execute "source " . expand("<afile>")
augroup END
Upvotes: 2