Nvim :help
pages, generated
from source
using the tree-sitter-vimdoc parser.
:tabe
:tabedit
:tabnew
:[count]tabnew
Open a new tab page with an empty window, after the current
tab page. If [count] is given the new tab page appears after
the tabpage [count] otherwise the new tab page will appear
after the current one.:tabnew " opens tabpage after the current one :.tabnew " as above :+tabnew " opens tabpage after the next tab page " note: it is one further than :tabnew :-tabnew " opens tabpage before the current :0tabnew " opens tabpage before the first one :$tabnew " opens tabpage after the last one:[count]tabe[dit] [++opt] [+cmd]
{file}
:[count]tabnew [++opt] [+cmd] {file}
Open a new tab page and edit {file}
, like with :edit.
For [count] see :tabnew above.{file}
:tabf
:tabfind
Open a new tab page and edit {file}
in 'path', like with
:find. For [count] see :tabnew above.{cmd}
:tab
Execute {cmd}
and when it opens a new window open a new tab
page instead. Doesn't work for :diffsplit, :diffpatch,
:execute and :normal.
If [count] is given the new tab page appears after the tab
page [count] otherwise the new tab page will appear after the
current one.
Examples::tab split " opens current buffer in new tab page :tab help gt " opens tab page with help for "gt" :.tab help gt " as above :+tab help " opens tab page with help after the next " tab page :-tab help " opens tab page with help before the " current one :0tab help " opens tab page with help before the " first one :$tab help " opens tab page with help after the last " oneCTRL-W gf Open a new tab page and edit the file name under the cursor. See CTRL-W_gf.
:tabc
:tabclose
:tabc[lose][!] Close current tab page.
This command fails when:
:tabclose " close the current tab page:{count}tabc[lose][!] :tabc[lose][!]
{count}
Close tab page {count}
. Fails in the same way as :tabclose
above.:-tabclose " close the previous tab page :+tabclose " close the next tab page :1tabclose " close the first tab page :$tabclose " close the last tab page :tabclose -2 " close the 2nd previous tab page :tabclose + " close the next tab page :tabclose 3 " close the third tab page :tabclose $ " close the last tab page :tabclose # " close the last accessed tab pageWhen a tab is closed the next tab page will become the current one.
:tabo
:tabonly
:tabo[nly][!] Close all other tab pages.
When the 'hidden' option is set, all buffers in closed windows
become hidden.
When 'hidden' is not set, and the 'autowrite' option is set,
modified buffers are written. Otherwise, windows that have
buffers that are modified are not removed, unless the [!] is
given, then they become hidden. But modified buffers are
never abandoned, so changes cannot get lost.:tabonly " close all tab pages except the current one:tabo[nly][!]
{count}
Close all tab pages except {count}
one.:.tabonly " as above :-tabonly " close all tab pages except the previous " one :+tabonly " close all tab pages except the next one :1tabonly " close all tab pages except the first one :$tabonly " close all tab pages except the last one :tabonly - " close all tab pages except the previous " one :tabonly +2 " close all tab pages except the two next " one :tabonly 1 " close all tab pages except the first one :tabonly $ " close all tab pages except the last one :tabonly # " close all tab pages except the last " accessed oneSWITCHING TO ANOTHER TAB PAGE:
:tabn
:tabnext
gt
<C-PageDown>
CTRL-<PageDown>
<C-PageDown>
gt i_CTRL-<PageDown>
i_<C-PageDown>
Go to the next tab page. Wraps around from the last to the
first one.{count}
Go to tab page {count}
. The first tab page has number one.:-tabnext " go to the previous tab page :+tabnext " go to the next tab page :+2tabnext " go to the two next tab page :1tabnext " go to the first tab page :$tabnext " go to the last tab page :tabnext $ " as above :tabnext # " go to the last accessed tab page :tabnext - " go to the previous tab page :tabnext -1 " as above :tabnext + " go to the next tab page :tabnext +1 " as above
{count}
<C-PageDown>
{count}
gt Go to tab page {count}
. The first tab page has number one.:tabp
:tabprevious
gT
:tabN
:tabN[ext] :tabNext
CTRL-<PageUp>
<C-PageUp>
<C-PageUp>
i_CTRL-<PageUp>
i_<C-PageUp>
gT Go to the previous tab page. Wraps around from the first one
to the last one.{count}
:tabN[ext] {count}
{count}
<C-PageUp>
{count}
gT Go {count}
tab pages back. Wraps around from the first one
to the last one. Note that the use of {count}
is different
from :tabnext, where it is used as the tab page number.<C-Tab>
CTRL-<Tab>
<C-Tab>
CTRL-W g<Tab> g<Tab>
CTRL-W_g<Tab>
g<Tab> Go to the last accessed tab page.:tabs
:tabs List the tab pages and the windows they contain.
Shows a ">" for the current window.
Shows a "+" for modified buffers.
For example:
:tabm
:tabmove
:[N]tabm[ove]
Move the current tab page to after tab page N. Use zero to
make the current tab page the first one. N is counted before
the move, thus if the second tab is the current one,
:tabmove 1
and :tabmove 2
have no effect.
Without N the tab page is made the last one.:.tabmove " do nothing :-tabmove " move the tab page to the left :+tabmove " move the tab page to the right :0tabmove " move the tab page to the beginning of the tab " list :tabmove 0 " as above :tabmove " move the tab page to the last :$tabmove " as above :tabmove $ " as above :tabmove # " move the tab page after the last accessed " tab page:tabm[ove] +[N] :tabm[ove] -[N] Move the current tab page N places to the right (with +) or to the left (with -).
:tabmove - " move the tab page to the left :tabmove -1 " as above :tabmove + " move the tab page to the right :tabmove +1 " as aboveNote that although it is possible to move a tab behind the N-th one by using :Ntabmove. And move it by N places by using :+Ntabmove. For clarification what +N means in this context see [range].
:tabd
:tabdo
:[range]tabd[o] {cmd}
Execute {cmd}
in each tab page or, if [range] is given, only
in tabpages which tab page number is in the [range]. It works
like doing this::tabfirst :{cmd} :tabnext :{cmd} etc.
{cmd}
can contain '|' to concatenate several commands.
{cmd}
must not open or close tab pages or reorder them.
Also see :windo, :argdo, :bufdo, :cdo, :ldo, :cfdo
and :lfdo.tabline-menu
The GUI tab pages line has a popup menu. It is accessed with a right click.
The entries are:
Close Close the tab page under the mouse pointer. The
current one if there is no label under the mouse
pointer.
New Tab Open a tab page, editing an empty buffer. It appears
to the left of the mouse pointer.
Open Tab... Like "New Tab" and additionally use a file selector to
select a file to edit.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: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 label to close the current tab page if tabpagenr('$') > 1 let s ..= '%=%#TabLine#%999Xclose' endif return s endfunctionNow the MyTabLabel() function is called for each tab page to get its label.
function MyTabLabel(n) let buflist = tabpagebuflist(a:n) let winnr = tabpagewinnr(a:n) return bufname(buflist[winnr - 1]) endfunctionThis is just a simplistic example that results in a tab pages line that resembles the default, but without adding a + for a modified buffer or truncating the names. You will want to reduce the width of labels in a clever way when there is not enough room. Check the 'columns' option for the space available.
:set guitablabel=%N\ %fAn example that resembles the default 'guitablabel': Show the number of windows in the tab page and a '+' if there is a modified buffer:
function GuiTabLabel() let label = '' let bufnrlist = tabpagebuflist(v:lnum) " 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 " 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 buffer name return label .. bufname(bufnrlist[tabpagewinnr(v:lnum) - 1]) endfunction set guitablabel=%{GuiTabLabel()}Note that the function must be defined before setting the option, otherwise you get an error message for the function not being known.