2

After reading :help :rewind

:rew[ind] [++opt] [+cmd]  
    Start editing the first file in the argument list.
    This fails when changes have been made and Vim does
    not want to |abandon| the current buffer.
    Also see |++opt| and |+cmd|. {Vi: no ++opt}

and :help :buffer

:[N]b[uffer][!] [+cmd] [N]      *:b* *:bu* *:buf* *:buffer* *E86*
    Edit buffer [N] from the buffer list.  If [N] is not given,
    the current buffer remains being edited.  See |:buffer-!| for
    [!].  This will also edit a buffer that is not in the buffer
    list, without setting the 'buflisted' flag.
    Also see |+cmd|.

comes the question: What does :rewind offer that :b1 lacks?

1
  • 1
    This is completely different things. Start from reading :h arglist. – Matt Jul 29 '20 at 5:30
4

As I was told in the comments, the fundamental difference is that :b1 targets the buffer list and :rewind targets the argument list. :help buffer-list is a nice summary:

    args list          buffer list         meaning
:[N]argument [N]    :[N]buffer [N]      to arg/buf N
:[N]next [file ..]  :[N]bnext [N]       to Nth next arg/buf
:[N]Next [N]        :[N]bNext [N]       to Nth previous arg/buf
:[N]previous [N]    :[N]bprevious [N]   to Nth previous arg/buf
:rewind / :first    :brewind / :bfirst  to first arg/buf
:last               :blast              to last arg/buf
:all                :ball               edit all args/buffers
                    :unhide             edit all loaded buffers
                    :[N]bmod [N]        to Nth modified buf

The argument list are the arguments passed Vim on startup. It hardly ever changes (:argedit, :argadd, etc. can change them though).

vim file1 file2

means the argument list contains file1 and file2.

The buffer list is not static. With :e file3, it incorporates file3, so :ls shows the three files while :args shows only file1 and file2.

Resuming the experiment, wipe the 1st buffer with :bwipe 1. Buffer 1 has been wiped and thus removed from the buffer list. Now,

  • :b1 raises an error "Buffer 1 does not exist",
  • :brewind goes to the first buffer in the buffer list, file2,
  • :rewind brings back file1 in a new buffer, since the argument list is unchanged and the first argument is file1.
4
  • 1
    Another difference is that one targets the buffer list while the other targets the argument list – D. Ben Knoble Jul 29 '20 at 15:02
  • @D.BenKnoble After a careful read, I think now I've got it. Please let me know if I made some mistake or if I still miss the point. – Quasímodo Aug 18 '20 at 19:18
  • 1
    Looks great! Technically it's possible to change the arguments list (e.g., many forms of :args, :argadd, :argdelete), but that's probably a tertiary detail – D. Ben Knoble Aug 18 '20 at 19:54
  • 1
    @D.BenKnoble Thank you very much! I have edited that too so as to avoid innacuracies. – Quasímodo Aug 18 '20 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.