On 2009-09-23, Jürgen Krämer wrote:
> Steven Woody wrote:
> :let &path = &path . ',' . substitute($VARIABLE, ' ', '\\ ', 'g')
>
> > This works!! Thanks. But I've not quite understand :
> > 1. why use let instead of 'set'? what's the difference?
>
> Because the spaces in $VARIABLE need to be escaped. This is not
> automatically done with
>
> set path+=$VARIABLE
Not only that, but set won't accept an expression on the right.
That's often the reason for using let instead of set. You could use
exe to evaluate the set command with the expression, like this,
exe 'set path+=' . $VARIABLE
but that doesn't seem to me as clean as
let &path .= ',' . $VARIABLE
even considering the need to explicitly append the comma.
I just noticed another difference between set and let in the above
example. If 'path' already includes "somepath",
set path+=somepath
will not add a second instance of "somepath" to 'path' whereas
let &path .= ",somepath"
will.
Regards,
Gary
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---