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