1

I want to set a $VIMFILES variable in my vimrc file to determine in a non-platform-specific way the file path of my vimfiles directory (a la How do I get Vim home directory?). This should be trivial (in fact, I think it should be a built-in variable), but I can't figure out a robust way to do it. The method using a plugin requires you to put any code that actually uses this variable in your after directory, which (in my opinion) makes the plugin almost useless. The method using if has to determine the operating system and manually set the variable seems absurdly fragile and tedious.

So I'd like to just make the assumption that the first component of the default value of the runtimepath option is the vimfiles directory I want.

However, I have no idea how to extract the first component from rtp. This, again, seems like it should be trivial, but &rtp[0] expands to the first character of the runtimepath, because apparently &rtp is actually a string, even though it's clearly semantically a list (!!?).

So...how do I get the first component of the runtimepath? Is there a better way to do this?

2
  • Out of curiosity, what problem are you trying to solve?
    – romainl
    Commented Jun 3, 2014 at 21:11
  • I use the $VIMFILES variable both to set up rtp and path for Vundle and to set undodir for persistent undo. Without such a variable, I'd need vimfile-directory-finding logic in both of those parts of my Vim setup. Commented Jun 3, 2014 at 21:19

1 Answer 1

1

I think I've got it:

set rtp&
let $VIMFILES=split(&rtp,",")[0]

Still seems overly manual, but it's not as ugly as I feared.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .