Code Monkey home page Code Monkey logo

Comments (9)

chrisbra avatar chrisbra commented on June 12, 2024

That is not how the normal d command is supposed to work. Posix states:

  1. If there are less than count -1 lines after the current line in the edit buffer, it shall be an error.

from vim.

k-takata avatar k-takata commented on June 12, 2024

2. If there are less than count -1 lines after the current line in the edit buffer, it shall be an error.

Then, the following behavior doesn't follow POSIX?

Another reason why I think this is incorrect bechavious is because in this example:

line 1
line 2
line 3| <- cursor
line 4

when you type like 6dd the outcome is:

line 1
line 2

from vim.

k-takata avatar k-takata commented on June 12, 2024

Then, the following behavior doesn't follow POSIX?

Ah, when :set compatible, 6dd doesn't delete the last two lines.

from vim.

itchyny avatar itchyny commented on June 12, 2024

In compatible mode (especially when cpo includes -), both cases do not delete the lines. In nocompatible mode, as the original intention of this report, I think it is more consistent to delete the last line when the cursor is at the last line. However, as we can tell from the fact this behavior is related to cpo--, it seems to be related to the beep alarmed when we try to move down from the last line. I'm not sure we can only change the behavior of [count]dd at the last line without messing the common code.

from vim.

V1K1NGbg avatar V1K1NGbg commented on June 12, 2024

Yes, that makes sense when in compatible mode but in nocompatible mode even considering everything, I still don't understand how this is not a bug.

it seems to be related to the beep alarmed when we try to move down from the last line. I'm not sure we can only change the behavior of [count]dd at the last line without messing the common code.

yes that could be the case, but it also could be that when it counts rows, it takes the rows that are below and when it does the calculations mentioned here: #14769 (comment) it gets a negative number and then it bugs somehow

from vim.

V1K1NGbg avatar V1K1NGbg commented on June 12, 2024

That is not how the normal d command is supposed to work. Posix states:

  1. If there are less than count -1 lines after the current line in the edit buffer, it shall be an error.

can you give more of an explenation on why it is that way

from vim.

chrisbra avatar chrisbra commented on June 12, 2024

can you give more of an explenation on why it is that way

You should ask this the authors of POSIX :)

In any case, I don't think changing this behaviour will be even considered, since this would be a backward incompatible change and is probably how original vi behaves.

from vim.

itchyny avatar itchyny commented on June 12, 2024

We're talking about non-POSIX behavior of Vim, because 6dd at :$-2 in nocompatible mode deletes the lines in contrary to the POSIX statements. Should 6dd at :$ behave like how it already works with 6dd at :$-2, or not? But this raises another question to the opener, should dj at :$, and dk at :1 delete the current line?

from vim.

chrisbra avatar chrisbra commented on June 12, 2024

Yes, my comment was directed directly at the OP, who questioned the POSIX behaviour. Regarding the dd behaviour it may seem inconsistent, but I'd prefer not to change it now, because for one, this is backwards incompatible change and secondly, it raises other questions as mentioned already.

from vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.