Loading ...
Sorry, an error occurred while loading the content.

restore buffer numbers after 'vim -S', a workaround?

Expand Messages
  • Daan van Rossum
    Hi all, Description: Vim s restore session mechanism doesn t restore the buffer numbers properly. Buffer #1 is skipped and the buffers in Session.vim are
    Message 1 of 3 , Apr 20 10:07 AM
    View Source
    • 0 Attachment
      Hi all,

      Description:
      Vim's restore session mechanism doesn't restore the buffer numbers properly. Buffer #1 is skipped and the buffers in Session.vim are appended to it, so they start at #2.


      Version:
      7.3.495


      References to the same problem:
      http://larig.wordpress.com/2012/02/14/vim-sessions-and-the-missing-first-buffer/


      Reproduce problem:
      vim a b
      :ls
      :mksession
      :qa
      vim -S
      :ls


      Possible solution:
      Add a workaround-function, say :bfrom1, that shifts all buffer numbers one position to the left if the first buffer is wiped-out. This fuction can then be called in Session.vim after wiping buffer #1:
      if exists('s:wipebuf')
      silent exe 'bwipe ' . s:wipebuf
      bfrom1
      endif


      Best,
      Daan

      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Tony Mechelynck
      ... AFAIK buffer numbers are not meant to persist between sessions, even efter :mksession :quit vim -S — if you ve used :bwipeout there are holes in
      Message 2 of 3 , Apr 22 8:16 PM
      View Source
      • 0 Attachment
        On 20/04/12 19:07, Daan van Rossum wrote:
        > Hi all,
        >
        > Description:
        > Vim's restore session mechanism doesn't restore the buffer numbers properly. Buffer #1 is skipped and the buffers in Session.vim are appended to it, so they start at #2.
        >
        >
        > Version:
        > 7.3.495
        >
        >
        > References to the same problem:
        > http://larig.wordpress.com/2012/02/14/vim-sessions-and-the-missing-first-buffer/
        >
        >
        > Reproduce problem:
        > vim a b
        > :ls
        > :mksession
        > :qa
        > vim -S
        > :ls
        >
        >
        > Possible solution:
        > Add a workaround-function, say :bfrom1, that shifts all buffer numbers one position to the left if the first buffer is wiped-out. This fuction can then be called in Session.vim after wiping buffer #1:
        > if exists('s:wipebuf')
        > silent exe 'bwipe ' . s:wipebuf
        > bfrom1
        > endif
        >
        >
        > Best,
        > Daan
        >


        AFAIK buffer numbers are not meant to persist between sessions, even
        efter ":mksession" ":quit" "vim -S" — if you've used :bwipeout there are
        "holes" in the list of buffer numbers; after reload those holes are not
        preserved.

        What is supposed to be preserved are buffer names (and full paths for
        buffers whose 'buftype' is not "nofile") and windows.


        Best regards,
        Tony.
        --
        Most fish live underwater, which is a terrible place to have sex
        because virtually anywhere you lie down there will be stinging crabs
        and large quantities of little fish staring at you with buggy little
        eyes. So generally when two fish want to have sex, they swim around
        and around for hours, looking for someplace to go, until finally the
        female gets really tired and has a terrible headache, and she just
        dumps her eggs right on the sand and swims away. Then the male, driven
        by some timeless, noble instinct for survival, eats the eggs. So the
        truth is that fish don't reproduce at all, but there are so many of
        them that it doesn't make any difference.
        -- Dave Barry, "Sex and the Single Amoeba: What Every
        Teen Should Know"

        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Daan van Rossum
        ... You re right. But still: Using buffer numbers (B#s) is a very convenient way to work on many files. It s so good to know where you left stuff, without
        Message 3 of 3 , Apr 23 9:01 AM
        View Source
        • 0 Attachment
          > AFAIK buffer numbers are not meant to persist between sessions, even
          > efter ":mksession" ":quit" "vim -S" — if you've used :bwipeout there
          > are "holes" in the list of buffer numbers; after reload those holes
          > are not preserved.
          >
          > What is supposed to be preserved are buffer names (and full paths
          > for buffers whose 'buftype' is not "nofile") and windows.
          >
          > Best regards,
          > Tony.

          You're right.

          But still:
          Using buffer numbers (B#s) is a very convenient way to work on many files. It's so good to know where you left stuff, without having to search for it first.
          Having to re-learn the B#s after a session restore is a pain.

          Is there a chance one could reorganize B#s at all within a live session (e.g. within the Session.vim script)? Or are the B#s so fundamental that allowing them to change would involve big code changes?

          Best,
          Daan

          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        Your message has been successfully submitted and would be delivered to recipients shortly.