windows.txt 53 KB

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