682
|
1 *tabpage.txt* For Vim version 7.0aa. Last change: 2006 Feb 23
|
674
|
2
|
|
3
|
|
4 VIM REFERENCE MANUAL by Bram Moolenaar
|
|
5
|
|
6
|
675
|
7 Editing with windows in multiple tab pages. *tab-page* *tabpage*
|
674
|
8
|
|
9 The commands which have been added to use multiple tab pages are explained
|
|
10 here. Additionally, there are explanations for commands that work differently
|
|
11 when used in combination with more than one tab page.
|
|
12
|
678
|
13 1. Introduction |tab-page-intro|
|
|
14 2. Commands |tab-page-commands|
|
|
15 3. Other items |tab-page-other|
|
|
16 4. Setting 'tabline' |setting-tabline|
|
674
|
17
|
|
18 {Vi does not have any of these commands}
|
|
19 {not able to use multiple tab pages when the |+windows| feature was disabled
|
|
20 at compile time}
|
|
21
|
|
22 ==============================================================================
|
|
23 1. Introduction *tab-page-intro*
|
|
24
|
|
25 A tab page holds one or more windows. You can easily switch between tab
|
|
26 pages, so that you have several collections of windows to work on different
|
|
27 things.
|
|
28
|
|
29 Usually you will see a list of labels at the top of the Vim window, one for
|
|
30 each tab page. With the mouse you can click on the label to jump to that tab
|
|
31 page. There are other ways to move between tab pages, see below.
|
|
32
|
|
33 Most commands work only in the current tab page. That includes the |CTRL-W|
|
|
34 commands, |:windo|, |:all| and |:ball|. The commands that are aware of
|
|
35 other tab pages than the current one are mentioned below.
|
|
36
|
|
37 Tabs are also a nice way to edit a buffer temporarily without changing the
|
|
38 current window layout. Open a new tab page, do whatever you want to do and
|
|
39 close the tab page.
|
|
40
|
|
41 ==============================================================================
|
|
42 2. Commands *tab-page-commands*
|
|
43
|
|
44 OPENING A NEW TAB PAGE:
|
|
45
|
|
46 When starting Vim "vim -p filename ..." opens each file argument in a separate
|
|
47 tab page (up to 10). |-p|
|
|
48
|
682
|
49 A double click with the mouse in the tab pages line opens a new, empty tab
|
|
50 page. It is placed left of the position of the click. The first click may
|
|
51 select another tab page first, causing an extra screen update.
|
|
52
|
|
53 :tabe[dit] *:tabe* *:tabedit* *:tabnew*
|
|
54 :tabnew Open a new tab page with an empty window, after the current
|
|
55 tab page.
|
674
|
56
|
|
57 :tabe[dit] [++opt] [+cmd] {file}
|
682
|
58 :tabnew [++opt] [+cmd] {file}
|
674
|
59 Open a new tab page and edit {file}, like with |:edit|.
|
|
60
|
675
|
61 :tabf[ind] [++opt] [+cmd] {file} *:tabf* *:tabfind*
|
674
|
62 Open a new tab page and edit {file} in 'path', like with
|
|
63 |:find|.
|
|
64 {not available when the |+file_in_path| feature was disabled
|
|
65 at compile time}
|
|
66
|
682
|
67 :[count]tab {cmd} *:tab*
|
|
68 Execute {cmd} and when it opens a new window open a new tab
|
|
69 page instead. Doesn't work for |:diffsplit| or |:diffpatch|.
|
|
70 When [count] is omitted the tab page appears after the current
|
|
71 one. When [count] is specified the new tab page comes after
|
|
72 tab page [count]. Use ":0tab cmd" to get the new tab page as
|
|
73 the first one. Examples: >
|
|
74 :tab split " opens current buffer in new tab page
|
|
75 :tab help gt " opens tab page with help for "gt"
|
|
76
|
674
|
77
|
|
78 CLOSING A TAB PAGE:
|
|
79
|
682
|
80 Closing the last window of a tab page closes the tab page too, unless there is
|
|
81 only one tab page.
|
674
|
82
|
|
83 Using the mouse: If the tab page line is displayed you can click in the "X" at
|
682
|
84 the top right to close the current tab page. A custom |'tabline'| may show
|
|
85 something else.
|
674
|
86
|
|
87 *:tabc* *:tabclose*
|
|
88 :tabc[lose][!] Close current tab page.
|
|
89 This command fails when:
|
|
90 - There is only one tab page on the screen. *E784*
|
|
91 - When 'hidden' is not set, [!] is not used, a buffer has
|
|
92 changes, and there is no other window on this buffer.
|
|
93 Changes to the buffer are not written and won't get lost, so
|
|
94 this is a "safe" command.
|
|
95
|
|
96 :tabc[lose][!] {count}
|
|
97 Close tab page {count}. Fails in the same way as ':tabclose"
|
|
98 above.
|
|
99
|
|
100 *:tabo* *:tabonly*
|
|
101 :tabo[nly][!] Close all other tab pages.
|
|
102 When the 'hidden' option is set, all buffers in closed windows
|
|
103 become hidden.
|
|
104 When 'hidden' is not set, and the 'autowrite' option is set,
|
|
105 modified buffers are written. Otherwise, windows that have
|
|
106 buffers that are modified are not removed, unless the [!] is
|
|
107 given, then they become hidden. But modified buffers are
|
|
108 never abandoned, so changes cannot get lost.
|
|
109
|
|
110
|
|
111 SWITCHING TO ANOTHER TAB PAGE:
|
|
112
|
|
113 Using the mouse: If the tab page line is displayed you can click in a tab page
|
682
|
114 label to switch to that tab page. Click where there is no label to go to the
|
|
115 next tab page. |'tabline'|
|
674
|
116
|
682
|
117 :tabn[ext] *:tabn* *:tabnext* *gt*
|
674
|
118 gt Go to the next tab page. Wraps around from the last to the
|
|
119 first one.
|
|
120
|
682
|
121 :tabn[ext] {count}
|
674
|
122 {count}gt Go to tab page {count}. The first tab page has number one.
|
|
123
|
|
124
|
682
|
125 :tabp[revious] *:tabp* *:tabprevious* *gT*
|
|
126 :tabN[ext] *:tabN* *:tabNext*
|
|
127 gT Go to the previous tab page. Wraps around from the first one
|
|
128 to the last one.
|
|
129
|
|
130 :tabp[revious] {count}
|
|
131 :tabN[ext] {count}
|
|
132 {count}gT Go {count} tab pages back. Wraps around from the first one
|
|
133 to the last one.
|
|
134
|
|
135
|
674
|
136 Other commands:
|
|
137 *:tabs*
|
682
|
138 :tabs List the tab pages and the windows they contain.
|
|
139 Shows a ">" for the current window.
|
|
140 Shows a "+" for modified buffers.
|
|
141
|
|
142
|
|
143 REORDERING TAB PAGES:
|
|
144
|
|
145 *:tabm* *:tabmove*
|
|
146 :tabmove N Move the current tab page to after tab page N. Use zero to
|
|
147 make the current tab page the first one. Without N the tab
|
|
148 page is made the last one.
|
674
|
149
|
|
150 ==============================================================================
|
|
151 3. Other items *tab-page-other*
|
|
152
|
|
153 Diff mode works per tab page. You can see the diffs between several files
|
|
154 within one tab page. Other tab pages can show differences between other
|
|
155 files.
|
|
156
|
675
|
157 The TabLeave and TabEnter autocommand events can be used to do something when
|
|
158 switching from one tab page to another. The exact order depends on what you
|
|
159 are doing. When creating a new tab page this works as if you create a new
|
|
160 window on the same buffer and then edit another buffer. Thus ":tabnew"
|
|
161 triggers:
|
|
162 WinLeave leave current window
|
|
163 TabLeave leave current tab page
|
|
164 TabEnter enter new tab page
|
|
165 WinEnter enter window in new tab page
|
|
166 BufLeave leave current buffer
|
|
167 BufEnter enter new empty buffer
|
|
168
|
678
|
169 When switching to another tab page the order is:
|
675
|
170 BufLeave
|
|
171 WinLeave
|
|
172 TabLeave
|
|
173 TabEnter
|
|
174 WinEnter
|
|
175 BufEnter
|
674
|
176
|
678
|
177 ==============================================================================
|
|
178 4. Setting 'tabline' *setting-tabline*
|
|
179
|
|
180 You can use the 'showtabline' option to specify when you want the line with
|
|
181 tab page labels to appear: never, when there is more than one tab page or
|
|
182 always.
|
|
183
|
|
184 The highlighting of the tab pages line is set with the groups TabLine
|
|
185 TabLineSel and TabLineFill. |hl-TabLine| |hl-TabLineSel| |hl-TabLineFill|
|
|
186
|
|
187 The 'tabline' option allows you to define your preferred way to tab pages
|
|
188 labels. This isn't easy, thus an example will be given here.
|
|
189
|
|
190 For basics see the 'statusline' option. The same items can be used in the
|
|
191 'tabline' option. Additionally, the |tabpagebuflist()|, |tabpagenr()| and
|
|
192 |tabpagewinnr()| functions are useful.
|
|
193
|
|
194 Since the number of tab labels will vary, you need to use an expresion for the
|
|
195 whole option. Something like: >
|
|
196 :set tabline=%!MyTabLine()
|
|
197
|
|
198 Then define the MyTabLine() function to list all the tab pages labels. A
|
|
199 convenient method is to split it in two parts: First go over all the tab
|
|
200 pages and define labels for them. Then get the label for each tab page. >
|
|
201
|
|
202 function MyTabLine()
|
|
203 let s = ''
|
|
204 for i in range(tabpagenr('$'))
|
681
|
205 " select the highlighting
|
678
|
206 if i + 1 == tabpagenr()
|
|
207 let s .= '%#TabLineSel#'
|
|
208 else
|
|
209 let s .= '%#TabLine#'
|
|
210 endif
|
681
|
211
|
|
212 " set the tab page number (for mouse clicks)
|
|
213 let s .= '%' . (i + 1) . 'T'
|
|
214
|
|
215 " the label is made by MyTabLabel()
|
678
|
216 let s .= ' %{MyTabLabel(' . (i + 1) . ')} '
|
|
217 endfor
|
681
|
218
|
|
219 " after the last tab fill with TabLineFill and reset tab page nr
|
|
220 let s .= '%#TabLineFill#%T'
|
|
221
|
|
222 " right-align the label to close the current tab page
|
|
223 if tabpagenr('$') > 1
|
|
224 let s .= '%=%#TabLine#%999Xclose'
|
|
225 endif
|
|
226
|
678
|
227 return s
|
|
228 endfunction
|
|
229
|
|
230 Now the MyTabLabel() function is called for each tab page to get its label. >
|
|
231
|
|
232 function MyTabLabel(n)
|
|
233 let buflist = tabpagebuflist(a:n)
|
|
234 let winnr = tabpagewinnr(a:n)
|
|
235 return bufname(buflist[winnr - 1])
|
|
236 endfunction
|
|
237
|
|
238 This is just a simplistic example that results in a tab pages line that
|
|
239 resembles the default, but without adding a + for a modified buffer or
|
|
240 trunctating the names. You will want to reduce the width of labels in a
|
|
241 clever way when there is not enough room. Check the 'columns' option for the
|
681
|
242 space available.
|
674
|
243
|
|
244 vim:tw=78:ts=8:ft=help:norl:
|