When :delete deletes all lines in a buffer, the reported number of fewer lines is one less than the number of lines actually deleted.
For example, with a four-line buffer, deleting 1,$ removes all four lines, but reports 3 fewer lines. Deleting 2,$ from the same four-line buffer correctly reports 3 fewer lines.
Minimal reproduction:
function! CmdMsg(cmd) abort " First force the preceding change into a separate undo block. let &g:undolevels = &g:undolevels let l:msg = '' redir => l:msg execute 'silent ' . a:cmd redir END echomsg printf('Message from "%s": ', a:cmd) . trim(l:msg) endfunction call setline(1, ['one', 'two', 'three', 'four']) call CmdMsg('1,$delete') call CmdMsg('undo') call CmdMsg('2,$delete') call getchar() quit!
Output of:
vi --clean -u theAboveScript
Message from "1,$delete": 3 fewer lines
Message from "undo": 4 more lines; before #2 0 seconds ago
Message from "2,$delete": 3 fewer lines
The first command deletes all four lines, leaving the buffer's required empty line, but the message appears to report the change in buffer line count rather than the number of lines actually deleted.
The second deletion is a useful comparison: it deletes three lines and correctly reports 3 fewer lines.
When :delete makes the buffer empty, it should correctly report the number of fewer lines, like in cases when buffer doesn't become empty.
vim 9.2.920
Fedora44
XTerm(406)
xterm-256color
bash
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()