1

Check the following screenshot:

Vim screenshot

I checked all my plugins/bundles, I use Vundle not Pathogen. Here's my list of bundles:

" This one is required baby!
Bundle 'gmarik/vundle'

" All of my Vundle bundles
Bundle 'scrooloose/nerdcommenter'
Bundle 'scrooloose/nerdtree'
Bundle 'mattn/zencoding-vim'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-markdown'
Bundle 'tpope/vim-repeat'
Bundle 'tpope/vim-surround'
Bundle 'spf13/PIV'
Bundle 'vim-scripts/YankRing.vim'
Bundle 'jeffkreeftmeijer/vim-numbertoggle'
Bundle 'PotHix/Vimpress'
" Color schemes
Bundle 'altercation/vim-colors-solarized'

I just yanked my vimrc file in case you didn't notice. I am not aware that any of these change the buffer behavior, but I might be mistaken.

How can I remove this tab-like functionality? To reproduce it, simply open a file, and then grab other files, and drag them on top of the Vim window (not icon, window).

TRiG
  • 10,148
  • 7
  • 57
  • 107
greduan
  • 4,770
  • 6
  • 45
  • 73
  • I see your point, but then try actually using the buffers navigation function within Vim, if you look at the tabs you will notice a problem. You don't switch between the tabs, but rather you switch the buffer in that tab, so you can have multiple tabs with the same name and buffer. – greduan Nov 16 '12 at 22:27
  • 3
    @Eduan I think you have some catching-up to do regarding Vim's concept of tabs and buffers -- it is very different from that of other editors: See the discussion [here](http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers). – glts Nov 16 '12 at 23:07
  • If you want easy buffer navigation without tabs, install LustyExplorer and LustyJuggler. In fact you're going to go ahead and want to install those anyway. – Andy Ray Nov 16 '12 at 23:40
  • @glts I am aware of how tabs and buffers and multiple files and all that stuff work. I made this question because I'm pretty sure there aren't supposed to be any kind of tabs in default Vim, as far as I know. Since apparently there are, could you please show me how to remove them? I'm talking about the ones shown in the image of course. – greduan Nov 17 '12 at 01:36
  • @AndyRay Thanks for the tip Andy, will make sure to check them. :) – greduan Nov 17 '12 at 01:36
  • @Eduan, your other question regarding MacVim made me think about one thing: the behavior you describe is set in the the Preferences window of MacVim: "Open files from applications". Just set it to the desired behavior and that's it. Thanks for wasting everyone's time by not mentioning that you were using MacVim. – romainl Nov 18 '12 at 08:03

2 Answers2

2

Vim can do tabs but it doesn't show a tabline by default: the tabline is created only if you create a tab and Vim won't create tabs if you don't tell it to do so.

If you don't want tabs don't use them. It's that simple.

From your comments, it looks like your are confusing Vim's tabs with the tabs you may be accustomed to in other editors. They might "look" the same at first sight but their purpose and implementation are very different.

In Vim, tabs are a way to organise workspaces: they don't and can't represent a single buffer. That's very important to understand if you want to use tabs in Vim. You need a lot of self discipline to actually be able to use Vim tabs as TextMate/Sublime tabs. You should only use tabs if you understand them.

The right way to work with multiple files in Vim is to use buffers and windows and the right commands. But here are a couple of tips if you really want to work with tabs:

Start by adding this line to your ~/.vimrc:

set switchbuf=useopen,usetab

With this setting, many operations (in the quickfix, notably) will jump you to the buffer where it is (in another window or another tab) instead of loading the buffer right here.

Then you should use the right commands:

:sb[uffer]
:sbn[ext]
:sbN[ext]
:sbl[ast]
:sbf[irst]
:sbr[ewind]

All these commands jump to the buffer where it is if it's displayed somewhere or open it in a split.

From there you are now able to do:

:e file_a
(editing file_a)
:tabe file_b
(editing file_b in tab 2)
:sbN
(editing file_a in tab 1)
:sbn
(editing file_b in tab 2)
…

without ending up with the same buffer in multiple tabs.

Tab-related movements like gt, :tabl or :tabn2 should be used only if you understand the real nature of tabs as workspaces, not as a way to switch to another file.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • Thanks for the useful tips romainl! I'm using the `switchbuf` settings now, very useful. :) I think I'll study tabs and buffers a little bit more, in order to not embarrass myself. :) – greduan Nov 17 '12 at 14:43
  • BTW, didn't accept this one because sehe's answer solved my problem, but nonetheless, very useful. :) – greduan Nov 17 '12 at 14:44
1

Edit Found a much more effective setting:

set tabpagemax=1 showtabline=0

inside your $MYVIMRC

Docs:

                        *'showtabline'* *'stal'*
'showtabline' 'stal'    number  (default 1)
            global
            {not in Vi}
            {not available when compiled without the |+windows|
            feature}
    The value of this option specifies when the line with tab page labels
    will be displayed:
        0: never
        1: only if there are at least two tab pages
        2: always
    This is both for the GUI and non-GUI implementation of the tab pages
    line.

And

                        *'tabpagemax'* *'tpm'*
'tabpagemax' 'tpm'  number  (default 10)
            global
            {not in Vi}
            {not available when compiled without the |+windows|
            feature}
    Maximum number of tab pages to be opened by the |-p| command line
    argument or the ":tab all" command. |tabpage|
sehe
  • 374,641
  • 47
  • 450
  • 633
  • I'm afraid that did not solve my problem. Although it does limit the amount of tabs I can see to 2, even if I have more buffers. – greduan Nov 17 '12 at 01:32
  • BTW, please remember I want to remove it completely, don't want to see it at all. Can this be achieved setting it to 0? – greduan Nov 17 '12 at 02:25
  • @Eduan Any window is always on a tab. So, setting tabpagemax < 1 would mean you couldn't open a window... See my updated answer, anways – sehe Nov 17 '12 at 11:17
  • @Eduan, the tabline is there *only* if you have tabs. The simplest way to get rid of it is to not use tabs at all. If you use tabs what would be the point of hiding the tabline? How are you going to interact with tabs? Or even know how many you have? Or that you want to go to tab number `x`? – romainl Nov 17 '12 at 12:10
  • @romainl the point is, he gets tabs _automatically_ (when dropping files from the filemanager...). Setting the options I show might prevent that from happening (without having to alter distribution specific integration) – sehe Nov 17 '12 at 12:31
  • Do you experience that behaviour yourself? I don't: dropping files from nautilus only replaces the current buffer without opening any tabs. – romainl Nov 17 '12 at 12:46
  • That solved the problem sehe, thanks! Now I gotta figure out how to make it not open it in splits, lol. – greduan Nov 17 '12 at 13:23
  • @Eduan try he `switchbuf` setting (switchbuf=useopen perhaps?). Anyways, the default behaviour of vim is to use a single window. So, if you see them opening with split, this is likely due to `vim -o` or `vim -p` being used by the launcher shortcut – sehe Nov 17 '12 at 14:20
  • OK, thanks, will dig a little bit, and see if I can find it. :) – greduan Nov 17 '12 at 14:41