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

Re: Opening every buffer in its own tab

Expand Messages
  • Matt Wozniski
    ... As Ben Fritz says, all you need is wildmenu completion on :b ... ^ offers all 8 buffers as a choice ... ^ offers car.cc and car.h ... ^
    Message 1 of 16 , Aug 1, 2008
    • 0 Attachment
      On Fri, Aug 1, 2008 at 5:23 AM, Scara Maccai wrote:
      >
      >> That's absolutely not what "everyone" wants, and most experienced
      >> vimmers, in particular those who work with more than 30 or so buffers
      >> simultaneously, would absolutely hate that.
      >
      > Maybe that's what I don't understand.
      > How, when you have 30 buffers open, you find the buffer you want? You
      > can't remember all the numbers, you can't remember exactly all the
      > names. That's what tabs are for in other editors: find the file you
      > want when you remember what the name "looks like".

      As Ben Fritz says, all you need is wildmenu completion on :b <Tab>

      An example, to show just how powerful this is:

      :set wildmenu wildmode=full
      :args vehicle.cc vehicle.h car.cc car.h jet.cc jet.h jetcar.cc jetcar.h
      :b <Tab>
      " ^ offers all 8 buffers as a choice
      :b car<Tab>
      " ^ offers car.cc and car.h
      :b *car<Tab>
      " ^ offers car.cc jetcar.cc car.h jetcar.h
      :b .h<Tab>
      " ^ offers the 4 buffers ending in .h
      :b .c<Tab>
      " ^ offers the 4 buffers ending in .cc
      :b ar.c<Tab>
      " ^ offers "car.cc" and "jetcar.cc"
      :b j*c<Tab>
      " ^ offers "jet.cc" "jetcar.cc" "jetcar.h"

      I used to use buffer explorer plugins, until I realized I could
      actually get to the buffer I was looking for faster this way 9 times
      out of 10.

      ~Matt

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tony Mechelynck
      ... In Vim, a buffer is an area of memory where Vim stores one file. A buffer may be hidden (I rarely use that) or displayed in a window. A window is a
      Message 2 of 16 , Aug 1, 2008
      • 0 Attachment
        On 01/08/08 11:23, Scara Maccai wrote:
        >> That's absolutely not what "everyone" wants, and most experienced
        >> vimmers, in particular those who work with more than 30 or so buffers
        >> simultaneously, would absolutely hate that.
        >
        > Maybe that's what I don't understand.
        > How, when you have 30 buffers open, you find the buffer you want? You
        > can't remember all the numbers, you can't remember exactly all the
        > names. That's what tabs are for in other editors: find the file you
        > want when you remember what the name "looks like".
        >
        >> Most editors don't even
        >> have a way to have a buffer loaded that isn't being displayed in a
        >> tab, I find that ability essential to my vim workflow.
        >
        > Again maybe that's something I don't understand: what is a buffer good
        > for if you don't see it?
        >
        > Please don't take these question the wrong way: I love everything
        > about vim, I just can't understand the "meaning" of buffers...

        In Vim, a buffer is an area of memory where Vim stores one file. A
        buffer may be hidden (I rarely use that) or displayed in a window.

        A window is a viewport to an area of a buffer. It consists of one
        statusline (with the pathfilename of the file being edited, its line,
        column, percentage down the file, the latter being replaced by "All"
        "Top" or "Bot" when you are seeing one or both ends of the file) plus
        zero or more lines of buffer text.

        Any buffer can be displayed in any number of windows (zero or more).

        Starting at version 7, one or more windows are arranged side-by-side
        and/or above one another in a tab. Until Vim 6, there was no provision
        for separate tabs, this is more or less equivalent to using one tab (per
        instance) in version 7. At version 7 you can have one or more tabs in a
        single Vim instance, which is more or less like having a choice of
        preset sessions in a single instance of Vim (and therefore sharing the
        same screen height, width and font).

        Each tab is a distinct arrangement of one or more split windows. Unlike
        windows, only one tab is displayed at a time in any Vim instance.

        You can have zero, one, or more instances of Console Vim and/or gvim
        running at the same time on one computer. Each instance of Console Vim
        interfaces with both keyboard and display through the text terminal in
        which it is loaded, and (for instance) cannot change the font; but on
        Unix you don't need to start X to run it, and even on Windows you can
        run it "really full-screen", with no MS-Windows frame at all (usually
        80x25, 80x43 or 80x60 characters on the screen, and nothing else to
        disturb you). Each instance of gvim needs a graphical interface such as
        X-Windows or MS-Windows, but it can set (among others) the height, width
        and font of its display interface. However, even in gvim, all tabs and
        windows in a given program instance share the same font face and size.

        I rarely use tabs. What I use is what I call "Rolodex Vim", which is set
        as follows:

        :set noequalalways winheight=99999 winminheight=0

        Or sometimes I use "true split windows", either side-by-side (usually in
        gvimdiff) or top-to-bottom (with ":set equalalways winheight=1").

        With Rolodex Vim, all windows in the current tab are reduced to just one
        statusline each, except the current window which expands to full height.
        The advantage (from my POV) is that unlike with tabs (which must all fit
        on a single line) here each window has one full line to display its
        filename and position. Clicking on a statusbar selects that window, or I
        can also use Ctrl-W w (next window down, round-robin) or Ctrl-W W (the
        opposite; W is of course shift-w), or either with a count (select Nth
        window). I even have the following maps to switch windows with a single key:

        :map <F11> <C-W>w
        :imap <F11> <C-O><C-W>w
        :map <S-F11> <C-W>W
        :imap <S-F11> <C-O><C-W>W

        The Vim session I use most steadily (and save with ":mks!" when I want
        to close gvim, e.g. to install a new version/patchlevel; then restore
        later with "gvim -S") contains 15 windows (not 30) in a single tab.
        Sometimes I start a parallel session in another instance, maybe with a
        different font.


        Best regards,
        Tony.
        --
        Jesus was killed by a Moral Majority.

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • John Beckett
        ... I recently tweaked a tip so I could use it in Did you know? on http://vim.wikia.com/wiki/Main_Page I recommend the tip to the OP:
        Message 3 of 16 , Aug 1, 2008
        • 0 Attachment
          Matt Wozniski wrote:
          > An example, to show just how powerful this is:
          > ...

          I recently tweaked a tip so I could use it in "Did you know?" on
          http://vim.wikia.com/wiki/Main_Page

          I recommend the tip to the OP:
          http://vim.wikia.com/wiki/Vim_buffer_FAQ

          While I agree about tab-completion on :bu, these two items are worth studying:
          - Is there a simpler way for using the buffers under gvim (GUI Vim)?
          - Is there a Vim script that simplifies using buffers with Vim?

          Matt's example is very useful, so I added it as a "todo" comment at the bottom. The
          tip is a little too wordy: one day I hope it will be trimmed and your example
          incorporated.

          John


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • François Ingelrest
          ... Thanks! That s useful for me as well. --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist. For more
          Message 4 of 16 , Aug 2, 2008
          • 0 Attachment
            On Sat, Aug 2, 2008 at 03:48, John Beckett <johnb.beckett@...> wrote:
            > I recommend the tip to the OP:
            > http://vim.wikia.com/wiki/Vim_buffer_FAQ

            Thanks! That's useful for me as well.

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • googler
            ... This might be a very basic question, but I wanted to understand the concept clearly. When we have several windows and tabs open in one single vim session
            Message 5 of 16 , Aug 2, 2008
            • 0 Attachment
              On Aug 1, 8:48 pm, "John Beckett" <johnb.beck...@...> wrote:
              > Matt Wozniski wrote:
              > > An example, to show just how powerful this is:
              > > ...
              >
              > I recently tweaked a tip so I could use it in "Did you know?" onhttp://vim.wikia.com/wiki/Main_Page
              >
              > I recommend the tip to the OP:http://vim.wikia.com/wiki/Vim_buffer_FAQ
              >
              > While I agree about tab-completion on :bu, these two items are worth studying:
              > - Is there a simpler way for using the buffers under gvim (GUI Vim)?
              > - Is there a Vim script that simplifies using buffers with Vim?
              >
              > Matt's example is very useful, so I added it as a "todo" comment at the bottom. The
              > tip is a little too wordy: one day I hope it will be trimmed and your example
              > incorporated.
              >
              > John

              This might be a very basic question, but I wanted to understand the
              concept clearly. When we have several windows and tabs open in one
              single vim session and if we perform a search on one of those windows,
              why does it highlight the occurences of the pattern in other windows
              and tabs?

              Also, if I open a help topic/file using ":help", why does vim not list
              that file as one of the loaded buffers when I do ":ls"?
              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Matt Wozniski
              ... Because highlighting is based off a single register, and registers are shared across all buffers. Anything that changes the / register changes what is
              Message 6 of 16 , Aug 2, 2008
              • 0 Attachment
                On Sat, Aug 2, 2008 at 5:35 PM, googler wrote:
                >
                > This might be a very basic question, but I wanted to understand the
                > concept clearly. When we have several windows and tabs open in one
                > single vim session and if we perform a search on one of those windows,
                > why does it highlight the occurences of the pattern in other windows
                > and tabs?

                Because highlighting is based off a single register, and registers are
                shared across all buffers. Anything that changes the '/' register
                changes what is highlighted (as well as what is searched for by 'n'
                and 'N'). You can prove this easily enough - after a search, when
                some things are highlighted, try changing the @/ register to something
                else, and the new thing will be highlighted instead, eg...
                /hello world
                to search for "hello world", then
                :let @/="world"
                to only highlight the word "world"
                Then, note that pressing n and N now jump between occurrences of
                "world", rather than "hello world".

                > Also, if I open a help topic/file using ":help", why does vim not list
                > that file as one of the loaded buffers when I do ":ls"?

                Well, as it says at :help :ls, "When the [!] is included the list will
                show unlisted buffers..." so, if you do ":ls!", you'll see the help
                buffer show up. Help buffers are normally unlisted, because they
                would generally just clutter the list, obscuring the documents that
                you intended to be working on. This is why if you open a new vim
                instance and do :help, then :enew a :ls will show two buffers,
                numbered 1 and 3. The help buffer is at 2 (which you can confirm with
                :ls!).

                ~Matt

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