8

I've specified the .vimrc and .vim location.

In my vimrc file, I found the runtimepath can be set as a absolute value likes:

set rtp+=~/.marslo/.vim/bundle/vundle

But it CANNOT be set as a variable, likes:

let vudpath = expand(~/.marslo/.vim/bundle/vundle)
set rtp+=vudpath

Why's that? Is there any way can make runtimepath be set as variable?

2 Answers 2

14

As romainl said, you have :let &option. But in your case, as you want to add a path to a list of paths it would be:

exe 'set rtp+=' . expand('~/.marslo/.vim/bundle/vundle')

That will only add the path if it isn't present in &rtp yet.

Or (note the use of the .= operator instead of the += one)

let &rtp .= ','.expand('~/.marslo/.vim/bundle/vundle')

However this time if it is already present in your &rtp, it will be added again. As such, prefer using :execute+:set in your specific case.

2
  • You are awsome!!! Two ways are all work for me!!! Thanks a lot!
    – Marslo
    Sep 4, 2014 at 10:01
  • 3
    What's not being said here, is that your problem had nothing to do with "let". Most ex commands do NOT expand variable names, i.e. they do not take an expression. "set" is not one of the commands that expands expressions (variables).
    – Ben
    Sep 10, 2014 at 1:27
2

You have two options:

execute "set option=" . expression
let &option = expression
2
  • If the let &option = expression, why call vundle#begin(bud) works fine?
    – Marslo
    Sep 3, 2014 at 9:54
  • Okay, you means, if the option using += method, then the value CANNOT be variable?
    – Marslo
    Sep 3, 2014 at 9:56

You must log in to answer this question.

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