windows.txt (58541B)
1 *windows.txt* Nvim 2 3 4 VIM REFERENCE MANUAL by Bram Moolenaar 5 6 7 Editing with multiple windows and buffers. *windows* *buffers* 8 9 The commands which have been added to use multiple windows and buffers are 10 explained here. Additionally, there are explanations for commands that work 11 differently when used in combination with more than one window. 12 13 The basics are explained in chapter 7 and 8 of the user manual |usr_07.txt| 14 |usr_08.txt|. 15 16 Type |gO| to see the table of contents. 17 18 ============================================================================== 19 1. Introduction *windows-intro* *window* 20 21 Summary: 22 A buffer is the in-memory text of a file. 23 A window is a viewport on a buffer. 24 A tab page is a collection of windows. 25 26 A window is a viewport onto a buffer. You can use multiple windows on one 27 buffer, or several windows on different buffers. 28 29 A buffer is a file loaded into memory for editing. The original file remains 30 unchanged until you write the buffer to the file. 31 32 A buffer can be in one of three states: 33 34 *active-buffer* 35 active: The buffer is displayed in a window. If there is a file for this 36 buffer, it has been read into the buffer. The buffer may have been 37 modified since then and thus be different from the file. 38 *hidden-buffer* 39 hidden: The buffer is not displayed. If there is a file for this buffer, it 40 has been read into the buffer. Otherwise it's the same as an active 41 buffer, you just can't see it. 42 *inactive-buffer* 43 inactive: The buffer is not displayed and does not contain anything. Options 44 for the buffer are remembered if the file was once loaded. It can 45 contain marks from the |shada| file. But the buffer doesn't 46 contain text. 47 48 In a table: 49 50 state displayed loaded ":buffers" ~ 51 in window shows ~ 52 active yes yes 'a' 53 hidden no yes 'h' 54 inactive no no ' ' 55 56 *buffer-reuse* 57 Each buffer has a unique number and the number will not change within a Vim 58 session. The |bufnr()| and |bufname()| functions can be used to convert 59 between a buffer name and the buffer number. There is one exception: if a new 60 empty buffer is created and it is not modified, the buffer will be re-used 61 when loading another file into that buffer. This also means the buffer number 62 will not change. 63 64 The main Vim window can hold several split windows. There are also tab pages 65 |tab-page|, each of which can hold multiple windows. 66 67 *focusable* 68 If a window is focusable, it is part of the "navigation stack", that is, 69 editor commands such as :windo, |CTRL-W|, etc., will consider the window as 70 one that can be made the "current window". A non-focusable window will be 71 skipped by such commands as it isn't assigned a window number. It can be 72 explicitly focused by |nvim_set_current_win()|, because it is still 73 assigned a |window-ID|. If it is focused, it will also have a window number. 74 Non-focusable windows are not listed by |:tabs|, or counted by the default 75 'tabline'. Their buffer content is not included in 'complete' "w" completion. 76 77 Windows (especially floating windows) can have many other |api-win_config| 78 properties such as "hide" and "fixed" which also affect behavior. 79 80 *window-ID* *winid* *windowid* 81 Each window has a unique identifier called the window ID. This identifier 82 will not change within a Vim session. The |win_getid()| and |win_id2tabwin()| 83 functions can be used to convert between the window/tab number and the 84 identifier. There is also the window number, which may change whenever 85 windows are opened or closed, see |winnr()|. 86 The window number is only valid in one specific tab. The window ID is valid 87 across tabs. For most functions that take a window ID or a window number, the 88 window number only applies to the current tab, while the window ID can refer 89 to a window in any tab. 90 91 92 ============================================================================== 93 2. Starting Vim *windows-starting* 94 95 By default, Vim starts with one window, just like Vi. 96 97 The "-o" and "-O" arguments to Vim can be used to open a window for each file 98 in the argument list. The "-o" argument will split the windows horizontally; 99 the "-O" argument will split the windows vertically. If both "-o" and "-O" 100 are given, the last one encountered will be used to determine the split 101 orientation. For example, this will open three windows, split horizontally: > 102 vim -o file1 file2 file3 103 104 "-oN", where N is a decimal number, opens N windows split horizontally. If 105 there are more file names than windows, only N windows are opened and some 106 files do not get a window. If there are more windows than file names, the 107 last few windows will be editing empty buffers. Similarly, "-ON" opens N 108 windows split vertically, with the same restrictions. 109 110 If there are many file names, the windows will become very small. You might 111 want to set the 'winheight' and/or 'winwidth' options to create a workable 112 situation. 113 114 Buf/Win Enter/Leave |autocommand|s are not executed when opening the new 115 windows and reading the files, that's only done when they are really entered. 116 117 *status-line* 118 A status line will be used to separate windows. The 'laststatus' option tells 119 when the last window also has a status line: 120 'laststatus' = 0 never a status line 121 'laststatus' = 1 status line if there is more than one window 122 'laststatus' = 2 always a status line 123 'laststatus' = 3 have a global statusline at the bottom instead 124 of one for each window 125 126 You can change the contents of the status line with the 'statusline' option. 127 This option can be local to the window, so that you can have a different 128 status line in each window. 129 130 Normally, inversion is used to display the status line. This can be changed 131 with the |hl-StatusLine| highlight group. If no highlighting is used for the 132 status line, the '^' character is used for the current window, and '=' for 133 other windows. If 'mouse' is enabled, a status line can be dragged to resize 134 windows. 135 136 *filler-lines* 137 The lines after the last buffer line in a window are called filler lines. By 138 default, these lines start with a tilde (~) character. The "eob" item in the 139 'fillchars' option can be used to change this character. By default, these 140 characters are highlighted as NonText (|hl-NonText|). The EndOfBuffer 141 highlight group (|hl-EndOfBuffer|) can be used to change the highlighting of 142 the filler characters. 143 144 ============================================================================== 145 3. Opening and closing a window *opening-window* 146 147 CTRL-W s *CTRL-W_s* 148 CTRL-W S *CTRL-W_S* 149 CTRL-W CTRL-S *CTRL-W_CTRL-S* 150 :[N]sp[lit] [++opt] [+cmd] *:sp* *:split* 151 Split current window in two. The result is two viewports on 152 the same file. 153 154 Make the new window N high (default is to use half the height 155 of the current window). Reduces the current window height to 156 create room (and others, if the 'equalalways' option is set, 157 'eadirection' isn't "hor", and one of them is higher than the 158 current or the new window). 159 160 Note: CTRL-S does not work on all terminals and might block 161 further input, use CTRL-Q to get going again. 162 Also see |++opt| and |+cmd|. 163 *E242* *E1159* 164 Be careful when splitting a window in an autocommand, it may 165 mess up the window layout if this happens while making other 166 window layout changes. 167 168 :[N]sp[lit] [++opt] [+cmd] {file} *:split_f* 169 Like |:split| but create a new window and start editing file 170 {file} in it. 171 This behaves almost like a ":split" first, and then an ":edit" 172 command, but the alternate file name in the original window is 173 set to {file}. 174 If [+cmd] is given, execute the command when the file has been 175 loaded |+cmd|. 176 Also see |++opt|. 177 Make new window N high (default is to use half the existing 178 height). Reduces the current window height to create room 179 (and others, if the 'equalalways' option is set). 180 181 CTRL-W CTRL-V *CTRL-W_CTRL-V* 182 CTRL-W v *CTRL-W_v* 183 :[N]vs[plit] [++opt] [+cmd] [file] *:vs* *:vsplit* 184 Like |:split|, but split vertically. The windows will be 185 spread out horizontally if 186 1. a width was not specified, 187 2. 'equalalways' is set, 188 3. 'eadirection' isn't "ver", and 189 4. one of the other windows is wider than the current or new 190 window. 191 If N was given make the new window N columns wide, if 192 possible. 193 Note: In other places CTRL-Q does the same as CTRL-V, but here 194 it doesn't! 195 196 CTRL-W n *CTRL-W_n* 197 CTRL-W CTRL-N *CTRL-W_CTRL-N* 198 :[N]new [++opt] [+cmd] *:new* 199 Create a new window and start editing an empty file in it. 200 Make new window N high (default is to use half the existing 201 height). Reduces the current window height to create room 202 (and others, if the 'equalalways' option is set and 203 'eadirection' isn't "hor"). 204 Also see |++opt| and |+cmd|. 205 If 'fileformats' is not empty, the first format given will be 206 used for the new buffer. If 'fileformats' is empty, the 207 'fileformat' of the current buffer is used. This can be 208 overridden with the |++opt| argument. 209 Autocommands are executed in this order: 210 1. WinLeave for the current window 211 2. WinEnter for the new window 212 3. BufLeave for the current buffer 213 4. BufEnter for the new buffer 214 This behaves like a ":split" first, and then an ":enew" 215 command. 216 217 :[N]new [++opt] [+cmd] {file} 218 Like |:split_f|, create a new window and start editing {file}. 219 220 :[N]vne[w] [++opt] [+cmd] [file] *:vne* *:vnew* 221 Like |:new|, but split vertically. If 'equalalways' is set 222 and 'eadirection' isn't "ver" the windows will be spread out 223 horizontally, unless a width was specified. 224 225 :[N]sv[iew] [++opt] [+cmd] [file] *:sv* *:sview* *splitview* 226 Same as ":split", but set 'readonly' option for this buffer. 227 228 :[N]sf[ind] [++opt] [+cmd] {file} *:sf* *:sfi* *:sfind* *splitfind* 229 Same as ":split", but search for {file} in 'path' like in 230 |:find|. Doesn't split if {file} is not found. 231 232 CTRL-W CTRL-^ *CTRL-W_CTRL-^* *CTRL-W_^* 233 CTRL-W ^ Split the current window in two and edit the alternate file. 234 When a count N is given, split the current window and edit 235 buffer N. Similar to ":sp #" and ":sp #N", but it allows the 236 other buffer to be unnamed. This command matches the behavior 237 of |CTRL-^|, except that it splits a window first. 238 239 CTRL-W ge *CTRL-W_ge* 240 Detach the current window as an external window. 241 Only available when using a UI with |ui-multigrid| support. 242 243 Note that the 'splitbelow' and 'splitright' options influence where a new 244 window will appear. 245 *E36* 246 Creating a window will fail if there is not enough room. Every window needs 247 at least one screen line and column, sometimes more. Options 'winminheight' 248 and 'winminwidth' are relevant. 249 250 *:vert* *:vertical* 251 :vert[ical] {cmd} 252 Execute {cmd}. If it contains a command that splits a window, 253 it will be split vertically. For `vertical wincmd =` windows 254 will be equalized only vertically. 255 Doesn't work for |:execute| and |:normal|. 256 257 *:hor* *:horizontal* 258 :hor[izontal] {cmd} 259 Execute {cmd} in a horizontal split window. Supports these 260 commands: 261 - `:wincmd =`: equalize windows only horizontally. 262 - |:terminal|: open a |terminal| buffer in a split window. 263 - |:checkhealth|: open a healthcheck buffer in a split window. 264 265 :lefta[bove] {cmd} *:lefta* *:leftabove* 266 :abo[veleft] {cmd} *:abo* *:aboveleft* 267 Execute {cmd}. If it contains a command that splits a window, 268 it will be opened left (vertical split) or above (horizontal 269 split) the current window. Overrules 'splitbelow' and 270 'splitright'. 271 Doesn't work for |:execute| and |:normal|. 272 273 :rightb[elow] {cmd} *:rightb* *:rightbelow* 274 :bel[owright] {cmd} *:bel* *:belowright* 275 Execute {cmd}. If it contains a command that splits a window, 276 it will be opened right (vertical split) or below (horizontal 277 split) the current window. Overrules 'splitbelow' and 278 'splitright'. 279 Doesn't work for |:execute| and |:normal|. 280 281 *:topleft* *E442* 282 :to[pleft] {cmd} 283 Execute {cmd}. If it contains a command that splits a window, 284 it will appear at the top and occupy the full width of the Vim 285 window. When the split is vertical the window appears at the 286 far left and occupies the full height of the Vim window. 287 Doesn't work for |:execute| and |:normal|. 288 289 *:bo* *:botright* 290 :bo[tright] {cmd} 291 Execute {cmd}. If it contains a command that splits a window, 292 it will appear at the bottom and occupy the full width of the 293 Vim window. When the split is vertical the window appears at 294 the far right and occupies the full height of the Vim window. 295 Doesn't work for |:execute| and |:normal|. 296 297 These command modifiers can be combined to make a vertically split window 298 occupy the full height. Example: > 299 :vertical topleft split tags 300 Opens a vertically split, full-height window on the "tags" file at the far 301 left of the Vim window. 302 303 304 ------------------------------------------------------------------------------ 305 Closing a window 306 307 :q[uit] 308 :{count}q[uit] *:count_quit* 309 CTRL-W q *CTRL-W_q* 310 CTRL-W CTRL-Q *CTRL-W_CTRL-Q* 311 Without {count}: Quit the current window. If {count} is 312 given quit the {count} window. 313 *edit-window* 314 When quitting the last edit window (not counting help or 315 preview windows), exit Vim. 316 317 When 'hidden' is set, and there is only one window for the 318 current buffer, it becomes hidden. When 'hidden' is not set, 319 and there is only one window for the current buffer, and the 320 buffer was changed, the command fails. 321 (Note: CTRL-Q does not work on all terminals). 322 If [count] is greater than the last window number the last 323 window will be closed: > 324 :1quit " quit the first window 325 :$quit " quit the last window 326 :9quit " quit the last window 327 " if there are fewer than 9 windows opened 328 :-quit " quit the previous window 329 :+quit " quit the next window 330 :+2quit " quit the second next window 331 < 332 When closing a help window, and this is not the only window, 333 Vim will try to restore the previous window layout, see 334 |:helpclose|. 335 336 :q[uit]! 337 :{count}q[uit]! 338 Without {count}: Quit the current window. If {count} is 339 given quit the {count} window 340 If this was the last window for a buffer, any changes to that 341 buffer are lost. When quitting the last window (not counting 342 help windows), exit Vim. The contents of the buffer are lost, 343 even when 'hidden' is set. 344 345 :clo[se][!] 346 :{count}clo[se][!] 347 CTRL-W c *CTRL-W_c* *:clo* *:close* 348 Without {count}: Close the current window. If given close the 349 {count} window. 350 351 When 'hidden' is set, or when the buffer was changed and the 352 [!] is used, the buffer becomes hidden (unless there is another 353 window editing it). 354 355 When there is only one |edit-window| in the current tab page 356 and there is another tab page, this closes the current tab 357 page. |tab-page|. 358 359 This command fails when: *E444* 360 - There is only one window on the screen. 361 - When 'hidden' is not set, [!] is not used, the buffer has 362 changes, and there is no other window on this buffer. 363 Changes to the buffer are not written and won't get lost, so 364 this is a "safe" command. 365 366 CTRL-W CTRL-C *CTRL-W_CTRL-C* 367 You might have expected that CTRL-W CTRL-C closes the current 368 window, but that does not work, because the CTRL-C cancels the 369 command. 370 371 *:hide* 372 :hid[e] 373 :{count}hid[e] 374 Without {count}: Quit the current window, unless it is the 375 last window on the screen. 376 If {count} is given quit the {count} window. 377 378 The buffer becomes hidden (unless there is another window 379 editing it or 'bufhidden' is `unload`, `delete` or `wipe`). 380 If the window is the last one in the current tab page the tab 381 page is closed. |tab-page| 382 383 The value of 'hidden' is irrelevant for this command. 384 Changes to the buffer are not written and won't get lost, so 385 this is a "safe" command. 386 387 :hid[e] {cmd} Execute {cmd} with 'hidden' set. The previous value of 388 'hidden' is restored after {cmd} has been executed. 389 Example: > 390 :hide edit Makefile 391 < This will edit "Makefile", and hide the current buffer if it 392 has any changes. 393 394 :on[ly][!] 395 :{count}on[ly][!] 396 CTRL-W o *CTRL-W_o* *E445* 397 CTRL-W CTRL-O *CTRL-W_CTRL-O* *:on* *:only* 398 Make the current window the only one on the screen. All other 399 windows are closed. For {count} see the `:quit` command 400 above |:count_quit|. 401 402 When the 'hidden' option is set, all buffers in closed windows 403 become hidden. 404 405 When 'hidden' is not set, and the 'autowrite' option is set, 406 modified buffers are written. Otherwise, windows that have 407 buffers that are modified are not removed, unless the [!] is 408 given, then they become hidden. But modified buffers are 409 never abandoned, so changes cannot get lost. 410 411 *:fc* *:fclose* 412 :[count]fc[lose][!] 413 Close [count] floating windows with the highest zindex values. 414 '!' to close all floating windows. 415 416 ============================================================================== 417 4. Moving cursor to other windows *window-move-cursor* 418 419 CTRL-W <Down> *CTRL-W_<Down>* 420 CTRL-W CTRL-J *CTRL-W_CTRL-J* *CTRL-W_j* 421 CTRL-W j Move cursor to Nth window below current one. Uses the cursor 422 position to select between alternatives. 423 424 CTRL-W <Up> *CTRL-W_<Up>* 425 CTRL-W CTRL-K *CTRL-W_CTRL-K* *CTRL-W_k* 426 CTRL-W k Move cursor to Nth window above current one. Uses the cursor 427 position to select between alternatives. 428 429 CTRL-W <Left> *CTRL-W_<Left>* 430 CTRL-W CTRL-H *CTRL-W_CTRL-H* 431 CTRL-W <BS> *CTRL-W_<BS>* *CTRL-W_h* 432 CTRL-W h Move cursor to Nth window left of current one. Uses the 433 cursor position to select between alternatives. 434 435 CTRL-W <Right> *CTRL-W_<Right>* 436 CTRL-W CTRL-L *CTRL-W_CTRL-L* *CTRL-W_l* 437 CTRL-W l Move cursor to Nth window right of current one. Uses the 438 cursor position to select between alternatives. 439 440 CTRL-W w *CTRL-W_w* *CTRL-W_CTRL-W* 441 CTRL-W CTRL-W Without count: move cursor to the |focusable| window 442 below/right of the current one. If none, go to the top-left 443 window. With count: go to Nth window (numbered top-left to 444 bottom-right), skipping unfocusable windows. To obtain the 445 window number see |bufwinnr()| and |winnr()|. When N is 446 larger than the number of windows go to the last focusable 447 window. 448 449 *CTRL-W_W* 450 CTRL-W W Without count: move cursor to the |focusable| window 451 above/left of current one. If none, go to the bottom-right 452 window. With count: go to Nth window, like CTRL-W w. 453 454 CTRL-W t *CTRL-W_t* *CTRL-W_CTRL-T* 455 CTRL-W CTRL-T Move cursor to top-left window. 456 457 CTRL-W b *CTRL-W_b* *CTRL-W_CTRL-B* 458 CTRL-W CTRL-B Move cursor to bottom-right window. 459 460 CTRL-W p *CTRL-W_p* *CTRL-W_CTRL-P* 461 CTRL-W CTRL-P Go to previous (last accessed) window. 462 463 *CTRL-W_P* *E441* 464 CTRL-W P Go to preview window. When there is no preview window this is 465 an error. 466 467 If Visual mode is active and the new window is not for the same buffer, the 468 Visual mode is ended. If the window is on the same buffer, the cursor 469 position is set to keep the same Visual area selected. 470 471 *:winc* *:wincmd* 472 These commands can also be executed with ":wincmd": 473 474 :[count]winc[md] {arg} 475 :winc[md] [count] {arg} 476 Like executing CTRL-W [count] {arg}. Example: > 477 :wincmd j 478 < Moves to the window below the current one. 479 This command is useful when a Normal mode cannot be used (for 480 the |CursorHold| autocommand event). Or when a Normal mode 481 command is inconvenient. 482 The count can also be a window number. Example: > 483 :exe nr .. "wincmd w" 484 < This goes to window "nr". 485 486 Note: All CTRL-W commands can also be executed with |:wincmd|, for those 487 places where a Normal mode command can't be used or is inconvenient (e.g. 488 in a browser-based terminal). 489 490 ============================================================================== 491 5. Moving windows around *window-moving* 492 493 CTRL-W r *CTRL-W_r* *CTRL-W_CTRL-R* *E443* 494 CTRL-W CTRL-R Rotate windows downwards/rightwards. The first window becomes 495 the second one, the second one becomes the third one, etc. 496 The last window becomes the first window. The cursor remains 497 in the same window. 498 This only works within the row or column of windows that the 499 current window is in. 500 501 *CTRL-W_R* 502 CTRL-W R Rotate windows upwards/leftwards. The second window becomes 503 the first one, the third one becomes the second one, etc. The 504 first window becomes the last window. The cursor remains in 505 the same window. 506 This only works within the row or column of windows that the 507 current window is in. 508 509 CTRL-W x *CTRL-W_x* *CTRL-W_CTRL-X* 510 CTRL-W CTRL-X Without count: Exchange current window with next one. If 511 there is no next window, exchange with previous window. 512 With count: Exchange current window with Nth window (first 513 window is 1). The cursor is put in the other window. 514 When vertical and horizontal window splits are mixed, the 515 exchange is only done in the row or column of windows that the 516 current window is in. 517 518 The following commands can be used to change the window layout. For example, 519 when there are two vertically split windows, CTRL-W K will change that in 520 horizontally split windows. CTRL-W H does it the other way around. 521 522 *CTRL-W_K* 523 CTRL-W K Move the current window to be at the very top, using the full 524 width of the screen. This works like `:topleft split`, except 525 it is applied to the current window and no new window is 526 created. 527 528 *CTRL-W_J* 529 CTRL-W J Move the current window to be at the very bottom, using the 530 full width of the screen. This works like `:botright split`, 531 except it is applied to the current window and no new window 532 is created. 533 534 *CTRL-W_H* 535 CTRL-W H Move the current window to be at the far left, using the 536 full height of the screen. This works like 537 `:vert topleft split`, except it is applied to the current 538 window and no new window is created. 539 540 *CTRL-W_L* 541 CTRL-W L Move the current window to be at the far right, using the full 542 height of the screen. This works like `:vert botright split`, 543 except it is applied to the current window and no new window 544 is created. 545 546 *CTRL-W_T* 547 CTRL-W T Move the current window to a new tab page. This fails if 548 there is only one window in the current tab page. 549 This works like `:tab split`, except the previous window is 550 closed. 551 When a count is specified the new tab page will be opened 552 before the tab page with this index. Otherwise it comes after 553 the current tab page. 554 555 ============================================================================== 556 6. Window resizing *window-resize* 557 558 *CTRL-W_=* 559 CTRL-W = Make all windows (almost) equally high and wide, but use 560 'winheight' and 'winwidth' for the current window. 561 Windows with 'winfixheight' set keep their height and windows 562 with 'winfixwidth' set keep their width. 563 To equalize only vertically (make window equally high) use 564 `vertical wincmd =` . 565 To equalize only horizontally (make window equally wide) use 566 `horizontal wincmd =` . 567 568 :res[ize] -N *:res* *:resize* *CTRL-W_-* 569 CTRL-W - Decrease current window height by N (default 1). 570 If used after |:vertical|: decrease width by N. 571 572 :res[ize] +N *CTRL-W_+* 573 CTRL-W + Increase current window height by N (default 1). 574 If used after |:vertical|: increase width by N. 575 576 :res[ize] [N] 577 CTRL-W CTRL-_ *CTRL-W_CTRL-_* *CTRL-W__* 578 CTRL-W _ Set current window height to N (default: highest possible). 579 580 :{winnr}res[ize] [+-]N 581 Like `:resize` above, but apply the size to window {winnr} 582 instead of the current window. 583 584 z{nr}<CR> Set current window height to {nr}. 585 586 *CTRL-W_<* 587 CTRL-W < Decrease current window width by N (default 1). 588 589 *CTRL-W_>* 590 CTRL-W > Increase current window width by N (default 1). 591 592 :vert[ical] res[ize] [N] *:vertical-resize* *CTRL-W_bar* 593 CTRL-W | Set current window width to N (default: widest possible). 594 595 You can also resize a window by dragging a status line up or down with the 596 mouse. Or by dragging a vertical separator line left or right. This only 597 works if the version of Vim that is being used supports the mouse and the 598 'mouse' option has been set to enable it. 599 600 The option 'winheight' ('wh') is used to set the minimal window height of the 601 current window. This option is used each time another window becomes the 602 current window. If the option is '0', it is disabled. Set 'winheight' to a 603 very large value, e.g., '9999', to make the current window always fill all 604 available space. Set it to a reasonable value, e.g., '10', to make editing in 605 the current window comfortable. 606 607 The equivalent 'winwidth' ('wiw') option is used to set the minimal width of 608 the current window. 609 610 When the option 'equalalways' ('ea') is set, all the windows are automatically 611 made the same size after splitting or closing a window. If you don't set this 612 option, splitting a window will reduce the size of the current window and 613 leave the other windows the same. When closing a window, the extra lines are 614 given to the window above it. 615 616 The 'eadirection' option limits the direction in which the 'equalalways' 617 option is applied. The default "both" resizes in both directions. When the 618 value is "ver" only the heights of windows are equalized. Use this when you 619 have manually resized a vertically split window and want to keep this width. 620 Likewise, "hor" causes only the widths of windows to be equalized. 621 622 The option 'cmdheight' ('ch') is used to set the height of the command-line. 623 If you are annoyed by the |hit-enter| prompt for long messages, set this 624 option to 2 or 3. 625 626 If there is only one window, resizing that window will also change the command 627 line height. If there are several windows, resizing the current window will 628 also change the height of the window below it (and sometimes the window above 629 it). 630 631 The minimal height and width of a window is set with 'winminheight' and 632 'winminwidth'. These are hard values, a window will never become smaller. 633 634 635 WinScrolled and WinResized autocommands ~ 636 *win-scrolled-resized* 637 If you want to get notified of changes in window sizes, the |WinResized| 638 autocommand event can be used. 639 If you want to get notified of text in windows scrolling vertically or 640 horizontally, the |WinScrolled| autocommand event can be used. This will also 641 trigger in window size changes. 642 Exception: the events will not be triggered when the text scrolls for 643 'incsearch'. 644 *WinResized-event* 645 The |WinResized| event is triggered after updating the display, several 646 windows may have changed size then. A list of the IDs of windows that changed 647 since last time is provided in the v:event.windows variable, for example: 648 [1003, 1006] 649 *WinScrolled-event* 650 The |WinScrolled| event is triggered after |WinResized|, and also if a window 651 was scrolled. That can be vertically (the text at the top of the window 652 changed) or horizontally (when 'wrap' is off or when the first displayed part 653 of the first line changes). Note that |WinScrolled| will trigger many more 654 times than |WinResized|, it may slow down editing a bit. 655 656 The information provided by |WinScrolled| is a dictionary for each window that 657 has changes, using the window ID as the key, and a total count of the changes 658 with the key "all". Example value for |v:event|: > 659 { 660 all: {width: 0, height: 2, leftcol: 0, skipcol: 0, topline: 1, topfill: 0}, 661 1003: {width: 0, height: -1, leftcol: 0, skipcol: 0, topline: 0, topfill: 0}, 662 1006: {width: 0, height: 1, leftcol: 0, skipcol: 0, topline: 1, topfill: 0}, 663 } 664 665 Note that the "all" entry has the absolute values of the individual windows 666 accumulated. 667 668 If you need more information about what changed, or you want to "debounce" the 669 events (not handle every event to avoid doing too much work), you may want to 670 use the `winlayout()` and `getwininfo()` functions. 671 672 |WinScrolled| and |WinResized| do not trigger when the first autocommand is 673 added, only after the first scroll or resize. They may trigger when switching 674 to another tab page. 675 676 The commands executed are expected to not cause window size or scroll changes. 677 If this happens anyway, the event will trigger again very soon. In other 678 words: Just before triggering the event, the current sizes and scroll 679 positions are stored and used to decide whether there was a change. 680 681 ============================================================================== 682 7. Argument and buffer list commands *buffer-list* 683 684 args list buffer list meaning ~ 685 > 686 1. :[N]argument [N] 11. :[N]buffer [N] to arg/buf N 687 2. :[N]next [file ..] 12. :[N]bnext [N] to Nth next arg/buf 688 3. :[N]Next [N] 13. :[N]bNext [N] to Nth previous arg/buf 689 4. :[N]previous [N] 14. :[N]bprevious [N] to Nth previous arg/buf 690 5. :rewind / :first 15. :brewind / :bfirst to first arg/buf 691 6. :last 16. :blast to last arg/buf 692 7. :all 17. :ball edit all args/buffers 693 18. :unhide edit all loaded buffers 694 19. :[N]bmod [N] to Nth modified buf 695 < 696 split & args list split & buffer list meaning ~ 697 > 698 21. :[N]sargument [N] 31. :[N]sbuffer [N] split + to arg/buf N 699 22. :[N]snext [file ..] 32. :[N]sbnext [N] split + to Nth next arg/buf 700 23. :[N]sNext [N] 33. :[N]sbNext [N] split + to Nth previous arg/buf 701 24. :[N]sprevious [N] 34. :[N]sbprevious [N] split + to Nth previous arg/buf 702 25. :srewind / :sfirst 35. :sbrewind / :sbfirst split + to first arg/buf 703 26. :slast 36. :sblast split + to last arg/buf 704 27. :sall 37. :sball edit all args/buffers 705 38. :sunhide edit all loaded buffers 706 39. :[N]sbmod [N] split + to Nth modified buf 707 708 40. :args list of arguments 709 41. :buffers list of buffers 710 < 711 The meaning of [N] depends on the command: 712 [N] is the number of buffers to go forward/backward on 2/12/22/32, 713 3/13/23/33, and 4/14/24/34 714 [N] is an argument number, defaulting to current argument, for 1 and 21 715 [N] is a buffer number, defaulting to current buffer, for 11 and 31 716 [N] is a count for 19 and 39 717 718 Note: ":next" is an exception, because it must accept a list of file names 719 for compatibility with Vi. 720 721 722 ------------------------------------------------------------------------------ 723 The argument list and multiple windows 724 725 The current position in the argument list can be different for each window. 726 Remember that when doing ":e file", the position in the argument list stays 727 the same, but you are not editing the file at that position. To indicate 728 this, the file message (and the title, if you have one) shows 729 "(file (N) of M)", where "(N)" is the current position in the file list, and 730 "M" the number of files in the file list. 731 732 All the entries in the argument list are added to the buffer list. Thus, you 733 can also get to them with the buffer list commands, like ":bnext". 734 735 :[N]al[l][!] [N] *:al* *:all* *:sal* *:sall* 736 :[N]sal[l][!] [N] 737 Rearrange the screen to open one window for each argument. 738 All other windows are closed. When a count is given, this is 739 the maximum number of windows to open. 740 With the |:tab| modifier open a tab page for each argument. 741 When there are more arguments than 'tabpagemax' further ones 742 become split windows in the last tab page. 743 When the 'hidden' option is set, all buffers in closed windows 744 become hidden. 745 When 'hidden' is not set, and the 'autowrite' option is set, 746 modified buffers are written. Otherwise, windows that have 747 buffers that are modified are not removed, unless the [!] is 748 given, then they become hidden. But modified buffers are 749 never abandoned, so changes cannot get lost. 750 [N] is the maximum number of windows to open. 'winheight' 751 also limits the number of windows opened ('winwidth' if 752 |:vertical| was prepended). 753 Buf/Win Enter/Leave autocommands are not executed for the new 754 windows here, that's only done when they are really entered. 755 If autocommands change the window layout while this command is 756 busy an error will be given. *E249* 757 758 :[N]sa[rgument][!] [++opt] [+cmd] [N] *:sa* *:sargument* 759 Short for ":split | argument [N]": split window and go to Nth 760 argument. But when there is no such argument, the window is 761 not split. Also see |++opt| and |+cmd|. 762 763 :[N]sn[ext][!] [++opt] [+cmd] [file ..] *:sn* *:snext* 764 Short for ":split | [N]next": split window and go to Nth next 765 argument. But when there is no next file, the window is not 766 split. Also see |++opt| and |+cmd|. 767 768 :[N]spr[evious][!] [++opt] [+cmd] [N] *:spr* *:sprevious* 769 :[N]sN[ext][!] [++opt] [+cmd] [N] *:sN* *:sNext* 770 Short for ":split | [N]Next": split window and go to Nth 771 previous argument. But when there is no previous file, the 772 window is not split. Also see |++opt| and |+cmd|. 773 774 *:sre* *:srewind* 775 :sre[wind][!] [++opt] [+cmd] 776 Short for ":split | rewind": split window and go to first 777 argument. But when there is no argument list, the window is 778 not split. Also see |++opt| and |+cmd|. 779 780 *:sfir* *:sfirst* 781 :sfir[st] [++opt] [+cmd] 782 Same as ":srewind". 783 784 *:sla* *:slast* 785 :sla[st][!] [++opt] [+cmd] 786 Short for ":split | last": split window and go to last 787 argument. But when there is no argument list, the window is 788 not split. Also see |++opt| and |+cmd|. 789 790 *:dr* *:drop* 791 :dr[op] [++opt] [+cmd] {file} .. 792 Edit the first {file} in a window. 793 - If the file is already open in a window change to that 794 window. 795 - If the file is not open in a window edit the file in the 796 current window. If the current buffer can't be |abandon|ed, 797 the window is split first. 798 - Windows that are not in the argument list or are not full 799 width will be closed if possible. 800 The |argument-list| is set, like with the |:next| command. 801 The purpose of this command is that it can be used from a 802 program that wants Vim to edit another file, e.g., a debugger. 803 When using the |:tab| modifier each argument is opened in a 804 tab page. The last window is used if it's empty. 805 Also see |++opt| and |+cmd|. 806 807 ============================================================================== 808 8. Do a command in all buffers or windows *list-repeat* 809 810 *:windo* 811 :[range]windo {cmd} Execute {cmd} in each |focusable| window, or only for 812 windows in a given [range] of window numbers. It works 813 like doing this: > 814 CTRL-W t 815 :{cmd} 816 CTRL-W w 817 :{cmd} 818 etc. 819 < This only operates in the current tab page. 820 When an error is detected on one window, further 821 windows will not be visited. 822 The last window (or where an error occurred) becomes 823 the current window. 824 {cmd} can contain '|' to concatenate several commands. 825 {cmd} must not open or close windows or reorder them. 826 827 Also see |:tabdo|, |:argdo|, |:bufdo|, |:cdo|, |:ldo|, 828 |:cfdo| and |:lfdo|. 829 830 *:bufdo* 831 :[range]bufdo[!] {cmd} Execute {cmd} in each buffer in the buffer list or if 832 [range] is given only for buffers for which their 833 buffer number is in the [range]. It works like doing 834 this: > 835 :bfirst 836 :{cmd} 837 :bnext 838 :{cmd} 839 etc. 840 < When the current file can't be |abandon|ed and the [!] 841 is not present, the command fails. 842 When an error is detected on one buffer, further 843 buffers will not be visited. 844 Unlisted buffers are skipped. 845 The last buffer (or where an error occurred) becomes 846 the current buffer. 847 {cmd} can contain '|' to concatenate several commands. 848 {cmd} must not delete buffers or add buffers to the 849 buffer list. 850 Note: While this command is executing, the Syntax 851 autocommand event is disabled by adding it to 852 'eventignore'. This considerably speeds up editing 853 each buffer. 854 855 Also see |:tabdo|, |:argdo|, |:windo|, |:cdo|, |:ldo|, 856 |:cfdo| and |:lfdo|. 857 858 Examples: > 859 860 :windo set nolist foldcolumn=0 | normal! zn 861 862 This resets the 'list' option and disables folding in all windows. > 863 864 :bufdo set fileencoding= | update 865 866 This resets the 'fileencoding' in each buffer and writes it if this changed 867 the buffer. The result is that all buffers will use the 'encoding' encoding 868 (if conversion succeeds). 869 870 ============================================================================== 871 9. Tag or file name under the cursor *window-tag* 872 873 *:sta* *:stag* 874 :sta[g][!] [tagname] 875 Does ":tag[!] [tagname]" and splits the window for the found 876 tag. Refer to 'switchbuf' to jump to a tag in a vertically 877 split window or a new tab page. See also |:tag|. 878 879 CTRL-W ] *CTRL-W_]* *CTRL-W_CTRL-]* 880 CTRL-W CTRL-] Split current window in two. Use identifier under cursor as a 881 tag and jump to it in the new upper window. 882 In Visual mode uses the Visually selected text as a tag. 883 Make new window N high. Refer to 'switchbuf' to jump to a tag 884 in a vertically split window or a new tab page. 885 886 *CTRL-W_g]* 887 CTRL-W g ] Split current window in two. Use identifier under cursor as a 888 tag and perform ":tselect" on it in the new upper window. 889 In Visual mode uses the Visually selected text as a tag. 890 Make new window N high. 891 892 *CTRL-W_g_CTRL-]* 893 CTRL-W g CTRL-] Split current window in two. Use identifier under cursor as a 894 tag and perform ":tjump" on it in the new upper window. 895 In Visual mode uses the Visually selected text as a tag. 896 Make new window N high. 897 898 CTRL-W f *CTRL-W_f* *CTRL-W_CTRL-F* 899 CTRL-W CTRL-F Split current window in two. Edit file name under cursor. 900 Like ":split gf", but window isn't split if the file does not 901 exist. 902 Uses the 'path' variable as a list of directory names where to 903 look for the file. Also the path for current file is 904 used to search for the file name. 905 If the name is a hypertext link that looks like 906 "type://machine/path", only "/path" is used. 907 If a count is given, the count'th matching file is edited. 908 909 CTRL-W F *CTRL-W_F* 910 Split current window in two. Edit file name under cursor and 911 jump to the line number following the file name. See |gF| for 912 details on how the line number is obtained. 913 914 CTRL-W gf *CTRL-W_gf* 915 Open a new tab page and edit the file name under the cursor. 916 Like "tab split" and "gf", but the new tab page isn't created 917 if the file does not exist. 918 919 CTRL-W gF *CTRL-W_gF* 920 Open a new tab page and edit the file name under the cursor 921 and jump to the line number following the file name. Like 922 "tab split" and "gF", but the new tab page isn't created if 923 the file does not exist. 924 925 CTRL-W gt *CTRL-W_gt* 926 Go to next tab page, same as `gt`. 927 928 CTRL-W gT *CTRL-W_gT* 929 Go to previous tab page, same as `gT`. 930 931 Also see |CTRL-W_CTRL-I|: open window for an included file that includes 932 the keyword under the cursor. 933 934 ============================================================================== 935 10. The preview window *preview-window* 936 937 The preview window is a special window to show (preview) another file. It is 938 normally a small window used to show an include file or definition of a 939 function. 940 941 There can be only one preview window (per tab page). It is created with one 942 of the commands below. The 'previewheight' option can be set to specify the 943 height of the preview window when it's opened. The 'previewwindow' option is 944 set in the preview window to be able to recognize it. The 'winfixheight' 945 option is set to have it keep the same height when opening/closing other 946 windows. 947 948 *:pt* *:ptag* 949 :pt[ag][!] [tagname] 950 Does ":tag[!] [tagname]" and shows the found tag in a 951 "Preview" window without changing the current buffer or cursor 952 position. If a "Preview" window already exists, it is re-used 953 (like a help window is). If a new one is opened, 954 'previewheight' is used for the height of the window. See 955 also |:tag|. 956 See below for an example. |CursorHold-example| 957 Small difference from |:tag|: When [tagname] is equal to the 958 already displayed tag, the position in the matching tag list 959 is not reset. This makes the CursorHold example work after a 960 |:ptnext|. 961 962 CTRL-W z *CTRL-W_z* 963 CTRL-W CTRL-Z *CTRL-W_CTRL-Z* *:pc* *:pclose* 964 :pc[lose][!] Close any "Preview" window currently open. When the 'hidden' 965 option is set, or when the buffer was changed and the [!] is 966 used, the buffer becomes hidden (unless there is another 967 window editing it). The command fails if any "Preview" buffer 968 cannot be closed. See also |:close|. 969 970 *:pp* *:ppop* 971 :[count]pp[op][!] 972 Does ":[count]pop[!]" in the preview window. See |:pop| and 973 |:ptag|. 974 975 CTRL-W } *CTRL-W_}* 976 Use identifier under cursor as a tag and perform a :ptag on 977 it. Make the new Preview window (if required) N high. If N 978 is not given, 'previewheight' is used. 979 980 CTRL-W g } *CTRL-W_g}* 981 Use identifier under cursor as a tag and perform a :ptjump on 982 it. Make the new Preview window (if required) N high. If N 983 is not given, 'previewheight' is used. 984 985 *:pb* *:pbuffer* 986 :[N]pb[uffer][!] [+cmd] [N] 987 Edit buffer [N] from the buffer list in the preview window. 988 If [N] is not given, the current buffer remains being edited. 989 See |:buffer-!| for [!]. This will also edit a buffer that is 990 not in the buffer list, without setting the 'buflisted' flag. 991 Also see |+cmd|. 992 993 *:ped* *:pedit* 994 :ped[it][!] [++opt] [+cmd] {file} 995 Edit {file} in the preview window. The preview window is 996 opened like with |:ptag|. The current window and cursor 997 position isn't changed. Useful example: > 998 :pedit +/fputc /usr/include/stdio.h 999 < 1000 Also see |++opt| and |+cmd|. 1001 1002 *:ps* *:psearch* 1003 :[range]ps[earch][!] [count] [/]pattern[/] 1004 Works like |:ijump| but shows the found match in the preview 1005 window. The preview window is opened like with |:ptag|. The 1006 current window and cursor position isn't changed. Useful 1007 example: > 1008 :psearch popen 1009 < Like with the |:ptag| command, you can use this to 1010 automatically show information about the word under the 1011 cursor. This is less clever than using |:ptag|, but you don't 1012 need a tags file and it will also find matches in system 1013 include files. Example: > 1014 :au! CursorHold *.[ch] ++nested exe "silent! psearch " .. expand("<cword>") 1015 < Warning: This can be slow. 1016 1017 Example *CursorHold-example* > 1018 1019 :au! CursorHold *.[ch] ++nested exe "silent! ptag " .. expand("<cword>") 1020 1021 This will cause a ":ptag" to be executed for the keyword under the cursor, 1022 when the cursor hasn't moved for the time set with 'updatetime'. "++nested" 1023 makes other autocommands be executed, so that syntax highlighting works in the 1024 preview window. The "silent!" avoids an error message when the tag could not 1025 be found. Also see |CursorHold|. To disable this again: > 1026 1027 :au! CursorHold 1028 1029 A nice addition is to highlight the found tag, avoid the ":ptag" when there 1030 is no word under the cursor, and a few other things: > 1031 1032 :au! CursorHold *.[ch] ++nested call PreviewWord() 1033 :func PreviewWord() 1034 : if &previewwindow " don't do this in the preview window 1035 : return 1036 : endif 1037 : let w = expand("<cword>") " get the word under cursor 1038 : if w =~ '\a' " if the word contains a letter 1039 : 1040 : " Delete any existing highlight before showing another tag 1041 : silent! wincmd P " jump to preview window 1042 : if &previewwindow " if we really get there... 1043 : match none " delete existing highlight 1044 : wincmd p " back to old window 1045 : endif 1046 : 1047 : " Try displaying a matching tag for the word under the cursor 1048 : try 1049 : exe "ptag " .. w 1050 : catch 1051 : return 1052 : endtry 1053 : 1054 : silent! wincmd P " jump to preview window 1055 : if &previewwindow " if we really get there... 1056 : if has("folding") 1057 : silent! .foldopen " don't want a closed fold 1058 : endif 1059 : call search("$", "b") " to end of previous line 1060 : let w = substitute(w, '\\', '\\\\', "") 1061 : call search('\<\V' .. w .. '\>') " position cursor on match 1062 : " Add a match highlight to the word at this position 1063 : hi previewWord term=bold ctermbg=green guibg=green 1064 : exe 'match previewWord "\%' .. line(".") .. 'l\%' .. col(".") .. 'c\k*"' 1065 : wincmd p " back to old window 1066 : endif 1067 : endif 1068 :endfun 1069 1070 ============================================================================== 1071 11. Using hidden buffers *buffer-hidden* 1072 1073 A hidden buffer is not displayed in a window, but is still loaded into memory. 1074 This makes it possible to jump from file to file, without the need to read or 1075 write the file every time you get another buffer in a window. 1076 1077 *:buffer-!* 1078 If the option 'hidden' ('hid') is set, abandoned buffers are kept for all 1079 commands that start editing another file: ":edit", ":next", ":tag", etc. The 1080 commands that move through the buffer list sometimes make the current buffer 1081 hidden although the 'hidden' option is not set. This happens when a buffer is 1082 modified, but is forced (with '!') to be removed from a window, and 1083 'autowrite' is off or the buffer can't be written. 1084 1085 You can make a hidden buffer not hidden by starting to edit it with any 1086 command, or by deleting it with the ":bdelete" command. 1087 1088 The 'hidden' is global, it is used for all buffers. The 'bufhidden' option 1089 can be used to make an exception for a specific buffer. It can take these 1090 values: 1091 <empty> Use the value of 'hidden'. 1092 hide Hide this buffer, also when 'hidden' is not set. 1093 unload Don't hide but unload this buffer, also when 'hidden' 1094 is set. 1095 delete Delete the buffer. 1096 1097 *hidden-quit* 1098 When you try to quit Vim while there is a hidden, modified buffer, you will 1099 get an error message and Vim will make that buffer the current buffer. You 1100 can then decide to write this buffer (":wq") or quit without writing (":q!"). 1101 Be careful: there may be more hidden, modified buffers! 1102 1103 A buffer can also be unlisted. This means it exists, but it is not in the 1104 list of buffers. |unlisted-buffer| 1105 1106 1107 :files[!] [flags] *:files* 1108 :buffers[!] [flags] *:buffers* *:ls* 1109 :ls[!] [flags] 1110 Show all buffers. Example: 1111 1112 1 #h "/test/text" line 1 ~ 1113 2u "asdf" line 0 ~ 1114 3 %a + "version.c" line 1 ~ 1115 1116 When the [!] is included the list will show unlisted buffers 1117 (the term "unlisted" is a bit confusing then...). 1118 1119 Each buffer has a unique number. That number will not change, 1120 thus you can always go to a specific buffer with ":buffer N" 1121 or "N CTRL-^", where N is the buffer number. 1122 1123 For the file name these special values are used: 1124 "[Prompt]" |prompt-buffer| 1125 "[Scratch]" 'buftype' is "nofile" 1126 "[No Name]" no file name specified 1127 1128 Indicators (chars in the same column are mutually exclusive): 1129 u an unlisted buffer (only displayed when [!] is used) 1130 |unlisted-buffer| 1131 % the buffer in the current window 1132 # the alternate buffer for ":e #" and CTRL-^ 1133 a an active buffer: it is loaded and visible 1134 h a hidden buffer: It is loaded, but currently not 1135 displayed in a window |hidden-buffer| 1136 `-` a buffer with 'modifiable' off 1137 = a readonly buffer 1138 R a terminal buffer with a running job 1139 F a terminal buffer with a finished job 1140 ? a terminal buffer without a job: `:terminal NONE` 1141 + a modified buffer 1142 x a buffer with read errors 1143 1144 [flags] can be a combination of the following characters, 1145 which restrict the buffers to be listed: 1146 + modified buffers 1147 `-` buffers with 'modifiable' off 1148 = readonly buffers 1149 a active buffers 1150 u unlisted buffers (overrides the "!") 1151 h hidden buffers 1152 x buffers with a read error 1153 % current buffer 1154 # alternate buffer 1155 R terminal buffers with a running job 1156 F terminal buffers with a finished job 1157 t show time last used and sort buffers 1158 Combining flags means they are "and"ed together, e.g.: 1159 h+ hidden buffers which are modified 1160 a+ active buffers which are modified 1161 1162 When using |:filter| the pattern is matched against the 1163 displayed buffer name, e.g.: > 1164 filter /\.vim/ ls 1165 < 1166 *:bad* *:badd* 1167 :bad[d] [+lnum] {fname} 1168 Add file name {fname} to the buffer list, without loading it, 1169 if it wasn't listed yet. If the buffer was previously 1170 deleted, not wiped, it will be made listed again. 1171 If "lnum" is specified, the cursor will be positioned at that 1172 line when the buffer is first entered. Note that other 1173 commands after the + will be ignored. 1174 1175 *:balt* 1176 :balt [+lnum] {fname} 1177 Like `:badd` and also set the alternate file for the current 1178 window to {fname}. 1179 1180 :[N]bd[elete][!] *:bd* *:bdel* *:bdelete* *E516* 1181 :bd[elete][!] [N] 1182 Unload buffer [N] (default: current buffer) and delete it from 1183 the buffer list. If the buffer was changed, this fails, 1184 unless [!] is specified, in which case changes are lost. 1185 The file remains unaffected. Any windows for this buffer are 1186 closed. If buffer [N] is the current buffer, another buffer 1187 will be displayed instead. This is the most recent entry in 1188 the jump list that points into a loaded buffer. 1189 1190 Actually, the buffer isn't completely deleted, it is removed 1191 from the buffer list |unlisted-buffer| and option values, 1192 variables and mappings/abbreviations for the buffer are 1193 cleared. If [N] is the last listed buffer in a window (i.e., 1194 there is no other listed buffer to switch to), the buffer is 1195 emptied instead of being unloaded. The window is not closed, 1196 and the buffer may be reused as a new buffer |buffer-reuse|. 1197 This ensures every window always has a valid buffer. 1198 1199 Examples: > 1200 :.,$-bdelete " delete buffers from the current one to 1201 " last but one 1202 :%bdelete " delete all buffers 1203 < 1204 1205 :bd[elete][!] {bufname} *E93* *E94* 1206 Like ":bdelete[!] [N]", but buffer given by name, see 1207 |{bufname}|. 1208 1209 :bd[elete][!] N1 N2 ... 1210 Do ":bdelete[!]" for buffer N1, N2, etc. The arguments can be 1211 buffer numbers or buffer names (but not buffer names that are 1212 a number). Insert a backslash before a space in a buffer 1213 name. 1214 1215 :N,Mbd[elete][!] 1216 Do ":bdelete[!]" for all buffers in the range N to M 1217 |inclusive|. 1218 1219 :[N]bw[ipeout][!] *:bw* *:bwipe* *:bwipeout* *E517* 1220 :bw[ipeout][!] {bufname} 1221 :N,Mbw[ipeout][!] 1222 :bw[ipeout][!] N1 N2 ... 1223 Like |:bdelete|, but really delete the buffer. Everything 1224 related to the buffer is lost. All marks in this buffer 1225 become invalid, option settings are lost, the jumplist and 1226 tagstack data will be purged, etc. Don't use this 1227 unless you know what you are doing. Examples: > 1228 :.+,$bwipeout " wipe out all buffers after the current 1229 " one 1230 :%bwipeout " wipe out all buffers 1231 < 1232 1233 :[N]bun[load][!] *:bun* *:bunload* *E515* 1234 :bun[load][!] [N] 1235 Unload buffer [N] (default: current buffer). The memory 1236 allocated for this buffer will be freed. The buffer remains 1237 in the buffer list. 1238 If the buffer was changed, this fails, unless when [!] is 1239 specified, in which case the changes are lost. 1240 Any windows for this buffer are closed. If buffer [N] is the 1241 current buffer, another buffer will be displayed instead. 1242 This is the most recent entry in the jump list that points 1243 into a loaded buffer. 1244 1245 :bun[load][!] {bufname} 1246 Like ":bunload[!] [N]", but buffer given by name. 1247 Also see |{bufname}|. 1248 1249 :N,Mbun[load][!] 1250 Do ":bunload[!]" for all buffers in the range N to M 1251 |inclusive|. 1252 1253 :bun[load][!] N1 N2 ... 1254 Do ":bunload[!]" for buffer N1, N2, etc. The arguments can be 1255 buffer numbers or buffer names (but not buffer names that are 1256 a number). Insert a backslash before a space in a buffer 1257 name. 1258 1259 :[N]b[uffer][!] [+cmd] [N] *:b* *:bu* *:buf* *:buffer* *E86* 1260 Edit buffer [N] from the buffer list. If [N] is not given, 1261 the current buffer remains being edited. See |:buffer-!| for 1262 [!]. This will also edit a buffer that is not in the buffer 1263 list, without setting the 'buflisted' flag. 1264 Also see |+cmd|. 1265 1266 :[N]b[uffer][!] [+cmd] {bufname} *{bufname}* 1267 Edit buffer for {bufname} from the buffer list. A partial 1268 name also works, so long as it is unique in the list of 1269 buffers. 1270 Note that a buffer whose name is a number cannot be referenced 1271 by that name; use the buffer number instead. Same is true if 1272 the buffer name starts with a `+`, it will be interpreted as 1273 the start of a |+cmd|. 1274 Insert a backslash before a space in a buffer name. 1275 See |:buffer-!| for [!]. 1276 This will also edit a buffer that is not in the buffer list, 1277 without setting the 'buflisted' flag. 1278 Also see |+cmd|. 1279 1280 :[N]sb[uffer] [+cmd] [N] *:sb* *:sbuffer* 1281 Split window and edit buffer [N] from the buffer list. If [N] 1282 is not given, the current buffer is edited. Respects the 1283 "useopen" setting of 'switchbuf' when splitting. This will 1284 also edit a buffer that is not in the buffer list, without 1285 setting the 'buflisted' flag. 1286 Also see |+cmd|. 1287 1288 :[N]sb[uffer] [+cmd] {bufname} 1289 Split window and edit buffer for |{bufname}| from the buffer 1290 list. This will also edit a buffer that is not in the buffer 1291 list, without setting the 'buflisted' flag. 1292 Note: If what you want to do is split the buffer, make a copy 1293 under another name, you can do it this way: > 1294 :w foobar | sp # 1295 < Also see |+cmd|. 1296 1297 :[N]bn[ext][!] [+cmd] [N] *:bn* *:bnext* *E87* 1298 Go to [N]th next buffer in buffer list. [N] defaults to one. 1299 Wraps around the end of the buffer list. 1300 See |:buffer-!| for [!]. 1301 Also see |+cmd|. 1302 If you are in a help buffer, this takes you to the next help 1303 buffer (if there is one). Similarly, if you are in a normal 1304 (non-help) buffer, this takes you to the next normal buffer. 1305 This is so that if you have invoked help, it doesn't get in 1306 the way when you're browsing code/text buffers. The next 1307 three commands also work like this. 1308 1309 *]b* 1310 ]b Mapped to |:bnext|. |default-mappings| 1311 1312 *:sbn* *:sbnext* 1313 :[N]sbn[ext] [+cmd] [N] 1314 Split window and go to [N]th next buffer in buffer list. 1315 Wraps around the end of the buffer list. Uses 'switchbuf' 1316 Also see |+cmd|. 1317 1318 :[N]bN[ext][!] [+cmd] [N] *:bN* *:bNext* *:bp* *:bprevious* *E88* 1319 1320 *[b* 1321 [b Mapped to |:bprevious|. |default-mappings| 1322 1323 :[N]bp[revious][!] [+cmd] [N] 1324 Go to [N]th previous buffer in buffer list. [N] defaults to 1325 one. Wraps around the start of the buffer list. 1326 See |:buffer-!| for [!] and 'switchbuf'. 1327 Also see |+cmd|. 1328 1329 :[N]sbN[ext] [+cmd] [N] *:sbN* *:sbNext* *:sbp* *:sbprevious* 1330 :[N]sbp[revious] [+cmd] [N] 1331 Split window and go to [N]th previous buffer in buffer list. 1332 Wraps around the start of the buffer list. 1333 Uses 'switchbuf'. 1334 Also see |+cmd|. 1335 1336 :br[ewind][!] [+cmd] *:br* *:bre* *:brewind* 1337 Go to first buffer in buffer list. If the buffer list is 1338 empty, go to the first unlisted buffer. 1339 See |:buffer-!| for [!]. 1340 1341 *[B* 1342 [B Mapped to |:brewind|. |default-mappings| 1343 1344 :bf[irst] [+cmd] *:bf* *:bfirst* 1345 Same as |:brewind|. 1346 Also see |+cmd|. 1347 1348 :sbr[ewind] [+cmd] *:sbr* *:sbrewind* 1349 Split window and go to first buffer in buffer list. If the 1350 buffer list is empty, go to the first unlisted buffer. 1351 Respects the 'switchbuf' option. 1352 Also see |+cmd|. 1353 1354 :sbf[irst] [+cmd] *:sbf* *:sbfirst* 1355 Same as ":sbrewind". 1356 1357 :bl[ast][!] [+cmd] *:bl* *:blast* 1358 Go to last buffer in buffer list. If the buffer list is 1359 empty, go to the last unlisted buffer. 1360 See |:buffer-!| for [!]. 1361 1362 *]B* 1363 ]B Mapped to |:blast|. |default-mappings| 1364 1365 :sbl[ast] [+cmd] *:sbl* *:sblast* 1366 Split window and go to last buffer in buffer list. If the 1367 buffer list is empty, go to the last unlisted buffer. 1368 Respects 'switchbuf' option. 1369 1370 :[N]bm[odified][!] [+cmd] [N] *:bm* *:bmodified* *E84* 1371 Go to [N]th next modified buffer. Note: this command also 1372 finds unlisted buffers. If there is no modified buffer the 1373 command fails. 1374 1375 :[N]sbm[odified] [+cmd] [N] *:sbm* *:sbmodified* 1376 Split window and go to [N]th next modified buffer. 1377 Respects 'switchbuf' option. 1378 Note: this command also finds buffers not in the buffer list. 1379 1380 :[N]unh[ide] [N] *:unh* *:unhide* *:sun* *:sunhide* 1381 :[N]sun[hide] [N] 1382 Rearrange the screen to open one window for each loaded buffer 1383 in the buffer list. When a count is given, this is the 1384 maximum number of windows to open. 1385 1386 :[N]ba[ll] [N] *:ba* *:ball* *:sba* *:sball* 1387 :[N]sba[ll] [N] Rearrange the screen to open one window for each buffer in 1388 the buffer list. When a count is given, this is the maximum 1389 number of windows to open. 'winheight' also limits the number 1390 of windows opened ('winwidth' if |:vertical| was prepended). 1391 Buf/Win Enter/Leave autocommands are not executed for the new 1392 windows here, that's only done when they are really entered. 1393 When the |:tab| modifier is used new windows are opened in a 1394 new tab, up to 'tabpagemax'. 1395 1396 Note: All the commands above that start editing another buffer, keep the 1397 'readonly' flag as it was. This differs from the ":edit" command, which sets 1398 the 'readonly' flag each time the file is read. 1399 1400 ============================================================================== 1401 12. Special kinds of buffers *special-buffers* 1402 1403 Instead of containing the text of a file, buffers can also be used for other 1404 purposes. A few options can be set to change the behavior of a buffer: 1405 'bufhidden' what happens when the buffer is no longer displayed 1406 in a window. 1407 'buftype' what kind of a buffer this is 1408 'swapfile' whether the buffer will have a swap file 1409 'buflisted' buffer shows up in the buffer list 1410 1411 A few useful kinds of a buffer: 1412 1413 quickfix Used to contain the error list or the location list. See 1414 |:cwindow| and |:lwindow|. This command sets the 'buftype' 1415 option to "quickfix". You are not supposed to change this! 1416 'swapfile' is off. 1417 1418 help Contains a help file. Will only be created with the |:help| 1419 command. The flag that indicates a help buffer is internal 1420 and can't be changed. The 'buflisted' option will be reset 1421 for a help buffer. 1422 1423 terminal A terminal window buffer, see |terminal|. The contents cannot 1424 be read or changed until the job ends. 1425 1426 directory Displays directory contents. Can be used by a file explorer 1427 plugin. The buffer is created with these settings: > 1428 :setlocal buftype=nowrite 1429 :setlocal bufhidden=delete 1430 :setlocal noswapfile 1431 < The buffer name is the name of the directory and is adjusted 1432 when using the |:cd| command. 1433 1434 *scratch-buffer* 1435 scratch Contains text that can be discarded at any time. It is kept 1436 when closing the window, it must be deleted explicitly. 1437 Settings: > 1438 :setlocal buftype=nofile 1439 :setlocal bufhidden=hide 1440 :setlocal noswapfile 1441 < The buffer name can be used to identify the buffer, if you 1442 give it a meaningful name. 1443 1444 *unlisted-buffer* 1445 unlisted The buffer is not in the buffer list. It is not used for 1446 normal editing, but to show a help file, remember a file name 1447 or marks. The ":bdelete" command will also set this option, 1448 thus it doesn't completely delete the buffer. Settings: > 1449 :setlocal nobuflisted 1450 < 1451 1452 vim:tw=78:ts=8:noet:ft=help:norl: