Timothy Madden wrote:
On 14.03.2012 19:40, Charles Campbell wrote:
Timothy Madden wrote:
On 14.03.2012 18:21, Sergey Khorev wrote:
:let&rtp = '~/.vim,' .&rtp
Or even set rtp+=~/.vim or set rtp^=~/.vim :)
But I want to insert the ~/.vim/ dir inside &rtp in the right place
before $VIMRUNTIME, and only if it is not included in &rtp already.
set rtp+= ... will not append if already ... is already present
set rtp^= ... will prepend, but will not prepend if ... is already
present
For this I need to process every dir in &rtp and compare it with both
~/.vim/ and $VIMRUNTIME. And for this I need the canonical path names.
Are you worried about whether or not ~/.vim is already in $VIMRUNTIME?
$VIMRUNTIME has already been expanded, so if ~/.vim duplicates one of
the $VIMRUNTIME entries, it won't prepend with ^= and won'tappend
with += .
Ok, than
:set rtp ^= ~/.vim
:set rtp += ~/.vim
will take care of any duplicates.
But if ~/.vim is not already in &rtp, that it will be prepended (or
appended) to the entire list, and that is not what I want. I would
like to insert it in the list right before $VIMRUNTIME.
(by the way, $VIMRUNTIME is not &runtimepath, it is only one of the
directories in &runtimepath, and it usually appears there in the
middle of the list).
The following snippet will prepend $HOME/.vim just before whatever
$VIMRUNTIME expanded to in your runtimepath, but only if it wasn't
already somewhere in your runtimepath:
let tildotvim= expand("$HOME")."/.vim"
if &rtp !~ '\%(^\|,\)'.tildotvim.'\%(,\|$\)'
let &rtp= substitute(&rtp,expand("$VIMRUNTIME"),tildotvim.',&',"")
endif
Regards,
Chip Campbell
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php