Loading ...
Sorry, an error occurred while loading the content.

46235Re: Bug: ":confirm w" only works once

Expand Messages
  • A.J.Mechelynck
    Feb 28, 2007
    • 0 Attachment
      Yakov Lerner wrote:
      > On 2/27/07, Michael Schaap <vim@...> wrote:
      >> Hi,
      >> When editing a read-only file, ":confirm w" only works the first time
      >> you use it in a session. The second time you try to use it, you simply
      >> get an error message, as if you didn't use ":confirm".
      >> The same problem occurs when using ":set confirm".
      >> To recreate:
      >> $ echo Hello > hello.txt
      >> $ chmod 400 hello.txt
      >> $ vim -u NONE hello.txt
      >> :set nocompatible " or you won't be able to overwrite at all
      >> A, World<Esc>
      >> :confirm w
      >> 'readonly' option is set for "qq".
      >> Do you wish to write anyway?
      >> (Y)es, [N]o: y
      >> A!<Esc>
      >> :confirm w
      >> E505: "qq" is read-only (add ! to override)
      >> This is using 7.0.203, but it has been happening for quite a while. An
      >> old 6.3 does the same thing.
      > You see this behaviour because the first :confirm w(or ':w!',
      > for this matter) resets the 'ro' option. This is the reason the 2nd
      > ':confirm w' doesn't ask anything. You can see yourself if you do
      > 'set ro?' before and after first ':confirm w'.
      > :set ro?
      > readonly
      > :confirm w
      > ... (Y)es, [N]o: y
      > :set ro?
      > noreadonly
      > As you see, the 'ro' option has been reset. This is
      > the reason the following ':confirm w' does not ask for
      > the confirmation.
      > AFAIK, vim always behaved this way -- that is,
      > the ':w!' would reset the ro flag.
      > But notice that inserting text into 'ro' file does not reset the 'ro'
      > flag by itself.
      > It warns (modifying the readonly file). but the 'ro' flag remains. After
      > :w!, 'ro' flag is reset.
      > Yakov

      Why then does the second ":confirm w" give 'E505: "qq" is read-only (add ! to
      override)' ?

      Best regards,
      Your fault: core dumped
    • Show all 7 messages in this topic