Is there some way in which I can read the filename being passed to source, when the SourcePre autocommand is triggered?
eg:
au SourcePre */plugin/*.vim set runtimepath=/usr/share/vim/vim71/{INSERT-Plugin-Dir-Name}
source /root/.vim/bundle/minibufexpl.vim_-_Elegant_buffer_explorer/plugin/minibufexpl.vim
I’d like to replace this {INSERT-Plugin-Dir-Name} with "minibufexpl.vim_-_Elegant_buffer_explorer"
Use
<afile>to get name of the file being sourced. You can useexpand()to turn it into a full path and get the bit you want. For example, in your line:You could do:
The
:pturns it into a full path (in case you docd /path/to/plugin,:source filename.vim); each:hstrips one part of the path off the end.Note that this won’t work in a
:setline. Use:let-&instead:See: