On 07/10/08 16:08, Bob Hiestand wrote:
> On Tue, Oct 7, 2008 at 8:57 AM, A. S. Budden<[EMAIL PROTECTED]> wrote:
>> 2008/10/7 Bob Hiestand<[EMAIL PROTECTED]>:
>>> You could do something like the following (untested):
>>>
>>> :auto BufRead * if expand('%') =~ '^/some/directory'|set
>>> ft=somefiletype|endif
>> Wouldn't expand('%:p') be better?
>>
>> :help expand()
>
> I don't think it matters, as the matching is just testing to see if
> the file name starts with that path.
I think it does, as the problem was that the match was not found when
typing the filename without a path because the file's directory was
already current.
Example:
:lcd /some/dir
:e filename.ext
then expand('%') is "filename.ext", not "/some/dir/filename.ext". If you
test (expand('%') =~ '^/some/dir') it'll return 0 i.e. FALSE.
OTOH under the same circumstances expand('%:p') is
"/some/dir/filename.ext" and it should work.
However, I believe you should test for =~ '^some/dir/' with an ending
slash, otherwise you'll also find a match for /some/direction/file.txt
Best regards,
Tony.
--
If they can make penicillin out of moldy bread, they can sure make
something out of you.
-- Muhammad Ali
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---