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}
。第一個分頁標籤的編號為一。:-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}
。第一個分頁標籤的編號為一。<C-PageUp>
<C-PageUp> i_CTRL-<PageUp> i_<C-PageUp> gT 移至上一個分頁標籤。從第一個換至最後一個。{count}
:tabN[ext] {count}
{count}
<C-PageUp>
{count}
gT 返回 {count}
個分頁標籤。從第一個換至最後一個。請注意,{count}
的用法與 :tabnext 不同,在 :tabnext 中,它被用作分頁標籤編號。: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()}請注意,必須先定義函數,然後才能設定選項,否則會收到找不到函數的錯誤訊息。