On Wed, 14 Mar 2012, 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).

Right, so is there any reason you don't have control over what's being added to &rtp?

I.e.  If you're using some kind of plugin management, just do:

==> in your .vimrc/_vimrc <==

" 'rtp' contains $VIMRUNTIME by default...
" 'rtp' contains $HOME/vimfiles and $VIM/vimfiles by default...

" this next section might depend on recent changes... (I think vimfiles " is used if it exists, and .vim otherwise)
"
" if vimfiles exists, it will have been used rather than .vim
" otherwise, &rtp should already contain .vim
if (exists(expand('~/vimfiles')))
        " then add ~/.vim before and ~/.vim/after after
        se rtp^=~/.vim
        se rtp+=~/.vim/after
endif

" then let plugin management do its thing
" ...presumably it's what's messing up your preferred ordering
=============================

--
Best,
Ben

--
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

Reply via email to