[vim/vim] fix(tutor): set buftype to 'nowrite' instead of 'nofile' (PR #18613)

19 views
Skip to first unread message

Phạm Bình An

unread,
Oct 20, 2025, 11:27:26 PM (12 days ago) Oct 20
to vim/vim, Subscribed

Problem:
After I have opened the tutor with :Tutor, then I close its window with :q, then if I run :Tutor to open the tutor again, it will open an empty buffer instead of the tutor content. This is a very confusing behavior.

Related issue neovim/neovim#36228

Solution:
I believe the point of set buftype=nofile is just to prevent users from accidentally writing changes to the tutor file, so why not use nowrite instead?


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/18613

Commit Summary

  • b0e5d75 fix(tutor): set buftype to 'nowrite' instead of 'nofile'

File Changes

(1 file)

Patch Links:

—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613@github.com>

Phạm Bình An

unread,
Oct 21, 2025, 5:51:21 AM (11 days ago) Oct 21
to vim/vim, Push

@brianhuster pushed 1 commit.

  • a4b5bc4 fix(tutor): set buftype to 'nowrite' instead of 'nofile'

—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613/before/b0e5d75267be441eb42890ee1065270353029f31/after/a4b5bc4fd4b33672afcd2f57334609aeece1a231@github.com>

Maxim Kim

unread,
Oct 21, 2025, 6:32:00 PM (11 days ago) Oct 21
to vim/vim, Subscribed
habamax left a comment (vim/vim#18613)

I can't reproduce it with the steps provided.

https://asciinema.org/a/tgKyl8dmRSrIdQ3BsW0DragCT

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613/c3429800242@github.com>

Maxim Kim

unread,
Oct 21, 2025, 6:49:55 PM (11 days ago) Oct 21
to vim/vim, Subscribed
habamax left a comment (vim/vim#18613)

However if you :e within :Tutor it will wipe out the buffer. Here set buftype=nowrite doesn't help.

Or just do :Tutor and then again :Tutor. Here set buftype=nowrite helps.

I believe a better solution might be to come up with BufReadCmd to populate buffer properly on occasional :e and other related commands.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613/c3429838656@github.com>

Maxim Kim

unread,
Oct 21, 2025, 7:04:46 PM (11 days ago) Oct 21
to vim/vim, Subscribed
habamax left a comment (vim/vim#18613)

If you add autocmd! BufReadCmd <buffer> :Tutor

" Enables/disables interactive mode.
function! tutor#EnableInteractive(enable)
    let enable = a:enable
    if enable
        setlocal buftype=nowrite
        setlocal concealcursor+=inv
        setlocal conceallevel=2
        call tutor#ApplyMarks()
        augroup tutor_interactive
            autocmd! TextChanged,TextChangedI <buffer> call tutor#ApplyMarksOnChanged()
            autocmd! BufReadCmd <buffer> :Tutor
        augroup END
...

Together with set buftype=nowrite it would also fix issue with :e.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613/c3429870302@github.com>

Maxim Kim

unread,
Oct 21, 2025, 7:07:49 PM (11 days ago) Oct 21
to vim/vim, Subscribed
habamax left a comment (vim/vim#18613)

Well, it needs to be smarter: it should know what tutorial was loaded into the buffer and read it back within BufReadCmd.

PS, original tutorial ftw :)

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613/c3429875521@github.com>

Phạm Bình An

unread,
Oct 21, 2025, 9:38:23 PM (11 days ago) Oct 21
to vim/vim, Subscribed
brianhuster left a comment (vim/vim#18613)

Or just do :Tutor and then again :Tutor. Here set buftype=nowrite helps.

This is what I was trying to solve.

Well, it needs to be smarter: it should know what tutorial was loaded into the buffer and read it back within BufReadCmd.

Tutor is not a part of anyone's workflow, so I don't want to put too much time on it. I also support removing the new tutor btw.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613/c3430150734@github.com>

Christian Brabandt

unread,
Oct 25, 2025, 9:08:17 AM (7 days ago) Oct 25
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18613)

Thanks. Let's also make it :drop instead of edit, so it works even when the current buffer is modified

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613/c3446684571@github.com>

Christian Brabandt

unread,
Oct 25, 2025, 9:13:29 AM (7 days ago) Oct 25
to vim/vim, Subscribed

Closed #18613 via 9978bb7.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613/issue_event/20502467854@github.com>

Phạm Bình An

unread,
Oct 25, 2025, 12:08:29 PM (7 days ago) Oct 25
to vim/vim, Subscribed
brianhuster left a comment (vim/vim#18613)

Let's also make it :drop instead of edit, so it works even when the current buffer is modified

@chrisbra Why doesn't :edit work when the current buffer is modified? Can you please elaborate on that?

Also, you have not explained that change in the commit message.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613/c3446868524@github.com>

Phạm Bình An

unread,
Oct 26, 2025, 12:49:26 PM (6 days ago) Oct 26
to vim/vim, Subscribed
brianhuster left a comment (vim/vim#18613)

@chrisbra

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613/c3448689531@github.com>

Christian Brabandt

unread,
Oct 26, 2025, 2:07:42 PM (6 days ago) Oct 26
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18613)

Why doesn't :edit work when the current buffer is modified? Can you please elaborate on that?

Try yourself: :set modified| :e and notice the E37.

Also, you have not explained that change in the commit message.

Indeed, but now it is set in stone 🤷

—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18613/c3448739977@github.com>

Reply all
Reply to author
Forward
0 new messages