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

2dd on last line doesn't dd !?!

Expand Messages
  • Ron Aaron
    If I m on the last line of a buffer, and I do: 2dd nothing happens. Is this the correct behavior? -- Ron Aaron Moss Bay
    Message 1 of 14 , Jan 13, 2000
    • 0 Attachment
      If I'm on the last line of a buffer, and I do:
      2dd

      nothing happens. Is this the correct behavior?

      --
      Ron Aaron Moss Bay Engineering
      425-814-2748 Precision Crafted Software

      "If you won't be better tomorrow than you are today,
      what need have you for tomorrow?"
      R' Nahman of Bratslav
    • Aron Griffis
      ... /bin/vi on Tru64 will delete the line, so it appears that vim is incompatible here. -- Aron Griffis Compaq Computer Corporation, ZKO3-3/T30
      Message 2 of 14 , Jan 13, 2000
      • 0 Attachment
        On Thu, Jan 13, 2000 at 12:16:09PM -0800, Ron Aaron wrote:
        > If I'm on the last line of a buffer, and I do:
        > 2dd
        >
        > nothing happens. Is this the correct behavior?

        /bin/vi on Tru64 will delete the line, so it appears that vim is
        incompatible here.

        --
        Aron Griffis Compaq Computer Corporation, ZKO3-3/T30
        Tru64 Hardware Support 110 Spit Brook Rd, Nashua, NH 03062
        603/884-1276 http://bigfoot.com/~agriffis/
      • Ron Aaron
        ... Hmmm. But the idea would be, I think, repeat twice the dd . Or is it really delete two lines only ? As the other respondant pointed out, this is not
        Message 3 of 14 , Jan 13, 2000
        • 0 Attachment
          Ed Ralston <eralston@...> writes:
          >
          >vi on SunOS 5.6 has this same behaviour,
          >so my guess is that it's done this way for
          >compatibility (?)
          >

          Hmmm. But the idea would be, I think, 'repeat twice the 'dd'. Or is it
          really 'delete two lines only'?

          As the other respondant pointed out, this is not compatible with at least one
          other vi implementation -- but that's not so much the question as 'what is the
          behaviour which makes the most sense?'.

          Regards,
          Ron
        • Ed Ralston
          vi on SunOS 5.6 has this same behaviour, so my guess is that it s done this way for compatibility (?) Ed. ... From: v-ronaar@exchange.microsoft.com
          Message 4 of 14 , Jan 13, 2000
          • 0 Attachment
            RE: 2dd on last line doesn't dd !?!

            vi on SunOS 5.6 has this same behaviour,
            so my guess is that it's done this way for
            compatibility (?)

            Ed.

            -----Original Message-----
            From: v-ronaar@...
            [mailto:v-ronaar@...]
            Sent: 2000-01-13 15:16
            To: VIM developers
            Subject: 2dd on last line doesn't dd !?!


            If I'm on the last line of a buffer, and I do:
                    2dd

            nothing happens.  Is this the correct behavior?

            --
            Ron Aaron                                       Moss Bay Engineering
            425-814-2748                              Precision Crafted Software

            "If you won't be better tomorrow than you are today,
                                what need have you for tomorrow?"
            R' Nahman of Bratslav

          • Thomas Köhler
            On Thu, Jan 13, 2000 at 09:16:53PM +0100, ... Vim can t delete 2 lines, so it doesn t delete anything. As other vi clones show the same behaviour (nvi, elvis),
            Message 5 of 14 , Jan 13, 2000
            • 0 Attachment
              On Thu, Jan 13, 2000 at 09:16:53PM +0100,
              Ron Aaron <v-ronaar@...> wrote:
              >
              > If I'm on the last line of a buffer, and I do:
              > 2dd
              >
              > nothing happens. Is this the correct behavior?

              Vim can't delete 2 lines, so it doesn't delete anything. As other vi
              clones show the same behaviour (nvi, elvis), this seems to be vi
              compatible :-)

              CU,
              Thomas

              --
              Thomas Köhler Email: jean-luc@... | LCARS - Linux for
              <>< WWW: http://home.pages.de/~jeanluc/ | Computers on All
              IRC: jeanluc | Real Starships
              PGP public key: http://www.mayn.de/users/jean-luc/PGP-Public.asc
            • Bill McCarthy
              ... From the last line, 2dd does nothing. But go up a line and try 3dd -- works fine even though it can t delete 3 lines. It is not consistent.
              Message 6 of 14 , Jan 13, 2000
              • 0 Attachment
                On Thu, 13 Jan 2000 21:52:41 +0100, Thomas K�hler wrote:

                >On Thu, Jan 13, 2000 at 09:16:53PM +0100,
                >Ron Aaron <v-ronaar@...> wrote:
                >>
                >> If I'm on the last line of a buffer, and I do:
                >> 2dd
                >>
                >> nothing happens. Is this the correct behavior?
                >
                >Vim can't delete 2 lines, so it doesn't delete anything. As other vi
                >clones show the same behaviour (nvi, elvis), this seems to be vi
                >compatible :-)

                From the last line, 2dd does nothing. But go up a line and try 3dd --
                works fine even though it can't delete 3 lines. It is not consistent.
              • Ed Ralston
                Hmm, like I said before, SunOS 5.6 does the same thing. HOWEVER, if you re on the 2nd to the last line on SunOS and do a 3dd, nothing happens. On Vim, 2
                Message 7 of 14 , Jan 13, 2000
                • 0 Attachment
                  RE: 2dd on last line doesn't dd !?!

                  Hmm, like I said before, SunOS 5.6 does the same thing.

                  HOWEVER, if you're on the 2nd to the last line on SunOS
                  and do a "3dd," nothing happens.  On Vim, 2 lines are
                  deleted.  In general, on SunOS, if there aren't enough
                  lines to delete, nothing happens.  This happens in Vim
                  only on the last line.  So vim is inconsistent with
                  itself, and with other implementations...  Seems like
                  we'd want it to always do nothing, or always do something,
                  instead of the current multiple-personality disorder.

                  Ed.

                  -----Original Message-----
                  From: Thomas Köhler [mailto:jean-luc@...]
                  Sent: 2000-01-13 15:53
                  To: VIM developers
                  Subject: Re: 2dd on last line doesn't dd !?!


                  On Thu, Jan 13, 2000 at 09:16:53PM +0100,
                  Ron Aaron <v-ronaar@...> wrote:
                  >
                  > If I'm on the last line of a buffer, and I do:
                  >       2dd
                  >
                  > nothing happens.  Is this the correct behavior?

                  Vim can't delete 2 lines, so it doesn't delete anything. As other vi
                  clones show the same behaviour (nvi, elvis), this seems to be vi
                  compatible :-)

                  CU,
                  Thomas

                  --
                   Thomas Köhler Email:   jean-luc@...   | LCARS - Linux for
                       <><        WWW:  http://home.pages.de/~jeanluc/ | Computers on All
                                  IRC:             jeanluc             | Real Starships
                     PGP public key: http://www.mayn.de/users/jean-luc/PGP-Public.asc

                • Andy Kahn
                  ... Not quite. That behavior is probably only with Digital Unix 5.x, because with 4.x, 2dd behaves the same as vim. So it appears that Digital Unix 4.x and
                  Message 8 of 14 , Jan 13, 2000
                  • 0 Attachment
                    On Thu, Jan 13, 2000 at 03:21:52PM -0500, Aron Griffis wrote:
                    > On Thu, Jan 13, 2000 at 12:16:09PM -0800, Ron Aaron wrote:
                    > > If I'm on the last line of a buffer, and I do:
                    > > 2dd
                    > >
                    > > nothing happens. Is this the correct behavior?
                    >
                    > /bin/vi on Tru64 will delete the line, so it appears that vim is
                    > incompatible here.

                    Not quite. That behavior is probably only with Digital Unix 5.x,
                    because with 4.x, "2dd" behaves the same as vim. So it appears that
                    Digital Unix 4.x and 5.x are somewhat incompatible with itself, and
                    having worked on both, I can safely it's Tru. <cough>

                    regards,
                    --andy
                  • Bram Moolenaar
                    ... The original Vi which I use as a reference does not delete the text when trying to delete past the end of the file. In Vim it doesn t appear to be
                    Message 9 of 14 , Jan 14, 2000
                    • 0 Attachment
                      Aron Griffis wrote:

                      > On Thu, Jan 13, 2000 at 12:16:09PM -0800, Ron Aaron wrote:
                      > > If I'm on the last line of a buffer, and I do:
                      > > 2dd
                      > >
                      > > nothing happens. Is this the correct behavior?
                      >
                      > /bin/vi on Tru64 will delete the line, so it appears that vim is
                      > incompatible here.

                      The original Vi which I use as a reference does not delete the text when
                      trying to delete past the end of the file.

                      In Vim it doesn't appear to be consistent, since doing "3dd" on the last but
                      one line does delete the last two lines. Vi just beeps.

                      The reason is that "2dd" on the last line is translated to "d2$", and "2$" on
                      the last line fails, because it can't move to a next line. "3$" on the last
                      but one line works, because it can move one line.

                      Well, that's an explanation, but it's still not consistant. It's already in
                      the todo list:

                      7 Make "5dd" on last-but-one-line not delete anything (vi compatible).
                      Change cursor_down()??? Many other commands will change too: "5j", "c5j",
                      etc. Add flag in 'cpoptions'?

                      --
                      hundred-and-one symptoms of being an internet addict:
                      156. You forget your friend's name but not her e-mail address.

                      --/-/---- Bram Moolenaar ---- Bram@... ---- Bram@... ---\-\--
                      \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /
                    • Ron Aaron
                      [snip] ... My vote is that e.g. 3dd would delete three lines if possible. If there were only one line in a file, 3dd would delete it. If one were
                      Message 10 of 14 , Jan 14, 2000
                      • 0 Attachment
                        [snip]
                        >only on the last line. So vim is inconsistent with itself, and with other
                        >implementations... Seems like we'd want it to always do nothing, or always
                        >do something, instead of the current multiple-personality disorder.
                        >

                        My vote is that e.g. '3dd' would delete three lines if possible. If there
                        were only one line in a file, '3dd' would delete it. If one were positioned
                        on the last line of a large file, '3dd' would delete that line, and the two
                        lines preceding it.

                        I think this behaviour is consistent, and I believe it is what people would
                        *expect* to happen. It seems readily apparent that 'vi compatibility' in this
                        regard is a chimera.

                        Ron
                      • Vince Negri
                        ... positioned ... two ... ! Shurely shome mishtake. dd always deletes lines down from the cursor position. It should not start deleting lines _upward_ just
                        Message 11 of 14 , Jan 14, 2000
                        • 0 Attachment
                          > Ron Aaron [SMTP:ron@...] quoth:
                          > My vote is that e.g. '3dd' would delete three lines if possible. If there
                          > were only one line in a file, '3dd' would delete it. If one were
                          positioned
                          > on the last line of a large file, '3dd' would delete that line, and the
                          two
                          > lines preceding it.

                          !

                          Shurely shome mishtake.

                          "dd" always deletes lines down from the cursor position. It should
                          not start deleting lines _upward_ just because you're on the last line.

                          I would expect that "3dd" on the last line deletes the last line and
                          nothing else. The analogy I would draw is doing
                          3j
                          on the next-to-last line of the file. It moves to the last line of the file.
                          It doesn't beep, or move to the last line and bounce up again. It just
                          moves as many lines of the 3 as is possible.

                          Or indeed consider 0d3j which is effectively 3dd...

                          Vince



                          Legal Disclaimer: Any views expressed by the sender of this message are
                          not necessarily those of Application Solutions Ltd. Information in this
                          e-mail may be confidential and is for the use of the intended recipient
                          only, no mistake in transmission is intended to waive or compromise such
                          privilege. Please advise the sender if you receive this e-mail by mistake.
                        • Ron Aaron
                          ... Ok, you ve convinced me -- so it should delete from the current line, up to and including as many of count as possible. 3dd on the next to last line
                          Message 12 of 14 , Jan 14, 2000
                          • 0 Attachment
                            Vince Negri <vnegri@...> writes:
                            >> Ron Aaron [SMTP:ron@...] quoth:
                            >> My vote is that e.g. '3dd' would delete three lines if possible.

                            >"dd" always deletes lines down from the cursor position. It should
                            >not start deleting lines _upward_ just because you're on the last line.

                            Ok, you've convinced me -- so it should delete from the current line, up to
                            and including as many of 'count' as possible.

                            '3dd' on the next to last line would delete the last two lines of the file,
                            not the last three as I proposed earlier.

                            Sounds good -- Bram, what's the final verdict?

                            Ron
                          • Vince Negri
                            ... to ... I am not Bram :) but it sounds like a cpoption to me: setting (1) - do nothing, beep setting (2) - delete as many lines as possible, up to EOF.
                            Message 13 of 14 , Jan 14, 2000
                            • 0 Attachment
                              > Ok, you've convinced me -- so it should delete from the current line, up
                              to
                              > and including as many of 'count' as possible.

                              > Sounds good -- Bram, what's the final verdict?

                              I am not Bram :) but it sounds like a cpoption to me:

                              setting (1) - do nothing, beep
                              setting (2) - delete as many lines as possible, up to EOF.


                              Legal Disclaimer: Any views expressed by the sender of this message are
                              not necessarily those of Application Solutions Ltd. Information in this
                              e-mail may be confidential and is for the use of the intended recipient
                              only, no mistake in transmission is intended to waive or compromise such
                              privilege. Please advise the sender if you receive this e-mail by mistake.
                            • Bram Moolenaar
                              Ron Aaron - ... That 10dd deletes ten lines, or as many lines as there are below the cursor, is what most people would expect. The original Vi didn t delete
                              Message 14 of 14 , Jan 14, 2000
                              • 0 Attachment
                                Ron Aaron -

                                > >"dd" always deletes lines down from the cursor position. It should
                                > >not start deleting lines _upward_ just because you're on the last line.
                                >
                                > Ok, you've convinced me -- so it should delete from the current line, up to
                                > and including as many of 'count' as possible.
                                >
                                > '3dd' on the next to last line would delete the last two lines of the file,
                                > not the last three as I proposed earlier.
                                >
                                > Sounds good -- Bram, what's the final verdict?

                                That "10dd" deletes ten lines, or as many lines as there are below the cursor,
                                is what most people would expect.

                                The original Vi didn't delete any lines if there are not enough. This asks
                                for a flag in 'cpoptions'. I'll adjust the item in the todo list:

                                7 Make "5dd" on last-but-one-line not delete anything (Vi compatible).
                                Add flag in 'cpoptions' for this. When not present, "2dd" in the last
                                line should delete the last line.

                                --
                                hundred-and-one symptoms of being an internet addict:
                                168. You have your own domain name.

                                --/-/---- Bram Moolenaar ---- Bram@... ---- Bram@... ---\-\--
                                \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /
                              Your message has been successfully submitted and would be delivered to recipients shortly.