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

Re: Minor fix for Vim Tip #1078 (Closing buffer without closing window)

Expand Messages
  • John Orr
    Clearly lots of us have solved this problem in various ways. My take on it was that, for each window in your vim session, I wanted a memory of which buffers
    Message 1 of 3 , May 1, 2007
    • 0 Attachment
      Clearly lots of us have solved this problem in various ways.
      My take on it was that, for each window in your vim session, I wanted a memory of which buffers had been displayed there -
      almost like a "back" button in a web browser.
      When you close a buffer, it would jump back to the previous buffer for that particular window (repeatedly) -
      so you could open a file, "gf" to another file, "gf" to another file etc - then step backwards, closing them as you go,
      back to your first file (or the unnamed file if you go one too far - but there's an undo function to fix that :)

      http://www.vim.org/scripts/script.php?script_id=1147 if you're interested.

      John

      On Tuesday 01 May 2007 10:18, Michael Henry wrote:
      > All,
      >
      > Vim Tip #1078 ("Best way to close (delete) buffer without closing its
      > window") is pretty useful. In the version shown on the tip page[1], it
      > doesn't keep your cursor in the window you are trying to preserve. I
      > think the following line is supposed to serve that purpose:
      >
      > execute "normal " . g:kwbdWinNum . ""
      >
      > The final pair of double-quotes are likely not supposed to be empty.
      >
      > If you replace the line above with the following line, the active window
      > will be preserved:
      >
      > execute g:kwbdWinNum "wincmd w"
      >
      > I would have posted a comment on the tip, but comments are currently
      > disabled due to spam considerations.
      >
      > As a side note, is there hope for re-enabling the comment feature? I've
      > found that many of the scripts have valuable comments, sometimes
      > containing bug fixes, sometimes pointing to similar or complementary
      > scripts, etc.
      >
      > Thanks,
      > Michael Henry
      >
      > [1]: http://www.vim.org/tips/tip.php?tip_id=1078
      >
      >
    • Larson, David
      John, Doesn t CTRL-O do this for you? See ... David ... From: John Orr [mailto:john.orr@catapult.com] Sent: Tuesday, May 01, 2007 4:12 AM To: Michael Henry Cc:
      Message 2 of 3 , May 1, 2007
      • 0 Attachment
        John,

        Doesn't CTRL-O do this for you? See

        :help CTRL-O

        David

        -----Original Message-----
        From: John Orr [mailto:john.orr@...]
        Sent: Tuesday, May 01, 2007 4:12 AM
        To: Michael Henry
        Cc: vim@...
        Subject: Re: Minor fix for Vim Tip #1078 (Closing buffer without closing
        window)

        Clearly lots of us have solved this problem in various ways.
        My take on it was that, for each window in your vim session, I wanted a
        memory of which buffers had been displayed there -
        almost like a "back" button in a web browser.
        When you close a buffer, it would jump back to the previous buffer for
        that particular window (repeatedly) -
        so you could open a file, "gf" to another file, "gf" to another file etc
        - then step backwards, closing them as you go,
        back to your first file (or the unnamed file if you go one too far - but
        there's an undo function to fix that :)

        http://www.vim.org/scripts/script.php?script_id=1147 if you're
        interested.

        John

        On Tuesday 01 May 2007 10:18, Michael Henry wrote:
        > All,
        >
        > Vim Tip #1078 ("Best way to close (delete) buffer without closing its
        > window") is pretty useful. In the version shown on the tip page[1],
        it
        > doesn't keep your cursor in the window you are trying to preserve. I
        > think the following line is supposed to serve that purpose:
        >
        > execute "normal " . g:kwbdWinNum . ""
        >
        > The final pair of double-quotes are likely not supposed to be empty.
        >
        > If you replace the line above with the following line, the active
        window
        > will be preserved:
        >
        > execute g:kwbdWinNum "wincmd w"
        >
        > I would have posted a comment on the tip, but comments are currently
        > disabled due to spam considerations.
        >
        > As a side note, is there hope for re-enabling the comment feature?
        I've
        > found that many of the scripts have valuable comments, sometimes
        > containing bug fixes, sometimes pointing to similar or complementary
        > scripts, etc.
        >
        > Thanks,
        > Michael Henry
        >
        > [1]: http://www.vim.org/tips/tip.php?tip_id=1078
        >
        >
      • John Orr
        Hi David, Thanks for the idea, but unfortunately Ctrl-O does something similar but different - it just jumps back to the previous location, which may well be
        Message 3 of 3 , May 1, 2007
        • 0 Attachment
          Hi David,

          Thanks for the idea, but unfortunately Ctrl-O does something similar but different - it just jumps back to the previous location, which may well be in another buffer - but the buffer it is leaving is left open.
          As per the title of this thread, the aim is to close the buffer, presumably because we're finished with it, and we don't want it open any more.
          The problem is that when you close the buffer, often your window would be closed too.
          Some of us have written functions to avoid that - but the question becomes, "If you don't close the window when you close the buffer, what should you display in the window?"
          One option is an empty buffer (as some functions accessible via links from this thread do), another is the alternate buffer. If you choose the alternate buffer though - then if you close that, what do you display?
          My answer is you need a history of all buffers displayed in that window, and you just step back through them.

          I'm always happy to find a built-in solution to a problem I've solved with a script - but unfortunately CTRL-O isn't it :(

          John

          On Wednesday 02 May 2007 01:51, Larson, David wrote:
          > John,
          >
          > Doesn't CTRL-O do this for you? See
          >
          > :help CTRL-O
          >
          > David
          >
          > -----Original Message-----
          > From: John Orr [mailto:john.orr@...]
          > Sent: Tuesday, May 01, 2007 4:12 AM
          > To: Michael Henry
          > Cc: vim@...
          > Subject: Re: Minor fix for Vim Tip #1078 (Closing buffer without closing
          > window)
          >
          > Clearly lots of us have solved this problem in various ways.
          > My take on it was that, for each window in your vim session, I wanted a
          > memory of which buffers had been displayed there -
          > almost like a "back" button in a web browser.
          > When you close a buffer, it would jump back to the previous buffer for
          > that particular window (repeatedly) -
          > so you could open a file, "gf" to another file, "gf" to another file etc
          > - then step backwards, closing them as you go,
          > back to your first file (or the unnamed file if you go one too far - but
          > there's an undo function to fix that :)
          >
          > http://www.vim.org/scripts/script.php?script_id=1147 if you're
          > interested.
          >
          > John
          >
          > On Tuesday 01 May 2007 10:18, Michael Henry wrote:
          > > All,
          > >
          > > Vim Tip #1078 ("Best way to close (delete) buffer without closing its
          > > window") is pretty useful. In the version shown on the tip page[1],
          > it
          > > doesn't keep your cursor in the window you are trying to preserve. I
          > > think the following line is supposed to serve that purpose:
          > >
          > > execute "normal " . g:kwbdWinNum . ""
          > >
          > > The final pair of double-quotes are likely not supposed to be empty.
          > >
          > > If you replace the line above with the following line, the active
          > window
          > > will be preserved:
          > >
          > > execute g:kwbdWinNum "wincmd w"
          > >
          > > I would have posted a comment on the tip, but comments are currently
          > > disabled due to spam considerations.
          > >
          > > As a side note, is there hope for re-enabling the comment feature?
          > I've
          > > found that many of the scripts have valuable comments, sometimes
          > > containing bug fixes, sometimes pointing to similar or complementary
          > > scripts, etc.
          > >
          > > Thanks,
          > > Michael Henry
          > >
          > > [1]: http://www.vim.org/tips/tip.php?tip_id=1078
          > >
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.