Giter Site home page Giter Site logo

vim-buftabline's Introduction

Buftabline

A well-integrated, low-configuration buffer list that lives in the tabline

Buffer basics

If you don’t know anything about buffers, the minimum you have to know is that a buffer in Vim essentially means a file, and if you set hidden, Vim can keep files open without necessarily displaying them on screen. You can then use the :bnext and :bprev commands to change which buffer is being displayed in the current window, and :ls to look at the list of buffers.

If this is all news to you, you should probably add this to your configuration:

set hidden
nnoremap <C-N> :bnext<CR>
nnoremap <C-P> :bprev<CR>

For the full story, read :help windows.txt.

Why this and not Vim tabs?

Vim tabs are not very useful except in very particular circumstances. To understand why this is, you have to understand that the display in Vim has 3 layers of indirection:

  1. Buffers correspond to files.

    Not necessarily to files on disk, but in potentiality; i.e. a buffer becomes the content of a file when you do :w

  2. Windows correspond to rectangular areas on the screen, each associated with some buffer.

    Any window can be associated with any buffer, and any buffer with any window. You can change which buffer is shown in a window at any time, and you can split and resize windows to create any on-screen arrangement you want. So you could have 3 windows showing the same buffer, e.g. to work on several areas of a file at once.

    Note that while windows are always associated with a buffer - i.e. an area of the screen always shows some file –, a buffer need not be associated with any window – i.e. a file may be loaded without being shown on screen.

  3. Tabs correspond to entire screens, i.e. to an arrangement of windows.

    In other windowing environments this concept is often called a viewport, or a virtual desktop. Each window belongs to one particular tab. But note that a buffer can be shown in any window (or no window at all), so any file can appear any number of times in any number of tabs. Tabs and files do not have anything to do with each other.

Now it is possible to open just one full-screen window in each tab, and in each window edit a different buffer, in effect associating tabs with files. But this only works if you stay away from any other window or buffer management, i.e. if you never create splits and never touch the buffer list. Even then there are parts of Vim (such as the help function and the netrw Explorer) that expect to be working with windows, not tabs, and so can easily inadvertently shatter the illusion.

So if you consider what Vim tabs actually are, i.e. viewports, and you use Vim in a typical way, there are only very limited circumstances in which you will ever need such functionality, if at all.

What the typical user wants when they think of tabs is simply the ability to open multiple files and then flip between them, which in Vim means they want buffers – not tabs.

Buftabline vs. X

As of Nov 15, 2014, here is how Buftabline compares with some other plugins of which I am aware that they offer related functionality, roughly in order of their age.

  • MiniBufExpl

    Obviously no rundown can be complete without the veteran of buffer list plugins, Mini Buffer Explorer. There are two major differences:

    1. Buftabline uses the tabline while MiniBufExpl renders to a special buffer in a split. The tabline is newer than MiniBufExpl, and unlike a buffer, it is guaranteed to stick to the top of the screen within Vim, unaffected by any splits.

    2. Because Buftabline uses the tabline, it cannot offer any functionality relating to the management of buffers: all it does is show you the list.

      OTOH, this also makes Buftabline very lightweight from a user perspective: Vim has plenty of facilities for managing buffers and with Buftabline you will be using those same as without it. Buftabline need not aspire to be your sole interface to Vim’s buffers.

  • buftabs

    Buftabs is what you get when you try to implement Buftabline on a Vim that does not yet have the tabline. It can only render your tabs near or at the bottom of the Vim screen, and you have the choice between trading in your statusline for the list, or having it flicker “behind” the command line. If MiniBufExpl is too heavy for you, buftabs is the best you can do in absence of the tabline.

    I used this for a long time.

  • bufferline

    Essentially a newer rendition of buftabs.

  • Airline

    If you already use Airline, you do not need Buftabline: the functionality comes built in – see :help airline-tabline.

    If you do not already use Airline, you may not want to: it is far heavier than Buftabline, to the point of dragging down performance. C.f. Pretty statuslines vs cursor speed

  • BufLine

    This is very similar in scope and strategy to Buftabline, but not nearly as simple. The code is more than 5 times as long. There are lots of options and mappings so despite its limited scope compared to something like MiniBufExpl or Airline, it feels like a Big Plugin – one that requires a large up-front commitment. And subjective though this is, I will call its default colors ugly (while the ones in Buftabline depend entirely on your colorscheme), nor does it make any attempt to harmonise with the user colorscheme.

  • WinTabs

    This is another Big Plugin, though much, much better. It supports Vim tabs in addition to buffers, and tries to implement a functionality that is not native to Vim tabs: scoping buffers to certain tabs. This means it also needs to hook into sessions in order to support them, which it does. All in all, if you want to use Vim tabs (i.e. viewports), this is probably the best plugin for you – Buftabline will be too simplistic for your preferences.

vim-buftabline's People

Contributors

anihm136 avatar ap avatar bitbrian avatar cenkalti avatar deathlyfrantic avatar gibfahn avatar liyongjin avatar simaoneves avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-buftabline's Issues

:h causes buffer line to disapear

This issue appears only when g:buftabline_show is set to 1.

To reproduce:

  1. Open two buffers, causing the buffer line to appear.
  2. Invoke :h, causing the buffer line to dissapear

Closing the help dialogue didn't restore the buffer line for me. I had to BufDelete all my buffers and then open two new ones for it to appear again.

Mouse support in NeoVim 0.1.2 and newer

This was added in NeoVim 0.1.2:

@ N   For 'tabline': start of execute function label. Use %X or %T to 
      end the label, e.g.: %10@[email protected]%X.  Clicking this 
      label runs specified function: in the example when clicking once 
      using left mouse button on "foo.c" "SwitchBuffer(10, 1, 'l', 
      '    ')" expression will be run.  Function receives the 
      following arguments in order:
      1. minwid field value or zero if no N was specified
      2. number of mouse clicks to detect multiple clicks
      3. mouse button used: "l", "r" or "m" for left, right or middle 
         button respectively; one should not rely on third argument 
         being only "l", "r" or "m": any other non-empty string value 
         that contains only ASCII lower case letters may be expected 
         for other mouse buttons
      4. modifiers pressed: string which contains "s" if shift 
         modifier was pressed, "c" for control, "a" for alt and "m" 
         for meta; currently if modifier is not pressed string 
         contains space instead, but one should not rely on presence 
         of spaces or specific order of modifiers: use |stridx()| to 
         test whether some modifier is present; string is guaranteed 
         to contain only ASCII letters and spaces, one letter per 
         modifier; "?" modifier may also be present, but its presence 
         is a bug that denotes that new mouse button recognition was 
         added without modifying code that reacts on mouse clicks on 
         this label.
      Note: to test whether your version of Neovim contains this 
            feature use `has('tablineat')`.

Mapping for changing buffer with a count

Instead of these

nmap <leader>1 <Plug>BufTabLine.Go(1)
nmap <leader>2 <Plug>BufTabLine.Go(2)
nmap <leader>3 <Plug>BufTabLine.Go(3)
nmap <leader>4 <Plug>BufTabLine.Go(4)
nmap <leader>5 <Plug>BufTabLine.Go(5)
nmap <leader>6 <Plug>BufTabLine.Go(6)
nmap <leader>7 <Plug>BufTabLine.Go(7)
nmap <leader>8 <Plug>BufTabLine.Go(8)
nmap <leader>9 <Plug>BufTabLine.Go(9)
nmap <leader>0 <Plug>BufTabLine.Go(10)

I would like to have a simple maping for <space> which would take a count parameter.
Then after invoking 5<space> I would expect vim to switch to 5'th buffer according to the ordinal numbering g:buftabline_numbers = 2.

I wouldn't bother, however I simply can't spend days reading Vim's documentation and figuring out its quirks just to do such simple thing 😞

EDIT: Great plugin btw!

Ability to reorder buffer icons

It would be very helpful if the buffer icons in the tabline could be reordered. Commands for moving the current buffer's icon to the left or right would be quite useful.

I understand that buffer icons are currently ordered by buffer numbers, which are assigned by vim and cannot be changed, but I would assume that it is possible to display the buffer icons in a different order.

p.s. thanks for making a slick plugin!

Better display of ordinal buffer numbers

I propose changing buffer numbers in ordinal mode with subscript notation as in screenshot above:

screenshot

This has 2 advantages:

  • The number baseline is different than buffer name baseline. It makes easier to see because your eyes know where to scan.
  • It saves 1 whitespace per buffer. More compact than current one.

I can make a PR if you would like to accept this change.

Is this project dead

Hi. I really like your plugin. Thanks a lot for your work. I am wondering if you have plans to work on it further or if this project is dead?

Opening help topics

I typically invoke a help topic with :tab help topic because I prefer this unmixed, full terminal view. But this causes bad things to happen with buftabline enabled. Tab labels appear to duplicate, or disappear, and navigation with bnext misbehaves.

I see that help buffers get filtered in user_buffers() but I was unable to successfully modify this for my purposes.

Is it possible to add a global option to allow for help in its own tab? Perhaps it would be desirable to generalize this option so people can decide if they want to see other buftypes in their own tabs?

Integrating devicons

Hello, would like some help integrating devicons, assuming it is possible.

Using the WebDevIconsGetFileTypeSumbol(), from https://github.com/ryanoasis/vim-devicons#developer, I can replace line 110, within buftablime.vim from this:
let tab.label = lpad . get(tab, 'pre', '') . tab.label . ' '
to this:
let tab.label = lpad . get(tab, 'pre', '') . tab.label . ' %{WebDevIconsGetFileTypeSymbol()} '.

It mostly works, except that all buffers get the same icon as the current. *sigh. I'm not sure how to address this, and would greatly appreciate your help, assuming it's possible.

Thank you.

Feature request: ordinal _and_ buffer number in tab

Lately I'm finding myself using buffer numbers in various :b commands, but I still like ordinal numbering for switching between buffers using Buftabline. Would you be open to a g:buftabline_numbers option that shows both?

I'm thinking it would look something like: 1 foo.txt [1] | 2 bar.txt [7] | 3 baz.txt [2]. If you're open to this I'd be glad to try implementing it myself, but I wanted to ask first since it could be treading on the ground of #35.

Feature: Make separator configurable

With the current font in my uxrvt-unicode terminal the separator does not look good (it does in gvim. Reading the source code I stopped at this line:
let lpad = g:buftabline_separators ? nr2char(0x23B8) : ' '

I think it would be nice to allow some other character via some globar variable like:
g:buftabline_separator_character

Indicators for modified and read only file

The one thing I found missing in this buffer bar compared to airline's buffer bar is an indicator showing if a file is changed or read only by some indicator in the tab. Airline uses a ‘+’ to indicate change and (I think) a ‘-’ to indicate read-only. It would look like this:
Indicators for modified and read only file

I have implemented this for myself already, so if you agree I can submit a PR.

Remove underline

How do i remove the underline off the buffernames like shown in your preview screenshot?

Splits: non-focused split more highlighted than focused one

Hey guys,

I've been finding this very disturbing for quite a while. I often work with splits and multiple buffers. In that kind of situations, the higlighting is very unintuitive: the inactive split buffers are much more emphasized (buffer name has a background color) than the active one (buffer name font color is set).

For instance :

capture d ecran 2019-02-22 a 11 49 41

What would be the best way to deal with this? Change the class used for highlighting? Make it a parameter? Any other idea?

Support lightline.vim

I've already posted about this over there (itchyny/lightline.vim#264), but I thought I'd drop a note here, as well:

Lightline.vim includes a beautiful tabline replacement, but it only shows the classic vim tabpages. I'd love to see some integration, if possible!

No buffer shown for netrw

Say I have the following directory listing:

.
├── a
├── b
├── c
└── dir
    ├── a2
    ├── b2
    └── c2

1 directory, 6 files

I open everything with vim *:

image

I get my files and the dir/ listing as expected. But if I change to the dir buffer, the dir/ option in the tabline isn't highlighted.

image

I assume this is because that buffer is listed as "no name". Is this something that's actually possible to fix? If there's no buffer name, I can imagine that with multiple directories open it might not be possible to work out which was highlighted.

Only one character is shown

Hi, awesome plugin!

I've noticed that the listed tabs only have the last character in the filename listed ('c' for vimrc; 'm' for autoload.vim). This only seems to happen in Tmux right when I open vim. If I source my vimrc, then it solves the issue for that instance only. Works fine when not in Tmux, however. Not a big deal, just a minor inconvenience.

Netrw integration

Hi, thanks for the plugin!

Is it possible to show netrw buffer too?
Currently its not showing and surprise me when I do :bp the buffer switch to netrw buffer, not the buffer on tab list.

Thanks.

Move tab functionality

Hi,

Can you please add the move functionality. Vim already has this for tabs with :tabmove but this dose not work your plugin. This is extremely useful when one has many tabs/buffers and wants to sort the order in the tabline.

This is the only thing missing form, otherwise, awesome plugin!

:Explore command error

When I start vim (without a specific argument file), if i run the Explore command on a [No Name] buffer, I got this error:

Error detected while processing function buftabline#render:
line 104:
E684: list index out of range: 0
Press ENTER or type command to continue
Error detected while processing function buftabline#render:
line 103:
E116: Invalid arguments for function substitute(tabs[0].label, lpad, ' ', '')
Press ENTER or type command to continue

tab highlight color override bug — coloring over underline

I wanted to change the tab colors so that the current tab is highlighted brighter:
highlight BufTabLineCurrent cterm=NONE ctermbg=15 ctermfg=8 gui=NONE guibg=#ffffff guifg=#d70000

doing so made the underline of the current tab appear to be colored over:

tag_view

Obviously not the most important bug in the world but I thought I would bring it to your attention.

Plug mapping to go to the last buffer

@simaoneves wrote:

Would love to see a mapping for something like Chromes last tab. So in a mac Cmd-<number> takes you to the desired tab, like buftabline, but if you have more than 9 tabs open and press Cmd-9 it takes you to the last tab.

Does anyone else uses this?

User-defined tab rendering

To avoid cramming everything possible into configuration options, allow the user to specify how tabs should be rendered, possibly by providing custom rendering code for tabs.

Support Vim tabs

There’s no reason this couldn’t incorporate Vim tabs by just showing a | 1 | 2 | 3 |-style display at either end of the tabline. Clickable ’n’ all. They would not have names, just numbers, but that’s OK, Vim fakes that part too, and it’ll help keep the display compact since the space is needed for buffer labels.

Is there a command to disable it?

I wish to disable vim-buftabline for certain file types, but setting let g:buftabline_show = 0 have no effect. How can I do this?

Doesn’t iteroperate well with Netrw

This is probably user error, and not a bug, but when I have buffers open, :bprev and :bnext work as expected, but when I do :e to get a file list, the file list becomes a buffer that I can not :prev.

i.e. I can cycle past it using next, but previous doesn't work. Also, the "tab" at the top isn't highlighted when I'm viewing the ":e" buffer.

Any ideas on how I'm supposed to be handling this situation? Thanks.

NeoVim external GUI tabline needs to be disabled separately

I'm using the latest nvim 0.4 + windows10(64bit).
This is the result when opened two buffers with:

:badd aaa
:badd bbb

image

My config in vimrc:

Plug 'ap/vim-buftabline'
let g:buftabline_show=1
let g:buftabline_numbers=2
let g:buftabline_indicators='on'

Why there is a tabline, not buffer line ? How to make it same as in the demo screenshot? Thanks.

Highlight name only of the buffer with cursor in it?

Right now if two buffers are open in a split, both names are highlighted in the tabline, no matter which buffer the cursor is in. Can there be an option to highlight the name of only the one with the cursor?

Order options for Buftabline

Hi! Love buftabline, its great.

#61 already mentioned something similar, but is it possible to order the buffer-tabs alphabetically by file name? So, opening a new tab would just insert the buffer into the correct, ordered space. That, or a function that orders the tabs.

Is this possible already? Or would we need a new PR?

Thanks for the plugin :)

Tabline sometimes disappears when closing location list

This is a really peculiar bug that only happens sometimes, and I'm not even sure buftabline is the responsible party. I have an autocmd set up to run Neomake on every BufWritePost. If there are errors, they get populated into the location list. If I correct the errors, save again, and Neomake finds no errors remaining, it will close the location list, which somehow makes the tabline disappear. Here's a terrible quality gif to demonstrate:

bug

This is on Neovim 0.2.1 FWIW. I've tried all manner of ways to reproduce this and have yet to track down the root cause. I have been able to reproduce it without using Neomake (just by using laddfile somefile.txt, lopen and lclose). I've looked through buftabline's source and nothing has jumped out at me as being an obvious culprit, but I can't claim to fully understand everything it does. Mostly I'm just reporting it here as a first step, to see if you have any thoughts.

Better error for calling `<Plug>BufTabLine.Go` beyond available buffers

Hey!

So far it seems like a great lightweight plugin. So much more performant than MiniBufExplorer and Airline. Thanks!

Would you mind improving the error message when calling <Plug>BufTabLine.Go beyond the available buffers? Given 3 buffers, calling <Plug>BufTabLine.Go(4) throws a two-line error with a prompt to press Enter at the end:

E684: list index out of range: 4
E15: Invalid expression: 'b'.buftabline#user_buffers()[4]

The "Press Enter" requirement from Vim is slightly too disruptive. Maybe limit that to a one-liner.

Thanks and cheers!

Buftabline in command bar?

I like the way bling/vim-bufferline displays buffer list in command bar but it lacks mappings options, make it hard to switch between buffers, any thought about it?

Don't show if only 1 buffer?

Hi, is there a simple way to hack the plugin in order to only show the buftabline when more than 1 buffer is opened?

Thanks!

Insert <C-u> into noremap definition to avoid E:481 No range allowed

E:481 No range allowed occurs when key mappings like noremap <Leader>1 <Plug>BufTabLine.Go(1) are defined and typing 1<Leader>1 by mistake. To avoid this, simply insert <C-u> into the noremap definition after :.

execute printf("noremap <silent> <Plug>BufTabLine.Go(%d) :exe 'b'.get(buftabline#user_buffers(),%d,'')<cr>", s:n, s:n - 1)

For more information, see :help N: and https://vi.stackexchange.com/questions/9751/understanding-ctrl-u-combination :)

Add 'modified' state to buffer name

Hi,

could you add '+' to the end of the filename in buftabline if the file is modified?

That would help me a lot.
Thanks for the great plugin.

Give user a chance to change tabline option

here is my setting of your plugin:

    set showtabline=1  
    let g:buftabline_numbers=2
    let g:buftabline_show=1
    let g:buftabline_indicators=1

I have noticed that tabline option is empty when tab is opened.

This will cause visual differences in mccvim and gvim .

2017-07-15 8 39 14

2017-07-15 8 39 23

Current Buffer not highlighted when using NerdTree

Hi, cool plugin, exactly what I was looking for.

Using NerdTree the current open buffer is not highlighted when the focus is not on NerdTree but on the opened buffer. Is there a way to fix this?

Focus on the buffer:
screen shot 2018-04-12 at 19 25 23

Focus on NerdTree:
screen shot 2018-04-12 at 19 30 35

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.