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

[BUG?] redir tromping yank register 0?

Expand Messages
  • Tim Chase
    Can anyone reproduce the following, and if so, is this a bug? vim -u NONE -N (start vim with no .vimrc in nocompatible mode) ihello (insert some text on
    Message 1 of 5 , Jul 2, 2014
    • 0 Attachment
      Can anyone reproduce the following, and if so, is this a bug?

      vim -u NONE -N

      (start vim with no .vimrc in 'nocompatible' mode)

      ihello<esc>

      (insert some text on the first line)

      Y

      (yank the line)

      :reg

      (correctly shows that "" and "0 contain the yanked line)

      :redir @"

      (redirect into the scratch register)

      :reg

      Hey, where did my 0 register go?! I expected the scratch register to
      get tromped, but not my yank register. I didn't do any yanking, and
      the help says """

      Numbered register 0 contains the text from the most recent yank
      command, unless the command specified another register with ["x].

      """

      It appears that ":redir @[a-z]" is somehow treated as a yank.

      -tim




      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Fredrik Andersson
      I can confirm the described behaviour on 7.4.52 ... -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the
      Message 2 of 5 , Jul 3, 2014
      • 0 Attachment
        I can confirm the described behaviour on 7.4.52


        On Thu, Jul 3, 2014 at 4:25 AM, Tim Chase <vim@...> wrote:
        Can anyone reproduce the following, and if so, is this a bug?

          vim -u NONE -N

        (start vim with no .vimrc in 'nocompatible' mode)

          ihello<esc>

        (insert some text on the first line)

          Y

        (yank the line)

          :reg

        (correctly shows that "" and "0 contain the yanked line)

          :redir @"

        (redirect into the scratch register)

          :reg

        Hey, where did my 0 register go?!  I expected the scratch register to
        get tromped, but not my yank register.  I didn't do any yanking, and
        the help says """

        Numbered register 0 contains the text from the most recent yank
        command, unless the command specified another register with ["x].

        """

        It appears that ":redir @[a-z]" is somehow treated as a yank.

        -tim




        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Bram Moolenaar
        ... I can see the 0 register changed when redirecting to the register, but not when redirecting to another register. This behavior may not be exactly
        Message 3 of 5 , Jul 6, 2014
        • 0 Attachment
          Tim Chase wrote:

          > Can anyone reproduce the following, and if so, is this a bug?
          >
          > vim -u NONE -N
          >
          > (start vim with no .vimrc in 'nocompatible' mode)
          >
          > ihello<esc>
          >
          > (insert some text on the first line)
          >
          > Y
          >
          > (yank the line)
          >
          > :reg
          >
          > (correctly shows that "" and "0 contain the yanked line)
          >
          > :redir @"
          >
          > (redirect into the scratch register)
          >
          > :reg
          >
          > Hey, where did my 0 register go?! I expected the scratch register to
          > get tromped, but not my yank register. I didn't do any yanking, and
          > the help says """
          >
          > Numbered register 0 contains the text from the most recent yank
          > command, unless the command specified another register with ["x].
          >
          > """
          >
          > It appears that ":redir @[a-z]" is somehow treated as a yank.

          I can see the "0 register changed when redirecting to the "" register,
          but not when redirecting to another register.

          This behavior may not be exactly right, but changing it most likely
          causes more trouble than it solves.

          --
          ARTHUR: Listen, old crone! Unless you tell us where we can buy a shrubbery,
          my friend and I will ... we will say "Ni!"
          CRONE: Do your worst!
          "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ an exciting new programming language -- http://www.Zimbu.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Urtica dioica
          Let s set up a 2-line file: hello world and have fun with the q command. You need to restart Vim before every example. q ~q ... ddq ~q still matches 1, and
          Message 4 of 5 , Jul 6, 2014
          • 0 Attachment
            Let's set up a 2-line file:

            hello
            world

            and have fun with the q command. You need to restart Vim before every example.

            q"~q

            :di reveals ~ has been written to "" and "0, which isn't that unusual.

            ddq"~q

            "" still matches "1, and q" only wrote to "0. That's odd.

            ddq1~q

            This wrote to "" and "1, but "0 is untouched.

            The "" register behaves differently depending on whether you use delete/yank, :redir, :let, or q. (Am I missing any?) I don't know the internals, but I think of it as a pointer to the register the text is actually in. It has a special affinity for "0.

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          • Bram Moolenaar
            ... Something else happens: You record to the register you specify. The register points to the last used yank or delete register, recording does not change
            Message 5 of 5 , Jul 8, 2014
            • 0 Attachment
              Urtica Dioica wrote:

              > Let's set up a 2-line file:
              >
              > hello
              > world
              >
              > and have fun with the q command. You need to restart Vim before every example.
              >
              > q"~q
              >
              > :di reveals ~ has been written to "" and "0, which isn't that unusual.
              >
              > ddq"~q
              >
              > "" still matches "1, and q" only wrote to "0. That's odd.
              >
              > ddq1~q
              >
              > This wrote to "" and "1, but "0 is untouched.
              >
              > The "" register behaves differently depending on whether you use
              > delete/yank, :redir, :let, or q. (Am I missing any?) I don't know the
              > internals, but I think of it as a pointer to the register the text is
              > actually in. It has a special affinity for "0.

              Something else happens: You record to the register you specify. The ""
              register points to the last used yank or delete register, recording does
              not change it. Thus if you happen to record to the register the ""
              points to, then "" is also changed.

              --
              Q: How do you tell the difference between a female cat and a male cat?
              A: You ask it a question and if HE answers, it's a male but, if SHE
              answers, it's a female.

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ an exciting new programming language -- http://www.Zimbu.org ///
              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

              --
              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            Your message has been successfully submitted and would be delivered to recipients shortly.