685
|
1 *tabpage.txt* For Vim version 7.0aa. Last change: 2006 Feb 24
|
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
|
685
|
135 :tabr[ewind] *:tabfir* *:tabfirst* *:tabr* *:tabrewind*
|
|
136 :tabl[ast] Go to the first tab page.
|
|
137
|
|
138 *:tabl* *:tablast*
|
|
139 :tabl[ast] Go to the last tab page.
|
|
140
|
682
|
141
|
674
|
142 Other commands:
|
|
143 *:tabs*
|
682
|
144 :tabs List the tab pages and the windows they contain.
|
|
145 Shows a ">" for the current window.
|
|
146 Shows a "+" for modified buffers.
|
|
147
|
|
148
|
|
149 REORDERING TAB PAGES:
|
|
150
|
|
151 *:tabm* *:tabmove*
|
|
152 :tabmove N Move the current tab page to after tab page N. Use zero to
|
|
153 make the current tab page the first one. Without N the tab
|
|
154 page is made the last one.
|
674
|
155
|
685
|
156
|
|
157 LOOPING OVER TAB PAGES:
|
|
158
|
|
159 *:tabd* *:tabdo*
|
|
160 :tabd[o] {cmd} Execute {cmd} in each tab page.
|
|
161 It works like doing this: >
|
|
162 :tabfirst
|
|
163 :{cmd}
|
|
164 :tabnext
|
|
165 :{cmd}
|
|
166 etc.
|
|
167 < This only operates in the current window of each tab page.
|
|
168 When an error is detected on one tab page, further tab pages
|
|
169 will not be visited.
|
|
170 The last tab page (or where an error occurred) becomes the
|
|
171 current tab page.
|
|
172 {cmd} can contain '|' to concatenate several commands.
|
|
173 {cmd} must not open or close tab pages or reorder them.
|
|
174 {not in Vi} {not available when compiled without the
|
|
175 |+listcmds| feature}
|
|
176 Also see |:windo|, |:argdo| and |:bufdo|.
|
|
177
|
674
|
178 ==============================================================================
|
|
179 3. Other items *tab-page-other*
|
|
180
|
|
181 Diff mode works per tab page. You can see the diffs between several files
|
|
182 within one tab page. Other tab pages can show differences between other
|
|
183 files.
|
|
184
|
675
|
185 The TabLeave and TabEnter autocommand events can be used to do something when
|
|
186 switching from one tab page to another. The exact order depends on what you
|
|
187 are doing. When creating a new tab page this works as if you create a new
|
|
188 window on the same buffer and then edit another buffer. Thus ":tabnew"
|
|
189 triggers:
|
|
190 WinLeave leave current window
|
|
191 TabLeave leave current tab page
|
|
192 TabEnter enter new tab page
|
|
193 WinEnter enter window in new tab page
|
|
194 BufLeave leave current buffer
|
|
195 BufEnter enter new empty buffer
|
|
196
|
678
|
197 When switching to another tab page the order is:
|
675
|
198 BufLeave
|
|
199 WinLeave
|
|
200 TabLeave
|
|
201 TabEnter
|
|
202 WinEnter
|
|
203 BufEnter
|
674
|
204
|
678
|
205 ==============================================================================
|
|
206 4. Setting 'tabline' *setting-tabline*
|
|
207
|
|
208 You can use the 'showtabline' option to specify when you want the line with
|
|
209 tab page labels to appear: never, when there is more than one tab page or
|
|
210 always.
|
|
211
|
|
212 The highlighting of the tab pages line is set with the groups TabLine
|
|
213 TabLineSel and TabLineFill. |hl-TabLine| |hl-TabLineSel| |hl-TabLineFill|
|
|
214
|
|
215 The 'tabline' option allows you to define your preferred way to tab pages
|
|
216 labels. This isn't easy, thus an example will be given here.
|
|
217
|
|
218 For basics see the 'statusline' option. The same items can be used in the
|
|
219 'tabline' option. Additionally, the |tabpagebuflist()|, |tabpagenr()| and
|
|
220 |tabpagewinnr()| functions are useful.
|
|
221
|
|
222 Since the number of tab labels will vary, you need to use an expresion for the
|
|
223 whole option. Something like: >
|
|
224 :set tabline=%!MyTabLine()
|
|
225
|
|
226 Then define the MyTabLine() function to list all the tab pages labels. A
|
|
227 convenient method is to split it in two parts: First go over all the tab
|
|
228 pages and define labels for them. Then get the label for each tab page. >
|
|
229
|
|
230 function MyTabLine()
|
|
231 let s = ''
|
|
232 for i in range(tabpagenr('$'))
|
681
|
233 " select the highlighting
|
678
|
234 if i + 1 == tabpagenr()
|
|
235 let s .= '%#TabLineSel#'
|
|
236 else
|
|
237 let s .= '%#TabLine#'
|
|
238 endif
|
681
|
239
|
|
240 " set the tab page number (for mouse clicks)
|
|
241 let s .= '%' . (i + 1) . 'T'
|
|
242
|
|
243 " the label is made by MyTabLabel()
|
678
|
244 let s .= ' %{MyTabLabel(' . (i + 1) . ')} '
|
|
245 endfor
|
681
|
246
|
|
247 " after the last tab fill with TabLineFill and reset tab page nr
|
|
248 let s .= '%#TabLineFill#%T'
|
|
249
|
|
250 " right-align the label to close the current tab page
|
|
251 if tabpagenr('$') > 1
|
|
252 let s .= '%=%#TabLine#%999Xclose'
|
|
253 endif
|
|
254
|
678
|
255 return s
|
|
256 endfunction
|
|
257
|
|
258 Now the MyTabLabel() function is called for each tab page to get its label. >
|
|
259
|
|
260 function MyTabLabel(n)
|
|
261 let buflist = tabpagebuflist(a:n)
|
|
262 let winnr = tabpagewinnr(a:n)
|
|
263 return bufname(buflist[winnr - 1])
|
|
264 endfunction
|
|
265
|
|
266 This is just a simplistic example that results in a tab pages line that
|
|
267 resembles the default, but without adding a + for a modified buffer or
|
|
268 trunctating the names. You will want to reduce the width of labels in a
|
|
269 clever way when there is not enough room. Check the 'columns' option for the
|
681
|
270 space available.
|
674
|
271
|
|
272 vim:tw=78:ts=8:ft=help:norl:
|