Home Explore Blog CI



neovim

5th chunk of `runtime/doc/tabpage.txt`
dcb2123d3d12c2b8c741215539f784190341b2206d305e070000000100000b2c
 other
files.

Variables local to a tab page start with "t:". |tabpage-variable|

Currently there is only one option local to a tab page: 'cmdheight'.

						*tabnew-autocmd*
The TabLeave and TabEnter autocommand events can be used to do something when
switching from one tab page to another.  The exact order depends on what you
are doing.  When creating a new tab page this works as if you create a new
window on the same buffer and then edit another buffer.  Thus ":tabnew"
triggers:
	WinLeave		leave current window
	TabLeave		leave current tab page
	WinEnter		enter window in new tab page
	TabEnter		enter new tab page
	BufLeave		leave current buffer
	BufEnter		enter new empty buffer

When switching to another tab page the order is:
	BufLeave
	WinLeave
	TabLeave
	WinEnter
	TabEnter
	BufEnter

When entering a new tab page (|:tabnew|), TabNew is triggered before TabEnter
and after WinEnter.

==============================================================================
4. Setting 'tabline'					*setting-tabline*

The 'tabline' option specifies what the line with tab pages labels looks like.
It is only used when there is no GUI tab line.

You can use the 'showtabline' option to specify when you want the line with
tab page labels to appear: never, when there is more than one tab page or
always.

The highlighting of the tab pages line is set with the groups TabLine
TabLineSel and TabLineFill.  |hl-TabLine| |hl-TabLineSel| |hl-TabLineFill|

A "+" will be shown for a tab page that has a modified window.  The number of
windows in a tabpage is also shown.  Thus "3+" means three windows and one of
them has a modified buffer.

The 'tabline' option allows you to define your preferred way to tab pages
labels.  This isn't easy, thus an example will be given here.

For basics see the 'statusline' option.  The same items can be used in the
'tabline' option.  Additionally, the |tabpagebuflist()|, |tabpagenr()| and
|tabpagewinnr()| functions are useful.

Since the number of tab labels will vary, you need to use an expression for
the whole option.  Something like: >
	:set tabline=%!MyTabLine()

Then define the MyTabLine() function to list all the tab pages labels.  A
convenient method is to split it in two parts:  First go over all the tab
pages and define labels for them.  Then get the label for each tab page. >

	function MyTabLine()
	  let s = ''
	  for i in range(tabpagenr('$'))
	    " select the highlighting
	    if i + 1 == tabpagenr()
	      let s ..= '%#TabLineSel#'
	    else
	      let s ..= '%#TabLine#'
	    endif

	    " set the tab page number (for mouse clicks)
	    let s ..= '%' .. (i + 1) .. 'T'

	    " the label is made by MyTabLabel()
	    let s ..= ' %{MyTabLabel(' .. (i + 1) .. ')} '
	  endfor

	  " after the last tab fill with TabLineFill and reset tab page nr
	  let s ..= '%#TabLineFill#%T'

	  " right-align the

Title: Setting the 'tabline' option
Summary
This section discusses the 'tabline' option, which allows customization of the tab page labels line, used when there's no GUI tab line. The 'showtabline' option controls when the tabline appears. It highlights tab pages with TabLine, TabLineSel, and TabLineFill groups. It also covers how to define a custom 'tabline' using functions like tabpagebuflist(), tabpagenr(), and tabpagewinnr(), providing an example function MyTabLine() to generate tab labels.