view runtime/doc/tabpage.txt @ 678:93a1bf1cb633

updated for version 7.0203
author vimboss
date Tue, 21 Feb 2006 22:02:53 +0000
parents 51794dc170f7
children 9364d114ed8d
line wrap: on
line source

*tabpage.txt*   For Vim version 7.0aa.  Last change: 2006 Feb 21


		  VIM REFERENCE MANUAL    by Bram Moolenaar


Editing with windows in multiple tab pages.		*tab-page* *tabpage*

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.

1. Introduction			|tab-page-intro|
2. Commands			|tab-page-commands|
3. Other items			|tab-page-other|
4. Setting 'tabline'		|setting-tabline|

{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|
commands, |:windo|, |:all| and |:ball|.  The commands that are aware of
other tab pages than the current one are mentioned below.

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
tab page (up to 10). |-p|

:tabe[dit]				*:tabe* *:tabedit* *:tabn* *:tabnew*
:tabn[ew]	Open a new tab page with an empty window.

:tabe[dit] [++opt] [+cmd] {file}
:tabn[ew] [++opt] [+cmd] {file}
		Open a new tab page and edit {file}, like with |:edit|.

:tabf[ind] [++opt] [+cmd] {file}			*:tabf* *:tabfind*
		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}


CLOSING A TAB PAGE:

Using |:close| in the last window of a tab page closes it.

Using the mouse: If the tab page line is displayed you can click in the "X" at
the top right to close the current tab page. |'tabline'|

							*: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
label to switch to that tab page. |'tabline'|

:tab							*:tab* *gt*
gt		Go to the next tab page.  Wraps around from the last to the
		first one.

:tab {count}
{count}gt	Go to tab page {count}.  The first tab page has number one.


Other commands:
							*:tabs*
:tabs		List the tab pages and the windows they contain.  Shows a "+"
		for modified buffers.

==============================================================================
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.

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

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

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

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('$'))
	    if i + 1 == tabpagenr()
	      let s .= '%#TabLineSel#'
	    else
	      let s .= '%#TabLine#'
	    endif
	    let s .= ' %{MyTabLabel(' . (i + 1) . ')} '
	  endfor
	  let s .= '%#TabLineFill#'
	  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
space available, keeping in mind that the "X" at the right will take one more
position.

 vim:tw=78:ts=8:ft=help:norl: