2006-03-01 22:01:55 +00:00
|
|
|
*tabpage.txt* For Vim version 7.0aa. Last change: 2006 Mar 01
|
2006-02-18 22:14:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
|
|
|
|
|
|
|
|
2006-02-20 21:27:21 +00:00
|
|
|
Editing with windows in multiple tab pages. *tab-page* *tabpage*
|
2006-02-18 22:14:51 +00:00
|
|
|
|
|
|
|
The commands which have been added to use multiple tab pages are explained
|
|
|
|
here. Additionally, there are explanations for commands that work differently
|
|
|
|
when used in combination with more than one tab page.
|
|
|
|
|
2006-02-21 22:02:53 +00:00
|
|
|
1. Introduction |tab-page-intro|
|
|
|
|
2. Commands |tab-page-commands|
|
|
|
|
3. Other items |tab-page-other|
|
|
|
|
4. Setting 'tabline' |setting-tabline|
|
2006-02-25 21:45:02 +00:00
|
|
|
5. Setting 'guitablabel' |setting-guitablabel|
|
2006-02-18 22:14:51 +00:00
|
|
|
|
|
|
|
{Vi does not have any of these commands}
|
|
|
|
{not able to use multiple tab pages when the |+windows| feature was disabled
|
|
|
|
at compile time}
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
1. Introduction *tab-page-intro*
|
|
|
|
|
|
|
|
A tab page holds one or more windows. You can easily switch between tab
|
|
|
|
pages, so that you have several collections of windows to work on different
|
|
|
|
things.
|
|
|
|
|
|
|
|
Usually you will see a list of labels at the top of the Vim window, one for
|
|
|
|
each tab page. With the mouse you can click on the label to jump to that tab
|
|
|
|
page. There are other ways to move between tab pages, see below.
|
|
|
|
|
|
|
|
Most commands work only in the current tab page. That includes the |CTRL-W|
|
2006-03-01 22:01:55 +00:00
|
|
|
commands, |:windo|, |:all| and |:ball| (when not using the |:tab| modifier).
|
|
|
|
The commands that are aware of other tab pages than the current one are
|
|
|
|
mentioned below.
|
2006-02-18 22:14:51 +00:00
|
|
|
|
|
|
|
Tabs are also a nice way to edit a buffer temporarily without changing the
|
|
|
|
current window layout. Open a new tab page, do whatever you want to do and
|
|
|
|
close the tab page.
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
2. Commands *tab-page-commands*
|
|
|
|
|
|
|
|
OPENING A NEW TAB PAGE:
|
|
|
|
|
|
|
|
When starting Vim "vim -p filename ..." opens each file argument in a separate
|
2006-03-01 22:01:55 +00:00
|
|
|
tab page (up to 'tabpagemax'). |-p|
|
2006-02-18 22:14:51 +00:00
|
|
|
|
2006-02-23 21:26:58 +00:00
|
|
|
A double click with the mouse in the tab pages line opens a new, empty tab
|
|
|
|
page. It is placed left of the position of the click. The first click may
|
|
|
|
select another tab page first, causing an extra screen update.
|
|
|
|
|
|
|
|
:tabe[dit] *:tabe* *:tabedit* *:tabnew*
|
|
|
|
:tabnew Open a new tab page with an empty window, after the current
|
|
|
|
tab page.
|
2006-02-18 22:14:51 +00:00
|
|
|
|
|
|
|
:tabe[dit] [++opt] [+cmd] {file}
|
2006-02-23 21:26:58 +00:00
|
|
|
:tabnew [++opt] [+cmd] {file}
|
2006-02-18 22:14:51 +00:00
|
|
|
Open a new tab page and edit {file}, like with |:edit|.
|
|
|
|
|
2006-02-20 21:27:21 +00:00
|
|
|
:tabf[ind] [++opt] [+cmd] {file} *:tabf* *:tabfind*
|
2006-02-18 22:14:51 +00:00
|
|
|
Open a new tab page and edit {file} in 'path', like with
|
|
|
|
|:find|.
|
|
|
|
{not available when the |+file_in_path| feature was disabled
|
|
|
|
at compile time}
|
|
|
|
|
2006-02-23 21:26:58 +00:00
|
|
|
:[count]tab {cmd} *:tab*
|
|
|
|
Execute {cmd} and when it opens a new window open a new tab
|
|
|
|
page instead. Doesn't work for |:diffsplit| or |:diffpatch|.
|
|
|
|
When [count] is omitted the tab page appears after the current
|
|
|
|
one. When [count] is specified the new tab page comes after
|
|
|
|
tab page [count]. Use ":0tab cmd" to get the new tab page as
|
|
|
|
the first one. Examples: >
|
|
|
|
:tab split " opens current buffer in new tab page
|
|
|
|
:tab help gt " opens tab page with help for "gt"
|
|
|
|
|
2006-02-18 22:14:51 +00:00
|
|
|
|
|
|
|
CLOSING A TAB PAGE:
|
|
|
|
|
2006-02-23 21:26:58 +00:00
|
|
|
Closing the last window of a tab page closes the tab page too, unless there is
|
|
|
|
only one tab page.
|
2006-02-18 22:14:51 +00:00
|
|
|
|
|
|
|
Using the mouse: If the tab page line is displayed you can click in the "X" at
|
2006-02-23 21:26:58 +00:00
|
|
|
the top right to close the current tab page. A custom |'tabline'| may show
|
|
|
|
something else.
|
2006-02-18 22:14:51 +00:00
|
|
|
|
|
|
|
*:tabc* *:tabclose*
|
|
|
|
:tabc[lose][!] Close current tab page.
|
|
|
|
This command fails when:
|
|
|
|
- There is only one tab page on the screen. *E784*
|
|
|
|
- When 'hidden' is not set, [!] is not used, a buffer has
|
|
|
|
changes, and there is no other window on this buffer.
|
|
|
|
Changes to the buffer are not written and won't get lost, so
|
|
|
|
this is a "safe" command.
|
|
|
|
|
|
|
|
:tabc[lose][!] {count}
|
|
|
|
Close tab page {count}. Fails in the same way as ':tabclose"
|
|
|
|
above.
|
|
|
|
|
|
|
|
*: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.
|
|
|
|
|
|
|
|
|
|
|
|
SWITCHING TO ANOTHER TAB PAGE:
|
|
|
|
|
|
|
|
Using the mouse: If the tab page line is displayed you can click in a tab page
|
2006-02-23 21:26:58 +00:00
|
|
|
label to switch to that tab page. Click where there is no label to go to the
|
|
|
|
next tab page. |'tabline'|
|
2006-02-18 22:14:51 +00:00
|
|
|
|
2006-02-23 21:26:58 +00:00
|
|
|
:tabn[ext] *:tabn* *:tabnext* *gt*
|
2006-02-18 22:14:51 +00:00
|
|
|
gt Go to the next tab page. Wraps around from the last to the
|
|
|
|
first one.
|
|
|
|
|
2006-02-23 21:26:58 +00:00
|
|
|
:tabn[ext] {count}
|
2006-02-18 22:14:51 +00:00
|
|
|
{count}gt Go to tab page {count}. The first tab page has number one.
|
|
|
|
|
|
|
|
|
2006-02-23 21:26:58 +00:00
|
|
|
:tabp[revious] *:tabp* *:tabprevious* *gT*
|
|
|
|
:tabN[ext] *:tabN* *:tabNext*
|
|
|
|
gT Go to the previous tab page. Wraps around from the first one
|
|
|
|
to the last one.
|
|
|
|
|
|
|
|
:tabp[revious] {count}
|
|
|
|
:tabN[ext] {count}
|
|
|
|
{count}gT Go {count} tab pages back. Wraps around from the first one
|
|
|
|
to the last one.
|
|
|
|
|
2006-02-24 23:53:04 +00:00
|
|
|
:tabr[ewind] *:tabfir* *:tabfirst* *:tabr* *:tabrewind*
|
2006-02-25 21:45:02 +00:00
|
|
|
:tabfir[st] Go to the first tab page.
|
2006-02-24 23:53:04 +00:00
|
|
|
|
|
|
|
*:tabl* *:tablast*
|
|
|
|
:tabl[ast] Go to the last tab page.
|
|
|
|
|
2006-02-23 21:26:58 +00:00
|
|
|
|
2006-02-18 22:14:51 +00:00
|
|
|
Other commands:
|
|
|
|
*:tabs*
|
2006-02-23 21:26:58 +00:00
|
|
|
:tabs List the tab pages and the windows they contain.
|
|
|
|
Shows a ">" for the current window.
|
|
|
|
Shows a "+" for modified buffers.
|
|
|
|
|
|
|
|
|
|
|
|
REORDERING TAB PAGES:
|
|
|
|
|
|
|
|
*:tabm* *:tabmove*
|
|
|
|
:tabmove N Move the current tab page to after tab page N. Use zero to
|
|
|
|
make the current tab page the first one. Without N the tab
|
|
|
|
page is made the last one.
|
2006-02-18 22:14:51 +00:00
|
|
|
|
2006-02-24 23:53:04 +00:00
|
|
|
|
|
|
|
LOOPING OVER TAB PAGES:
|
|
|
|
|
|
|
|
*:tabd* *:tabdo*
|
|
|
|
:tabd[o] {cmd} Execute {cmd} in each tab page.
|
|
|
|
It works like doing this: >
|
|
|
|
:tabfirst
|
|
|
|
:{cmd}
|
|
|
|
:tabnext
|
|
|
|
:{cmd}
|
|
|
|
etc.
|
|
|
|
< This only operates in the current window of each tab page.
|
|
|
|
When an error is detected on one tab page, further tab pages
|
|
|
|
will not be visited.
|
|
|
|
The last tab page (or where an error occurred) becomes the
|
|
|
|
current tab page.
|
|
|
|
{cmd} can contain '|' to concatenate several commands.
|
|
|
|
{cmd} must not open or close tab pages or reorder them.
|
|
|
|
{not in Vi} {not available when compiled without the
|
|
|
|
|+listcmds| feature}
|
|
|
|
Also see |:windo|, |:argdo| and |:bufdo|.
|
|
|
|
|
2006-02-18 22:14:51 +00:00
|
|
|
==============================================================================
|
|
|
|
3. Other items *tab-page-other*
|
|
|
|
|
|
|
|
Diff mode works per tab page. You can see the diffs between several files
|
|
|
|
within one tab page. Other tab pages can show differences between other
|
|
|
|
files.
|
|
|
|
|
2006-02-20 21:27:21 +00:00
|
|
|
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
|
|
|
|
TabEnter enter new tab page
|
|
|
|
WinEnter enter window in new tab page
|
|
|
|
BufLeave leave current buffer
|
|
|
|
BufEnter enter new empty buffer
|
|
|
|
|
2006-02-21 22:02:53 +00:00
|
|
|
When switching to another tab page the order is:
|
2006-02-20 21:27:21 +00:00
|
|
|
BufLeave
|
|
|
|
WinLeave
|
|
|
|
TabLeave
|
|
|
|
TabEnter
|
|
|
|
WinEnter
|
|
|
|
BufEnter
|
2006-02-18 22:14:51 +00:00
|
|
|
|
2006-02-21 22:02:53 +00:00
|
|
|
==============================================================================
|
|
|
|
4. Setting 'tabline' *setting-tabline*
|
|
|
|
|
2006-02-25 21:45:02 +00:00
|
|
|
The 'tabline' option specifies what the line with tab pages labels looks like.
|
|
|
|
It is only used when there is no GUI tab line.
|
|
|
|
|
2006-02-21 22:02:53 +00:00
|
|
|
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|
|
|
|
|
|
|
|
|
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 expresion 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('$'))
|
2006-02-22 21:25:37 +00:00
|
|
|
" select the highlighting
|
2006-02-21 22:02:53 +00:00
|
|
|
if i + 1 == tabpagenr()
|
|
|
|
let s .= '%#TabLineSel#'
|
|
|
|
else
|
|
|
|
let s .= '%#TabLine#'
|
|
|
|
endif
|
2006-02-22 21:25:37 +00:00
|
|
|
|
|
|
|
" set the tab page number (for mouse clicks)
|
|
|
|
let s .= '%' . (i + 1) . 'T'
|
|
|
|
|
|
|
|
" the label is made by MyTabLabel()
|
2006-02-21 22:02:53 +00:00
|
|
|
let s .= ' %{MyTabLabel(' . (i + 1) . ')} '
|
|
|
|
endfor
|
2006-02-22 21:25:37 +00:00
|
|
|
|
|
|
|
" 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
|
|
|
|
|
2006-02-21 22:02:53 +00:00
|
|
|
return s
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
Now 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])
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
This 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
|
|
|
|
trunctating 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
|
2006-02-22 21:25:37 +00:00
|
|
|
space available.
|
2006-02-18 22:14:51 +00:00
|
|
|
|
2006-02-25 21:45:02 +00:00
|
|
|
==============================================================================
|
|
|
|
5. Setting 'guitablabel' *setting-guitablabel*
|
|
|
|
|
|
|
|
When the GUI tab pages line is displayed, 'guitablabel' can be used to
|
|
|
|
specify the label to display for each tab page. Unlike 'tabline', which
|
|
|
|
specifies the whole tab pages line at once, 'guitablabel' is used for each
|
|
|
|
label separately.
|
|
|
|
|
|
|
|
See the 'statusline' option for the format of the value.
|
|
|
|
|
|
|
|
The "%N" item can be used for the current tab page number. The |v:lnum|
|
2006-02-26 23:59:20 +00:00
|
|
|
variable is also set to this number when 'guitablabel' is evaluated.
|
|
|
|
The items that use a file name refer to the current window of the tab page.
|
2006-02-25 21:45:02 +00:00
|
|
|
|
|
|
|
Note that syntax highlighting is not used for 'guitablabel'. The %T and %X
|
2006-02-26 23:59:20 +00:00
|
|
|
items are also ignored.
|
2006-02-25 21:45:02 +00:00
|
|
|
|
2006-02-26 23:59:20 +00:00
|
|
|
A simple example that puts the tab page number and the buffer name in the
|
|
|
|
label: >
|
2006-02-25 21:45:02 +00:00
|
|
|
:set guitablabel=%N\ %f
|
|
|
|
|
|
|
|
An example that resembles the default: Show the number of windows in the tab
|
|
|
|
page and a '+' if there is a modifed buffer: >
|
|
|
|
|
2006-02-26 23:59:20 +00:00
|
|
|
function GuiTabLabel()
|
2006-02-25 21:45:02 +00:00
|
|
|
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
|
2006-02-26 23:59:20 +00:00
|
|
|
|
2006-02-25 21:45:02 +00:00
|
|
|
set guitablabel=%{GuiTabLabel()}
|
2006-02-26 23:59:20 +00:00
|
|
|
|
|
|
|
Note that the function must be defined before setting the option, otherwise
|
|
|
|
you get an error message for the function not being known.
|
|
|
|
|
2006-02-25 21:45:02 +00:00
|
|
|
|
2006-02-18 22:14:51 +00:00
|
|
|
vim:tw=78:ts=8:ft=help:norl:
|