Hi,

Gary Johnson wrote:
> 
> 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.

as a first reaction I wanted to give this explanation, too, but then
I checked it and $VARIABLE was interpolated into the path option.
(The reason that made me stop writing this was that

  :e $HOME/.vimrc

works. If I am not mistaken environment variables are expanded in
ex-commands, but Vim's variables (pre-defined or user-defined) are
not. Thus

  :let variable = $VARIABLE
  :set path+=variable

does not work.)

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

Yeah, that's right. With options I prefer :let over :exe and use :exe
only where other commands are involved.

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us.     (Calvin)

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to