[vim/vim] :delete reports one fewer line when deleting the entire buffer (Issue #21049)

2 views
Skip to first unread message

Narendran Gopalakrishnan

unread,
Aug 14, 2026, 4:21:57 AM (2 days ago) Aug 14
to vim/vim, Subscribed
gnarendran created an issue (vim/vim#21049)

Steps to reproduce

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.

Expected behaviour

When :delete makes the buffer empty, it should correctly report the number of fewer lines, like in cases when buffer doesn't become empty.

Version of Vim

vim 9.2.920

Environment

Fedora44
XTerm(406)
xterm-256color
bash

Logs and stack traces


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.Message ID: <vim/vim/issues/21049@github.com>

Reply all
Reply to author
Forward
0 new messages