On 15.03.2012 17:17, Charles Campbell wrote:
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


Thank you for the idea, which I think I understand except for the trailing '&' in the argument to substitute, but the idea here was that any of the
   - $HOME/.vim
   - $VIMRUNTIME
   - &rtp components
might include the same directory name but with different case.

Such a case would be legal and would work on case-insensitive file systems like NTFS, but yet no regular expression can detect and correctly process this case.

Also I think expand("$VIMRUNTIME") is being used as a regexp here, and for that it would need some escaping to translate it into a RE that only matches a fixed string.

Thank you,
Timothy Madden

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