On 2/4/07, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:
Yakov Lerner wrote:
> I was searching for the reason why  initial-position-
> memory stopped working for me recently. It turned out the wrong
> ownership/perms of the ~/.viminfo file. ~/.viminfo existed,
> but was not readable and not writable by me.
> (vim does not warn, not in the slightest form).
>
> So I I want to insert the check for this special case into .vimrc.
> ( It happened once, it can happen again (maybe it happened to me more
> than once.
> I remember other mysterios cases when inititl-position stopped working
> and I did not know why)).
>
> So I need the fileexist() function in it's purest form. Because this
> check is not good:
>    if filereadable(expand("~/.viminfo")) && !
> filewritable(expand("~/.viminfo")) |
>        ... warn...|endif
> This is not good. I need
>    if fileexist(expand("~/.viminfo")) && !
> filewritable(expand("~/.viminfo")) | ... warn...|endif
> How can I check that file exists even though it is not readable ?
>
> Thanks
> Yakov
>

IIUC, Vim doesn't allow you to know of the existence of a file to which you
have neither read nor write permission

Just found how to do it:

if glob("~/.viminfo") != "" && ! filewritable(expand("~/.viminfo")) ...
Works nice. glob("~/.viminfo") returns non-empty string if file
exists, even if it is unreadable and unwritable.

Yakov

Reply via email to