Nvim 的 :help
页面,生成自 源代码 使用 tree-sitter-vimdoc 解析器。
: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}
打开一个新的标签页并编辑 {file}
,类似于使用 :edit。有关 [count],请参见上文中的 :tabnew。{file}
:tabf :tabfind 打开一个新的标签页,并在 'path' 中编辑 {file}
,类似于使用 :find。有关 [count],请参见上文中的 :tabnew。{cmd}
:tab{cmd}
,并在其打开一个新窗口时,改为打开一个新的标签页。不适用于 :diffsplit、 :diffpatch、 :execute 和 :normal。如果指定了 [count],则新标签页将出现在标签页 [count] 之后,否则新标签页将出现在当前标签页之后。示例: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 打开一个新的标签页并编辑光标下的文件名。参见 CTRL-W_gf.
:tabclose " close the current tab page:{count}tabc[lose][!] :tabc[lose][!]
{count}
关闭标签页 {count}
。以与上述 :tabclose
相同的方式失败。:-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 page关闭标签页后,下一个标签页将成为当前标签页。可以使用 'tabclose' 选项来自定义此行为。
:tabonly " close all tab pages except the current one:tabo[nly][!]
{count}
关闭除 {count}
之外的所有标签页。:.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 one切换到另一个标签页
<C-PageDown>
CTRL-<PageDown> <C-PageDown> gt i_CTRL-<PageDown> i_<C-PageDown> 转到下一个标签页。从最后一个标签页循环到第一个标签页。{count}
转到标签页 {count}
。第一个标签页的编号为 1。:-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 转到标签页 {count}
。第一个标签页的编号为 1。<C-PageUp>
<C-PageUp> i_CTRL-<PageUp> i_<C-PageUp> gT 转到上一个标签页。从第一个标签页循环到最后一个标签页。{count}
:tabN[ext] {count}
{count}
<C-PageUp>
{count}
gT 向后转 {count}
个标签页。从第一个标签页循环到最后一个标签页。请注意,使用 {count}
与 :tabnext 的用法不同,在 :tabnext 中,{count}
用作标签页编号。:tabmove 1
和 :tabmove 2
不会产生任何影响。如果未指定 N,则该标签页将变为最后一个标签页。:.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 first :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] 将当前标签页向右(使用 +)或向左(使用 -)移动 N 个位置。
:tabmove - " move the tab page to the left :tabmove -1 " as above :tabmove + " move the tab page to the right :tabmove +1 " as above请注意,虽然可以使用 :Ntabmove 将标签页移动到第 N 个标签页之后,并可以使用 :+Ntabmove 将其移动 N 个位置。有关此上下文中 +N 的含义,请参见 [range]。
{cmd}
在每个标签页中执行 {cmd}
,或者如果指定了 [range],则仅在标签页编号在 [range] 中的标签页中执行。它类似于执行以下操作::tabfirst :{cmd} :tabnext :{cmd} etc.
{cmd}
可以包含 '|' 以连接多个命令。{cmd}
不得打开或关闭标签页,也不得重新排序标签页。另请参见 :windo、 :argdo、 :bufdo、 :cdo、 :ldo、 :cfdo 和 :lfdo。:set tabline=%!MyTabLine()然后定义 MyTabLine() 函数以列出所有选项卡页面标签。 一种方便的方法是将其分成两部分:首先遍历所有选项卡页面,并为它们定义标签。 然后获取每个选项卡页面的标签。
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 endfunction现在,将为每个选项卡页面调用 MyTabLabel() 函数以获取其标签。
function MyTabLabel(n) let buflist = tabpagebuflist(a:n) let winnr = tabpagewinnr(a:n) return bufname(buflist[winnr - 1]) endfunction这只是一个简单的示例,它会生成类似于默认选项卡页面行的选项卡页面行,但不会为修改的缓冲区添加“+”,也不会截断名称。 当没有足够的空间时,您需要以一种巧妙的方式减少标签的宽度。 请查看选项 'columns' 以获取可用空间。
:set guitablabel=%N\ %f一个类似于默认 'guitablabel' 的示例:显示选项卡页面中的窗口数量,如果存在修改的缓冲区,则显示“+”
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()}请注意,必须在设置选项之前定义函数,否则您会收到有关函数未知的错误消息。