Thursday, August 26, 2010

Re: vim and encryption

Ответ на сообщение «Re: vim and encryption»,
присланное в 22:08:06 25 августа 2010, Среда,
отправитель Tobias Klausmann:

1. All options either exist in current vim session or not. This cannot be
changed.
2. ``echo exists("&key")'' echoes 1 as expected. ``exists("key")'' is a check
for either global or local to function varible ``key'', not for an option.
3. You can check for availability of encryption with ``has("cryptv")''. But this
will not let you check whether file is encrypted.
4. What you want is probably ``if !empty(&key)''. My vim echoes five stars when
I set key and nothing when key is empty. Though five stars are not your
password, but they are definitely not an empty string, so empty(&key) will
return 0 if key is not set.

Текст сообщения:
> Hi!
>
> On Wed, 25 Aug 2010, ZyX wrote:
> > On Wed, 25 Aug 2010, Tobias Klausmann wrote:
> > > All that said, I'd still like to use it this way. What I have
> > > been unable to accomplish is keeping vim from writing a viminfo
> > > file. At first I tried this in vimrc:
> > >
> > > if exists("key")
> > >
> > > let viminfo=""
> > >
> > > endif
> > >
> > > This does not work. Also, using "set noviminfo" and "let
> > > viminfo=n/dev/null" won't work either. In all cases, my edit
> > > commands were recallable after quitting vim and starting it
> > > again.
> >
> > You forgot to add an ampersand: you should use either
> >
> > set viminfo=
> >
> > or
> >
> > let &viminfo=""
> >
> > . Now you are setting only global variable g:viminfo.
>
> Done that, no luck though: apparently, checking for the existance
> of "key" does not work - the variable's contents is "hidden" as
> the help text explains. Unfortunately, this also means that
> exists() doesn't see it in this case. Thus, I need another way of
> detecting that vim is in encryption mode.
>
> Any ideas?
>
> Regards,
> Tobias

No comments: