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?
$VIMFILES
variable both to set uprtp
andpath
for Vundle and to setundodir
for persistent undo. Without such a variable, I'd need vimfile-directory-finding logic in both of those parts of my Vim setup.