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

Re: Doing ":bufdo tabnew" causes vim to hang, hog all resources

Expand Messages
  • Erik Falor
    ... Amen to that. At first, I, like you, wasn t sold on the benefits of tab pages, but have come to rely on them more and more. I thought that having the
    Message 1 of 15 , Feb 6, 2008
    • 0 Attachment
      On 2/6/08, Ben Schmidt <mail_ben_schmidt@...> wrote:
      I don't use them all that much, but am beginning to a bit more and I tend to do so
      like this. I put each module I am working on in a different tabpage. So one
      tabpage will have windows open for a handful of important files in my backend
      module. Another tabpage will have windows open for a handful of important frontend
      files. Another tabpage has a single window open with my 'to do' list so I can take
      notes and remember where I am up to. Another tabpage has specs open for the
      various data formats I am dealing with, for reference. I can switch between them
      at will, depending on what I need to work on.

      Arguably clicking a tab or using gt is easier than selecting a file from a list of
      buffers which is potentially signficantly longer than you really want, too, due to
      a stack of unloaded buffers you no longer need, but which still hang around in the
      list.

      Amen to that.  At first, I, like you, wasn't sold on the benefits of tab pages, but have come
      to rely on them more and more.  I thought that having the same buffer open on different
      tab pages was a weird feature.  But now that I partition my views of a project with tab
      pages, I can look at it in whichever perspective suits.  Quickly.

      I also keep a todo list in its own tab, various source files with supporting documents each in
      their own pages, another tab open to the file explorer, and often one tab page is dedicated
      to Vim's helpful help files.

      To quickly decide which tabpage I need to jump to in order to find a certain file, I can either
      use the :tabs command, or use the following combination of &guitablabel and &guitabtooltip
      functions.

      In short, now that I am familiar with tab pages, I won't go back!

      .gvimrc:
      set guioptions+=e

      function! GuiTabLabel() "{{{
      let label = '(' . v:lnum . ')'
      let bufnrlist = tabpagebuflist(v:lnum)

      " Append the number of windows in the tab page if more than one
      let wincount = tabpagewinnr(v:lnum, '$')
      if wincount > 1
      let label .= wincount
      endif
      if label != ''
      let label .= ' '
      endif

      " Append the name of active buffer
      let label .= pathshorten(bufname(bufnrlist[tabpagewinnr(v:lnum) - 1]))
      " Add '+' if one of the buffers in the tab page is modified
      for bufnr in bufnrlist
      if getbufvar(bufnr, "&modified")
      let label .= '+'
      break
      endif
      endfor

      return label
      endfunction "}}}


      function! GuiTabTooltip() "{{{
      " This function is called once per tabpage
      " Start with the tab number followed by the number of windows in the tab page
      let wincount = tabpagewinnr(v:lnum, '$')
      let label = 'Tab #' . v:lnum . ' - ' . wincount . ' window'
      if wincount > 1
      let label .= "s:\n"
      else
      let label .= ":\n"
      endif

      " list all buffers, putting a '+' in front of modified buffers
      " v:lnum == current tab page being evaluated
      let bufnrlist = tabpagebuflist(v:lnum)
      " prepend '+' if one of the buffers in the tab page is modified
      " prepend '%' for the window containing the cursor
      let current = tabpagewinnr(v:lnum)
      let i = 1
      for bufnr in bufnrlist
      let label .= bufnr
      if i == current
      let label .= '% '
      else
      let label .= ' '
      endif
      let i += 1
      if getbufvar(bufnr, "&modified")
      let label .= '+ '
      else
      let label .= ' '
      endif
      let name = bufname(bufnr)
      if name != ''
      let label .= name . "\n"
      else
      let label .= "[No Name]\n"
      endif

      endfor

      return label
      endfunction "}}}

      set guitablabel=%{GuiTabLabel()}
      set guitabtooltip=%{GuiTabTooltip()}

      --
      Erik Falor
      Registered Linux User #445632 http://counter.li.org
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---

    • Anand Hariharan
      ... Thank you for the above explanation, and your perspective of using tabs in the follow-up after reviewing my post. Much appreciated. ... Am afraid that has
      Message 2 of 15 , Feb 6, 2008
      • 0 Attachment
        On Feb 6, 12:44 am, Ben Schmidt <mail_ben_schm...@...> wrote:
        > > Ben says "For every tab, Vim adds a new tab".  It seems counter-
        > > intuitive to me considering that my command is *bufdo* tabnew (i.e.,
        > > for each *buffer* create a new tab).
        >
        > > Just seeking to understand here:  Do tabs transcend buffers or vice-
        > > versa (i.e., can I have a set of buffers in a tab that the buffer
        > > lists in other tabs do not know?  Or can a tab be agnostic of buffers
        > > loaded by vim?).
        >
        > O, yes, sorry; I didn't explain fully. :tabnew creates a new tab with a new,
        > empty, buffer. So, yes, you are right, it's because there is a new *buffer* that
        > it keeps going and going and going; the fact that a new tab comes with each buffer
        > is just coincidental.
        >

        Thank you for the above explanation, and your perspective of using
        tabs in the follow-up after reviewing my post. Much appreciated.


        > It might work if you used :tabedit which edits a file in a new tab, rather than
        > opening a new file in a tab, i.e.
        >
        > :bufdo tabedit
        >

        Am afraid that has the same effect as :bufdo tabnew, but you gave me
        the correct answer in your very first reply.

        - Anand
        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Anand Hariharan
        On Feb 6, 1:36 am, Tony Mechelynck ... Yes, it says new _window_, not a new buffer. In order to make that extrapolation from
        Message 3 of 15 , Feb 6, 2008
        • 0 Attachment
          On Feb 6, 1:36 am, Tony Mechelynck <antoine.mechely...@...>
          wrote:
          > Anand Hariharan wrote:
          >
          > [...]> Ben says "For every tab, Vim adds a new tab".  It seems counter-
          > > intuitive to me considering that my command is *bufdo* tabnew (i.e.,
          > > for each *buffer* create a new tab).
          >
          > [...]
          >
          > Yes: for each buffer, add a new tab with a new [No Name] buffer in it. So we
          > have one more buffer. The result is actually: for each buffer, add a new [No
          > Name] buffer. You should have checked ":help :tabnew", it mentions that with
          > no argument, it creates a new tab with an empty window.
          >

          Yes, it says new _window_, not a new buffer. In order to make that
          extrapolation from new window as to imply new buffer, one needs to
          know the following:


          > You may have several windows to a single buffer, in the same tab or in
          > different tabs, but creating a new "empty" window actually also creates a new
          > [No Name] buffer to contain whatever edits you'll make in that "empty" window.
          >

          I hope you find it reasonable that one could find the distinction
          between tabs, buffers and windows very subtle.

          Thank you all for responding. I suppose, just like the editor itself,
          I should let the tab feature 'grow' on me, because (again just like
          the editor itself), my first impression has not been very favourable!
          <I once swore /at/ vi, but I would now swear /by/ it! ;-)>

          - Anand
          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Ben Schmidt
          ... Interesting. It seems to work properly for me. I wonder what is different about your Vim/configuration. Not that it matters, since, as you say, the problem
          Message 4 of 15 , Feb 7, 2008
          • 0 Attachment
            >> It might work if you used :tabedit which edits a file in a new tab, rather than
            >> opening a new file in a tab, i.e.
            >>
            >> :bufdo tabedit
            >
            > Am afraid that has the same effect as :bufdo tabnew, but you gave me
            > the correct answer in your very first reply.

            Interesting. It seems to work properly for me. I wonder what is different about
            your Vim/configuration. Not that it matters, since, as you say, the problem has
            been solved.

            And yes, I think most of us would agree that the distinction between windows and
            buffers and so on is indeed quite subtle and can be confusing, at least to start
            with (if not for a good while longer!).

            Smiles,

            Ben.




            Send instant messages to your online friends http://au.messenger.yahoo.com


            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_dev" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Tony Mechelynck
            ... Which windows are open at any moment is rather obvious, at least for the current tab. (They are separated by their status lines; whether the bottom window
            Message 5 of 15 , Feb 7, 2008
            • 0 Attachment
              Anand Hariharan wrote:
              >
              >
              > On Feb 6, 1:36 am, Tony Mechelynck <antoine.mechely...@...>
              > wrote:
              >> Anand Hariharan wrote:
              >>
              >> [...]> Ben says "For every tab, Vim adds a new tab". It seems counter-
              >>> intuitive to me considering that my command is *bufdo* tabnew (i.e.,
              >>> for each *buffer* create a new tab).
              >> [...]
              >>
              >> Yes: for each buffer, add a new tab with a new [No Name] buffer in it. So we
              >> have one more buffer. The result is actually: for each buffer, add a new [No
              >> Name] buffer. You should have checked ":help :tabnew", it mentions that with
              >> no argument, it creates a new tab with an empty window.
              >>
              >
              > Yes, it says new _window_, not a new buffer. In order to make that
              > extrapolation from new window as to imply new buffer, one needs to
              > know the following:
              >
              >
              >> You may have several windows to a single buffer, in the same tab or in
              >> different tabs, but creating a new "empty" window actually also creates a new
              >> [No Name] buffer to contain whatever edits you'll make in that "empty" window.
              >>
              >
              > I hope you find it reasonable that one could find the distinction
              > between tabs, buffers and windows very subtle.
              >
              > Thank you all for responding. I suppose, just like the editor itself,
              > I should let the tab feature 'grow' on me, because (again just like
              > the editor itself), my first impression has not been very favourable!
              > <I once swore /at/ vi, but I would now swear /by/ it! ;-)>
              >
              > - Anand

              Which windows are open at any moment is rather obvious, at least for the
              current tab. (They are separated by their status lines; whether the bottom
              window has a status line is governed by the 'laststatus' option.)

              To determine which buffers are currently known, you can use ":ls!". (Without
              the exclamation mark, it hides the so-called "unlisted" buffers.) Some of them
              may not be in memory: see ":help :ls" for the meaning of the codes in the left
              margin of the list.


              Best regards,
              Tony.
              --
              "The Lord gave us farmers two strong hands so we could grab as much as
              we could with both of them."
              -- Joseph Heller, "Catch-22"

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_dev" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            Your message has been successfully submitted and would be delivered to recipients shortly.