Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
windows.txt1480 linesDownload Raw Back to doc
1*windows.txt*	For Vim version 9.2.  Last change: 2026 Mar 012 3 4		  VIM REFERENCE MANUAL	  by Bram Moolenaar5 6 7Editing with multiple windows and buffers.		*windows* *buffers*8 9The commands which have been added to use multiple windows and buffers are10explained here.  Additionally, there are explanations for commands that work11differently 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 161.  Introduction				|windows-intro|172.  Starting Vim				|windows-starting|183.  Opening and closing a window		|opening-window|194.  Moving cursor to other windows		|window-move-cursor|205.  Moving windows around			|window-moving|216.  Window resizing				|window-resize|227.  Argument and buffer list commands		|buffer-list|238.  Do a command in all buffers or windows	|list-repeat|249.  Tag or file name under the cursor		|window-tag|2510. The preview window				|preview-window|2611. Using hidden buffers			|buffer-hidden|2712. Special kinds of buffers			|special-buffers|28 29{not able to use multiple windows when the |+windows| feature was disabled at30compile time}31 32==============================================================================331. Introduction					*windows-intro* *window*34 35Summary:36   A buffer is the in-memory text of a file.37   A window is a viewport on a buffer.38   A tab page is a collection of windows.39 40A window is a viewport onto a buffer.  You can use multiple windows on one41buffer, or several windows on different buffers.42 43A buffer is a file loaded into memory for editing.  The original file remains44unchanged until you write the buffer to the file.45 46A buffer can be in one of three states:47 48							*active-buffer*49active:   The buffer is displayed in a window.  If there is a file for this50	  buffer, it has been read into the buffer.  The buffer may have been51	  modified since then and thus be different from the file.52							*hidden-buffer*53hidden:   The buffer is not displayed.  If there is a file for this buffer, it54	  has been read into the buffer.  Otherwise it's the same as an active55	  buffer, you just can't see it.56							*inactive-buffer*57inactive: The buffer is not displayed and does not contain anything.  Options58	  for the buffer are remembered if the file was once loaded.  It can59	  contain marks from the |viminfo| file.  But the buffer doesn't60	  contain text.61 62In a table:63 64state		displayed	loaded		":buffers"  ~65		in window			shows	    ~66active		  yes		 yes		  'a'67hidden		  no		 yes		  'h'68inactive	  no		 no		  ' '69 70							*buffer-reuse*71Each buffer has a unique number and the number will not change within a Vim72session.  The |bufnr()| and |bufname()| functions can be used to convert73between a buffer name and the buffer number.  There is one exception: if a new74empty buffer is created and it is not modified, the buffer will be re-used75when loading another file into that buffer.  This also means the buffer number76will not change.77 78The main Vim window can hold several split windows.  There are also tab pages79|tab-page|, each of which can hold multiple windows.80 81					*window-ID* *winid* *windowid*82Each window has a unique identifier called the window ID.  This identifier83will not change within a Vim session.  The |win_getid()| and |win_id2tabwin()|84functions can be used to convert between the window/tab number and the85identifier.  There is also the window number, which may change whenever86windows are opened or closed, see |winnr()|.87The window number is only valid in one specific tab.  The window ID is valid88across tabs.  For most functions that take a window ID or a window number, the89window number only applies to the current tab, while the window ID can refer90to a window in any tab.91 92 93==============================================================================942. Starting Vim						*windows-starting*95 96By default, Vim starts with one window, just like Vi.97 98The "-o" and "-O" arguments to Vim can be used to open a window for each file99in the argument list.  The "-o" argument will split the windows horizontally;100the "-O" argument will split the windows vertically.  If both "-o" and "-O"101are given, the last one encountered will be used to determine the split102orientation.  For example, this will open three windows, split horizontally: >103	vim -o file1 file2 file3104 105"-oN", where N is a decimal number, opens N windows split horizontally.  If106there are more file names than windows, only N windows are opened and some107files do not get a window.  If there are more windows than file names, the108last few windows will be editing empty buffers.  Similarly, "-ON" opens N109windows split vertically, with the same restrictions.110 111If there are many file names, the windows will become very small.  You might112want to set the 'winheight' and/or 'winwidth' options to create a workable113situation.114 115Buf/Win Enter/Leave |autocommand|s are not executed when opening the new116windows and reading the files, that's only done when they are really entered.117 118							*status-line*119A status line will be used to separate windows.  The 'laststatus' option tells120when the last window also has a status line:121	'laststatus' = 0	never a status line122	'laststatus' = 1	status line if there is more than one window123	'laststatus' = 2	always a status line124 125You can change the contents and height of the status line with the126'statusline' and 'statuslineopt' options.  Both can be local to the window,127allowing each window to have a unique status line appearance and height.128 129Normally, inversion is used to display the status line.  This can be changed130with the 's' character in the 'highlight' option.  For example, "sb" sets it131to bold characters.  If no highlighting is used for the status line ("sn"),132the '^' character is used for the current window, and '=' for other windows.133If the mouse is supported and enabled with the 'mouse' option, a status line134can be dragged to resize windows.135 136Note: If you expect your status line to be in reverse video and it isn't,137check if the 'highlight' option contains "si".  In version 3.0, this meant to138invert the status line.  Now it should be "sr", reverse the status line, as139"si" now stands for italic!  If italic is not available on your terminal, the140status line is inverted anyway; you will only see this problem on terminals141that have termcap codes for italics.142 143							*filler-lines*144The lines after the last buffer line in a window are called filler lines.  By145default, these lines start with a tilde (~) character.  The "eob" item in the146'fillchars' option can be used to change this character.  By default, these147characters are highlighted as NonText (|hl-NonText|).  The EndOfBuffer148highlight group (|hl-EndOfBuffer|) can be used to change the highlighting of149the filler characters.150 151==============================================================================1523. Opening and closing a window				*opening-window*153 154CTRL-W s						*CTRL-W_s*155CTRL-W S						*CTRL-W_S*156CTRL-W CTRL-S						*CTRL-W_CTRL-S*157:[N]sp[lit] [++opt] [+cmd]				*:sp* *:split*158		Split current window in two.  The result is two viewports on159		the same file.160 161		Make the new window N high (default is to use half the height162		of the current window).  Reduces the current window height to163		create room (and others, if the 'equalalways' option is set,164		'eadirection' isn't "hor", and one of them is higher than the165		current or the new window).166 167		Note: CTRL-S does not work on all terminals and might block168		further input, use CTRL-Q to get going again.169		Also see |++opt| and |+cmd|.170							*E242* *E1159*171		Be careful when splitting a window in an autocommand, it may172		mess up the window layout if this happens while making other173		window layout changes.174 175:[N]sp[lit] [++opt] [+cmd] {file}			*:split_f*176		Like |:split| but create a new window and start editing file177		{file} in it.178		This behaves almost like a ":split" first, and then an ":edit"179		command, but the alternate file name in the original window is180		set to {file}.181		If [+cmd] is given, execute the command when the file has been182		loaded |+cmd|.183		Also see |++opt|.184		Make new window N high (default is to use half the existing185		height).  Reduces the current window height to create room186		(and others, if the 'equalalways' option is set).187 188CTRL-W CTRL-V						*CTRL-W_CTRL-V*189CTRL-W v						*CTRL-W_v*190:[N]vs[plit] [++opt] [+cmd] [file]			*:vs* *:vsplit*191		Like |:split|, but split vertically.  The windows will be192		spread out horizontally if193		1. a width was not specified,194		2. 'equalalways' is set,195		3. 'eadirection' isn't "ver", and196		4. one of the other windows is wider than the current or new197		   window.198		If N was given make the new window N columns wide, if199		possible.200		Note: In other places CTRL-Q does the same as CTRL-V, but here201		it doesn't!202 203CTRL-W n						*CTRL-W_n*204CTRL-W CTRL-N						*CTRL-W_CTRL-N*205:[N]new [++opt] [+cmd]					*:new*206		Create a new window and start editing an empty file in it.207		Make new window N high (default is to use half the existing208		height).  Reduces the current window height to create room209		(and others, if the 'equalalways' option is set and210		'eadirection' isn't "hor").211		Also see |++opt| and |+cmd|.212		If 'fileformats' is not empty, the first format given will be213		used for the new buffer.  If 'fileformats' is empty, the214		'fileformat' of the current buffer is used.  This can be215		overridden with the |++opt| argument.216		Autocommands are executed in this order:217		1. WinLeave for the current window218		2. WinEnter for the new window219		3. BufLeave for the current buffer220		4. BufEnter for the new buffer221		This behaves like a ":split" first, and then an ":enew"222		command.223 224:[N]new [++opt] [+cmd] {file}225		Like |:split_f|, create a new window and start editing {file}.226 227:[N]vne[w] [++opt] [+cmd] [file]			*:vne* *:vnew*228		Like |:new|, but split vertically.  If 'equalalways' is set229		and 'eadirection' isn't "ver" the windows will be spread out230		horizontally, unless a width was specified.231 232:[N]sv[iew] [++opt] [+cmd] [file]		*:sv* *:sview* *splitview*233		Same as ":split", but set 'readonly' option for this buffer.234 235:[N]sf[ind] [++opt] [+cmd] {file}	     *:sf* *:sfi* *:sfind* *splitfind*236		Same as ":split", but search for {file} in 'path' like in237		|:find|.  Doesn't split if {file} is not found.238 239CTRL-W CTRL-^					*CTRL-W_CTRL-^* *CTRL-W_^*240CTRL-W ^	Split the current window in two and edit the alternate file.241		When a count N is given, split the current window and edit242		buffer N.  Similar to ":sp #" and ":sp #N", but it allows the243		other buffer to be unnamed.  This command matches the behavior244		of |CTRL-^|, except that it splits a window first.245 246						*CTRL-W_:*247CTRL-W :	Does the same as typing |:| - enter a command line.  Useful in a248		terminal window, where all Vim commands must be preceded with249		CTRL-W or 'termwinkey'.250 251Note that the 'splitbelow' and 'splitright' options influence where a new252window will appear.253								*E36*254Creating a window will fail if there is not enough room.  Every window needs255at least one screen line and column, sometimes more.   Options 'winminheight'256and 'winminwidth' are relevant.257 258						*:vert* *:vertical*259:vert[ical] {cmd}260		Execute {cmd}.  If it contains a command that splits a window,261		it will be split vertically.  For `vertical wincmd =` windows262		will be equalized only vertically.263		Doesn't work for |:execute| and |:normal|.264 265						*:hor* *:horizontal*266:hor[izontal] {cmd}267		Execute {cmd}.  Currently only makes a difference for268		`horizontal wincmd =`, which will equalize windows only269		horizontally.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 (horizontal275		split) the current window.  Overrules 'splitbelow' and276		'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 (horizontal283		split) the current window.  Overrules 'splitbelow' and284		'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 Vim291		window.  When the split is vertical the window appears at the292		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 the299		Vim window.  When the split is vertical the window appears at300		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 window304occupy the full height.  Example: >305	:vertical topleft split tags306Opens a vertically split, full-height window on the "tags" file at the far307left of the Vim window.308 309 310Closing a window311----------------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} is318		given quit the {count} window.319							*edit-window*320		When quitting the last edit window (not counting help or321		preview windows), exit Vim.322 323		When 'hidden' is set, and there is only one window for the324		current buffer, it becomes hidden.  When 'hidden' is not set,325		and there is only one window for the current buffer, and the326		buffer was changed, the command fails.327 328		(Note: CTRL-Q does not work on all terminals).329 330		If [count] is greater than the last window number the last331		window will be closed: >332		    :1quit  " quit the first window333		    :$quit  " quit the last window334		    :9quit  " quit the last window335			    " if there are fewer than 9 windows opened336		    :-quit  " quit the previous window337		    :+quit  " quit the next window338		    :+2quit " quit the second next window339<340		When closing a help window, and this is not the only window,341		Vim will try to restore the previous window layout, see342		|:helpclose|.343 344:q[uit]!345:{count}q[uit]!346		Without {count}: Quit the current window.  If {count} is347		given quit the {count} window.348 349		If this was the last window for a buffer, any changes to that350		buffer are lost.  When quitting the last window (not counting351		help windows), exit Vim.  The contents of the buffer are lost,352		even when 'hidden' is set.353 354:clo[se][!]355:{count}clo[se][!]356CTRL-W c					*CTRL-W_c* *:clo* *:close*357		Without {count}: Close the current window.  If {count} is358		given close the {count} window.359 360		When the 'hidden' option is set, or when the buffer was361		changed and the [!] is used, the buffer becomes hidden (unless362		there is another window editing it).363 364		When there is only one |edit-window| in the current tab page365		and there is another tab page, this closes the current tab366		page.  |tab-page|.367 368		This command fails when:			*E444*369		- There is only one window on the screen.370		- When 'hidden' is not set, [!] is not used, the buffer has371		  changes, and there is no other window on this buffer.372		Changes to the buffer are not written and won't get lost, so373		this is a "safe" command.374 375CTRL-W CTRL-C						*CTRL-W_CTRL-C*376		You might have expected that CTRL-W CTRL-C closes the current377		window, but that does not work, because the CTRL-C cancels the378		command.379 380							*:hide*381:hid[e]382:{count}hid[e]383		Without {count}: Quit the current window, unless it is the384		last window on the screen.385		If {count} is given quit the {count} window.386 387		The buffer becomes hidden (unless there is another window388		editing it or 'bufhidden' is "unload", "delete" or "wipe").389		If the window is the last one in the current tab page the tab390		page is closed.  |tab-page|391 392		The value of 'hidden' is irrelevant for this command.  Changes393		to the buffer are not written and won't get lost, so this is a394		"safe" command.395 396:hid[e] {cmd}	Execute {cmd} with 'hidden' set.  The previous value of397		'hidden' is restored after {cmd} has been executed.398		Example: >399		    :hide edit Makefile400<		This will edit "Makefile", and hide the current buffer if it401		has any changes.402 403:on[ly][!]404:{count}on[ly][!]405CTRL-W o						*CTRL-W_o* *E445*406CTRL-W CTRL-O					*CTRL-W_CTRL-O* *:on* *:only*407		Make the current window the only one on the screen.  All other408		windows are closed.  For {count} see the `:quit` command409		above |:count_quit|.410 411		When the 'hidden' option is set, all buffers in closed windows412		become hidden.413 414		When 'hidden' is not set, and the 'autowrite' option is set,415		modified buffers are written.  Otherwise, windows that have416		buffers that are modified are not removed, unless the [!] is417		given, then they become hidden.  But modified buffers are418		never abandoned, so changes cannot get lost.419 420==============================================================================4214. Moving cursor to other windows			*window-move-cursor*422 423CTRL-W <Down>					*CTRL-W_<Down>*424CTRL-W CTRL-J					*CTRL-W_CTRL-J* *CTRL-W_j*425CTRL-W j	Move cursor to Nth window below current one.  Uses the cursor426		position to select between alternatives.427 428CTRL-W <Up>					*CTRL-W_<Up>*429CTRL-W CTRL-K					*CTRL-W_CTRL-K* *CTRL-W_k*430CTRL-W k	Move cursor to Nth window above current one.  Uses the cursor431		position to select between alternatives.432 433CTRL-W <Left>					*CTRL-W_<Left>*434CTRL-W CTRL-H					*CTRL-W_CTRL-H*435CTRL-W <BS>					*CTRL-W_<BS>* *CTRL-W_h*436CTRL-W h	Move cursor to Nth window left of current one.  Uses the437		cursor position to select between alternatives.438 439CTRL-W <Right>					*CTRL-W_<Right>*440CTRL-W CTRL-L					*CTRL-W_CTRL-L* *CTRL-W_l*441CTRL-W l	Move cursor to Nth window right of current one.  Uses the442		cursor position to select between alternatives.443 444CTRL-W w					*CTRL-W_w* *CTRL-W_CTRL-W*445CTRL-W CTRL-W	Without count: move cursor to window below/right of the446		current one.  If there is no window below or right, go to447		top-left window.448		With count: go to Nth window (windows are numbered from449		top-left to bottom-right).  To obtain the window number see450		|bufwinnr()| and |winnr()|.  When N is larger than the number451		of windows go to the last window.452 453						*CTRL-W_W*454CTRL-W W	Without count: move cursor to window above/left of current455		one.  If there is no window above or left, go to bottom-right456		window.  With count: go to Nth window, like with CTRL-W w.457 458CTRL-W t					*CTRL-W_t* *CTRL-W_CTRL-T*459CTRL-W CTRL-T	Move cursor to top-left window.460 461CTRL-W b					*CTRL-W_b* *CTRL-W_CTRL-B*462CTRL-W CTRL-B	Move cursor to bottom-right window.463 464CTRL-W p					*CTRL-W_p* *CTRL-W_CTRL-P*465CTRL-W CTRL-P	Go to previous (last accessed) window.466 467						*CTRL-W_P* *E441*468CTRL-W P	Go to preview window.  When there is no preview window this is469		an error.470		{not available when compiled without the |+quickfix| feature}471 472If Visual mode is active and the new window is not for the same buffer, the473Visual mode is ended.  If the window is on the same buffer, the cursor474position 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		Like executing CTRL-W [count] {arg}.  Example: >481			:wincmd j482<		Moves to the window below the current one.483		This command is useful when a Normal mode cannot be used (for484		the |CursorHold| autocommand event).  Or when a Normal mode485		command is inconvenient.486		The count can also be a window number.  Example: >487			:exe nr .. "wincmd w"488<		This goes to window "nr".489 490Note: All CTRL-W commands can also be executed with |:wincmd|, for those491places where a Normal mode command can't be used or is inconvenient (e.g.492in a browser-based terminal).493 494==============================================================================4955. Moving windows around				*window-moving*496 497CTRL-W r				*CTRL-W_r* *CTRL-W_CTRL-R* *E443*498CTRL-W CTRL-R	Rotate windows downwards/rightwards.  The first window becomes499		the second one, the second one becomes the third one, etc.500		The last window becomes the first window.  The cursor remains501		in the same window.502		This only works within the row or column of windows that the503		current window is in.504 505						*CTRL-W_R*506CTRL-W R	Rotate windows upwards/leftwards.  The second window becomes507		the first one, the third one becomes the second one, etc.  The508		first window becomes the last window.  The cursor remains in509		the same window.510		This only works within the row or column of windows that the511		current window is in.512 513CTRL-W x					*CTRL-W_x* *CTRL-W_CTRL-X*514CTRL-W CTRL-X	Without count: Exchange current window with next one.  If515		there is no next window, exchange with previous window.516		With count: Exchange current window with Nth window (first517		window is 1).  The cursor is put in the other window.518		When vertical and horizontal window splits are mixed, the519		exchange is only done in the row or column of windows that the520		current window is in.521 522The following commands can be used to change the window layout.  For example,523when there are two vertically split windows, CTRL-W K will change that in524horizontally split windows.  CTRL-W H does it the other way around.525 526						*CTRL-W_K*527CTRL-W K	Move the current window to be at the very top, using the full528		width of the screen.  This works like `:topleft split`, except529		it is applied to the current window and no new window is530		created.531 532						*CTRL-W_J*533CTRL-W J	Move the current window to be at the very bottom, using the534		full width of the screen.  This works like `:botright split`,535		except it is applied to the current window and no new window536		is created.537 538						*CTRL-W_H*539CTRL-W H	Move the current window to be at the far left, using the540		full height of the screen.  This works like541		`:vert topleft split`, except it is applied to the current542		window and no new window is created.543 544						*CTRL-W_L*545CTRL-W L	Move the current window to be at the far right, using the full546		height of the screen.  This works like `:vert botright split`,547		except it is applied to the current window and no new window548		is created.549 550						*CTRL-W_T*551CTRL-W T	Move the current window to a new tab page.  This fails if552		there is only one window in the current tab page.553		This works like `:tab split`, except the previous window is554		closed.555		When a count is specified the new tab page will be opened556		before the tab page with this index.  Otherwise it comes after557		the current tab page.558 559==============================================================================5606. Window resizing					*window-resize*561 562						*CTRL-W_=*563CTRL-W =	Make all windows (almost) equally high and wide, but use564		'winheight' and 'winwidth' for the current window.565		Windows with 'winfixheight' set keep their height and windows566		with 'winfixwidth' set keep their width.567		To equalize only vertically (make window equally high) use568		`vertical wincmd =`.569		To equalize only horizontally (make window equally wide) use570		`horizontal wincmd =`.571 572:res[ize] -N					*:res* *:resize* *CTRL-W_-*573CTRL-W -	Decrease current window height by N (default 1).574		If used after |:vertical|: decrease width by N.575 576:res[ize] +N					*CTRL-W_+*577CTRL-W +	Increase current window height by N (default 1).578		If used after |:vertical|: increase width by N.579 580:res[ize] [N]581CTRL-W CTRL-_					*CTRL-W_CTRL-_* *CTRL-W__*582CTRL-W _	Set current window height to N (default: highest possible).583 584:{winnr}res[ize] [+-]N585		Like `:resize` above, but apply the size to window {winnr}586		instead of the current window.587 588z{nr}<CR>	Set current window height to {nr}.589 590						*CTRL-W_<*591CTRL-W <	Decrease current window width by N (default 1).592 593						*CTRL-W_>*594CTRL-W >	Increase current window width by N (default 1).595 596:vert[ical] res[ize] [N]			*:vertical-resize* *CTRL-W_bar*597CTRL-W |	Set current window width to N (default: widest possible).598 599You can also resize a window by dragging a status line up or down with the600mouse.  Or by dragging a vertical separator line left or right.  This only601works if the version of Vim that is being used supports the mouse and the602'mouse' option has been set to enable it.603 604The option 'winheight' ('wh') is used to set the minimal window height of the605current window.  This option is used each time another window becomes the606current window.  If the option is '0', it is disabled.  Set 'winheight' to a607very large value, e.g., '9999', to make the current window always fill all608available space.  Set it to a reasonable value, e.g., '10', to make editing in609the current window comfortable.610 611The equivalent 'winwidth' ('wiw') option is used to set the minimal width of612the current window.613 614When the option 'equalalways' ('ea') is set, all the windows are automatically615made the same size after splitting or closing a window.  If you don't set this616option, splitting a window will reduce the size of the current window and617leave the other windows the same.  When closing a window, the extra lines are618given to the window above it.619 620The 'eadirection' option limits the direction in which the 'equalalways'621option is applied.  The default "both" resizes in both directions.  When the622value is "ver" only the heights of windows are equalized.  Use this when you623have manually resized a vertically split window and want to keep this width.624Likewise, "hor" causes only the widths of windows to be equalized.625 626The option 'cmdheight' ('ch') is used to set the height of the command-line.627If you are annoyed by the |hit-enter| prompt for long messages, set this628option to 2 or 3.629 630If there is only one window, resizing that window will also change the command631line height.  If there are several windows, resizing the current window will632also change the height of the window below it (and sometimes the window above633it).634 635The minimal height and width of a window is set with 'winminheight' and636'winminwidth'.  These are hard values, a window will never become smaller.637 638 639WinScrolled and WinResized autocommands ~640						*win-scrolled-resized*641If you want to get notified of changes in window sizes, the |WinResized|642autocommand event can be used.643If you want to get notified of text in windows scrolling vertically or644horizontally, the |WinScrolled| autocommand event can be used.  This will also645trigger in window size changes.646Exception: the events will not be triggered when the text scrolls for647'incsearch'.648							*WinResized-event*649The |WinResized| event is triggered after updating the display, several650windows may have changed size then.  A list of the IDs of windows that changed651since last time is provided in the v:event.windows variable, for example:652	[1003, 1006]653							*WinScrolled-event*654The |WinScrolled| event is triggered after |WinResized|, and also if a window655was scrolled.  That can be vertically (the text at the top of the window656changed) or horizontally (when 'wrap' is off or when the first displayed part657of the first line changes).  Note that |WinScrolled| will trigger many more658times than |WinResized|, it may slow down editing a bit.659 660The information provided by |WinScrolled| is a dictionary for each window that661has changes, using the window ID as the key, and a total count of the changes662with the key "all".  Example value for |v:event| (|Vim9| syntax): >663	{664	   all:  {width: 0, height:  2, leftcol: 0, skipcol: 0, topline: 1, topfill: 0},665	   1003: {width: 0, height: -1, leftcol: 0, skipcol: 0, topline: 0, topfill: 0},666	   1006: {width: 0, height:  1, leftcol: 0, skipcol: 0, topline: 1, topfill: 0},667	}668 669Note that the "all" entry has the absolute values of the individual windows670accumulated.671 672If you need more information about what changed, or you want to "debounce" the673events (not handle every event to avoid doing too much work), you may want to674use the `winlayout()` and `getwininfo()` functions.675 676|WinScrolled| and |WinResized| do not trigger when the first autocommand is677added, only after the first scroll or resize.  They may trigger when switching678to another tab page.679 680The commands executed are expected to not cause window size or scroll changes.681If this happens anyway, the event will trigger again very soon.  In other682words: Just before triggering the event, the current sizes and scroll683positions are stored and used to decide whether there was a change.684								*E1312*685It is not allowed to change the window layout here (split, close or move686windows).687 688==============================================================================6897. Argument and buffer list commands			*buffer-list*690 691      args list		       buffer list	   meaning ~6921. :[N]argument [N]	11. :[N]buffer [N]	to arg/buf N6932. :[N]next [file ..]	12. :[N]bnext [N]	to Nth next arg/buf6943. :[N]Next [N]		13. :[N]bNext [N]	to Nth previous arg/buf6954. :[N]previous	[N]	14. :[N]bprevious [N]	to Nth previous arg/buf6965. :rewind / :first	15. :brewind / :bfirst	to first arg/buf6976. :last		16. :blast		to last arg/buf6987. :all			17. :ball		edit all args/buffers699			18. :unhide		edit all loaded buffers700			19. :[N]bmod [N]	to Nth modified buf701 702  split & args list	  split & buffer list	   meaning ~70321. :[N]sargument [N]   31. :[N]sbuffer [N]	split + to arg/buf N70422. :[N]snext [file ..] 32. :[N]sbnext [N]      split + to Nth next arg/buf70523. :[N]sNext [N]       33. :[N]sbNext [N]      split + to Nth previous arg/buf70624. :[N]sprevious [N]   34. :[N]sbprevious [N]  split + to Nth previous arg/buf70725. :srewind / :sfirst	35. :sbrewind / :sbfirst split + to first arg/buf70826. :slast		36. :sblast		split + to last arg/buf70927. :sall		37. :sball		edit all args/buffers710			38. :sunhide		edit all loaded buffers711			39. :[N]sbmod [N]	split + to Nth modified buf712 71340. :args		list of arguments71441. :buffers		list of buffers715 716The meaning of [N] depends on the command:717 [N] is the number of buffers to go forward/backward on 2/12/22/32,718     3/13/23/33, and 4/14/24/34719 [N] is an argument number, defaulting to current argument, for 1 and 21720 [N] is a buffer number, defaulting to current buffer, for 11 and 31721 [N] is a count for 19 and 39722 723Note: ":next" is an exception, because it must accept a list of file names724for compatibility with Vi.725 726 727The argument list and multiple windows728--------------------------------------729 730The current position in the argument list can be different for each window.731Remember that when doing ":e file", the position in the argument list stays732the same, but you are not editing the file at that position.  To indicate733this, the file message (and the title, if you have one) shows734"(file (N) of M)", where "(N)" is the current position in the file list, and735"M" the number of files in the file list.736 737All the entries in the argument list are added to the buffer list.  Thus, you738can also get to them with the buffer list commands, like ":bnext".739 740:[N]al[l][!] [N]				*:al* *:all* *:sal* *:sall*741:[N]sal[l][!] [N]742		Rearrange the screen to open one window for each argument.743		All other windows are closed.  When a count is given, this is744		the maximum number of windows to open.745		With the |:tab| modifier open a tab page for each argument.746		When there are more arguments than 'tabpagemax' further ones747		become split windows in the last tab page.748		When the 'hidden' option is set, all buffers in closed windows749		become hidden.750		When 'hidden' is not set, and the 'autowrite' option is set,751		modified buffers are written.  Otherwise, windows that have752		buffers that are modified are not removed, unless the [!] is753		given, then they become hidden.  But modified buffers are754		never abandoned, so changes cannot get lost.755		[N] is the maximum number of windows to open.  'winheight'756		also limits the number of windows opened ('winwidth' if757		|:vertical| was prepended).758		Buf/Win Enter/Leave autocommands are not executed for the new759		windows here, that's only done when they are really entered.760		If autocommands change the window layout while this command is761		busy an error will be given. *E249*762 763:[N]sa[rgument][!] [++opt] [+cmd] [N]			*:sa* *:sargument*764		Short for ":split | argument [N]": split window and go to Nth765		argument.  But when there is no such argument, the window is766		not split.  Also see |++opt| and |+cmd|.767 768:[N]sn[ext][!] [++opt] [+cmd] [file ..]			*:sn* *:snext*769		Short for ":split | [N]next": split window and go to Nth next770		argument.  But when there is no next file, the window is not771		split.  Also see |++opt| and |+cmd|.772 773:[N]spr[evious][!] [++opt] [+cmd] [N]			*:spr* *:sprevious*774:[N]sN[ext][!] [++opt] [+cmd] [N]			*:sN* *:sNext*775		Short for ":split | [N]Next": split window and go to Nth776		previous argument.  But when there is no previous file, the777		window is not split.  Also see |++opt| and |+cmd|.778 779						*:sre* *:srewind*780:sre[wind][!] [++opt] [+cmd]781		Short for ":split | rewind": split window and go to first782		argument.  But when there is no argument list, the window is783		not split.  Also see |++opt| and |+cmd|.784 785						*:sfir* *:sfirst*786:sfir[st] [++opt] [+cmd]787		Same as ":srewind".788 789						*:sla* *:slast*790:sla[st][!] [++opt] [+cmd]791		Short for ":split | last": split window and go to last792		argument.  But when there is no argument list, the window is793		not split.  Also see |++opt| and |+cmd|.794 795						*:dr* *:drop*796:dr[op] [++opt] [+cmd] {file} ..797		Edit the first {file} in a window.798		- If the file is already open in a window change to that799		  window.800		- If the file is not open in a window edit the file in the801		  current window.  If the current buffer can't be |abandon|ed,802		  the window is split first.803		- Windows that are not in the argument list or are not full804		  width will be closed if possible.805		The |argument-list| is set, like with the |:next| command.806		The purpose of this command is that it can be used from a807		program that wants Vim to edit another file, e.g., a debugger.808		When using the |:tab| modifier each argument is opened in a809		tab page.  The last window is used if it's empty.810		Also see |++opt| and |+cmd|.811 812==============================================================================8138. Do a command in all buffers or windows			*list-repeat*814 815							*:windo*816:[range]windo {cmd}	Execute {cmd} in each window or if [range] is given817			only in windows for which the window number lies in818			the [range].  It works like doing this: >819				CTRL-W t820				:{cmd}821				CTRL-W w822				:{cmd}823				etc.824<			This only operates in the current tab page.825			When an error is detected on one window, further826			windows will not be visited.827			The last window (or where an error occurred) becomes828			the current window.829			{cmd} can contain '|' to concatenate several commands.830			{cmd} must not open or close windows or reorder them.831 832			Also see |:tabdo|, |:argdo|, |:bufdo|, |:cdo|, |:ldo|,833			|:cfdo| and |:lfdo|834 835							*:bufdo*836:[range]bufdo[!] {cmd}	Execute {cmd} in each buffer in the buffer list or if837			[range] is given only for buffers for which their838			buffer number is in the [range].  It works like doing839			this: >840				:bfirst841				:{cmd}842				:bnext843				:{cmd}844				etc.845<			When the current file can't be |abandon|ed and the [!]846			is not present, the command fails.847			When an error is detected on one buffer, further848			buffers will not be visited.849			Unlisted buffers are skipped.850			The last buffer (or where an error occurred) becomes851			the current buffer.852			{cmd} can contain '|' to concatenate several commands.853			{cmd} must not delete buffers or add buffers to the854			buffer list.855			Note: While this command is executing, the Syntax856			autocommand event is disabled by adding it to857			'eventignore'.  This considerably speeds up editing858			each buffer.859 860			Also see |:tabdo|, |:argdo|, |:windo|, |:cdo|, |:ldo|,861			|:cfdo| and |:lfdo|862 863Examples: >864 865	:windo set nolist foldcolumn=0 | normal! zn866 867This resets the 'list' option and disables folding in all windows. >868 869	:bufdo set fileencoding= | update870 871This resets the 'fileencoding' in each buffer and writes it if this changed872the buffer.  The result is that all buffers will use the 'encoding' encoding873(if conversion succeeds).874 875==============================================================================8769. Tag or file name under the cursor			*window-tag*877 878							*:sta* *:stag*879:sta[g][!] [tagname]880		Does ":tag[!] [tagname]" and splits the window for the found881		tag.  Refer to 'switchbuf' to jump to a tag in a vertically882		split window or a new tab page.  See also |:tag|.883 884CTRL-W ]					*CTRL-W_]* *CTRL-W_CTRL-]*885CTRL-W CTRL-]	Split current window in two.  Use identifier under cursor as a886		tag and jump to it in the new upper window.887		In Visual mode uses the Visually selected text as a tag.888		Make new window N high.  Refer to 'switchbuf' to jump to a tag889		in a vertically split window or a new tab page.890 891							*CTRL-W_g]*892CTRL-W g ]	Split current window in two.  Use identifier under cursor as a893		tag and perform ":tselect" on it in the new upper window.894		In Visual mode uses the Visually selected text as a tag.895		Make new window N high.896 897							*CTRL-W_g_CTRL-]*898CTRL-W g CTRL-]	Split current window in two.  Use identifier under cursor as a899		tag and perform ":tjump" on it in the new upper window.900		In Visual mode uses the Visually selected text as a tag.901		Make new window N high.902 903CTRL-W f					*CTRL-W_f* *CTRL-W_CTRL-F*904CTRL-W CTRL-F	Split current window in two.  Edit file name under cursor.905		Like ":split gf", but window isn't split if the file does not906		exist.907		Uses the 'path' variable as a list of directory names where to908		look for the file.  Also the path for current file is909		used to search for the file name.910		If the name is a hypertext link that looks like911		"type://machine/path", only "/path" is used.912		If a count is given, the count'th matching file is edited.913 914CTRL-W F						*CTRL-W_F*915		Split current window in two.  Edit file name under cursor and916		jump to the line number following the file name.  See |gF| for917		details on how the line number is obtained.918 919CTRL-W gf						*CTRL-W_gf*920		Open a new tab page and edit the file name under the cursor.921		Like "tab split" and "gf", but the new tab page isn't created922		if the file does not exist.923 924CTRL-W gF						*CTRL-W_gF*925		Open a new tab page and edit the file name under the cursor926		and jump to the line number following the file name.  Like927		"tab split" and "gF", but the new tab page isn't created if928		the file does not exist.929 930CTRL-W gt						*CTRL-W_gt*931		Go to next tab page, same as `gt`.932 933CTRL-W gT						*CTRL-W_gT*934		Go to previous tab page, same as `gT`.935 936Also see |CTRL-W_CTRL-I|: open window for an included file that includes937the keyword under the cursor.938 939==============================================================================94010. The preview window				*preview-window*941 942The preview window is a special window to show (preview) another file.  It is943normally a small window used to show an include file or definition of a944function.945{not available when compiled without the |+quickfix| feature}946 947There can be only one preview window (per tab page).  It is created with one948of the commands below.  The 'previewheight' option can be set to specify the949height of the preview window when it's opened.  The 'previewwindow' option is950set in the preview window to be able to recognize it.  The 'winfixheight'951option is set to have it keep the same height when opening/closing other952windows.953						*preview-popup*954Alternatively, a popup window can be used by setting the 'previewpopup'955option.  When set, it overrules the 'previewwindow' and 'previewheight'956settings.  The option is a comma-separated list of values:957	border		border style (see 'pumborder')958	borderhighlight	highlight group for the popup border characters959	close		show close button: "on" (default) or "off", and if960			the value is "on", it must be set after border.961	height		maximum height of the popup962	highlight	highlight group of the popup (default is Pmenu)963	resize		show resize handle: "on" (default) or "off"964	shadow		"off" (default) or "on" using |hl-PmenuShadow|965	width		maximum width of the popup966 967Example: >968	:set previewpopup=height:10,width:60969	:set previewpopup=border:single,borderhilight:PmenuBorder970	:set previewpopup=border:custom:─;│;─;│;┌;┐;┘;└971 972A few peculiarities:973- If the file is in a buffer already, it will be re-used.  This will allow for974  editing the file while it's visible in the popup window.975- No ATTENTION dialog will be used, since you can't edit the file in the popup976  window.  However, if you later open the same buffer in a normal window, you977  may not notice it's edited elsewhere.  And when then using ":edit" to978  trigger the ATTENTION and responding "A" for Abort, the preview window will979  become empty.980 981						*:pt* *:ptag*982:pt[ag][!] [tagname]983		Does ":tag[!] [tagname]" and shows the found tag in a984		"Preview" window without changing the current buffer or cursor985		position.  If a "Preview" window already exists, it is re-used986		(like a help window is).  If a new one is opened,987		'previewheight' is used for the height of the window.   See988		also |:tag|.989		See below for an example. |CursorHold-example|990		Small difference from |:tag|: When [tagname] is equal to the991		already displayed tag, the position in the matching tag list992		is not reset.  This makes the CursorHold example work after a993		|:ptnext|.994 995CTRL-W z					*CTRL-W_z*996CTRL-W CTRL-Z					*CTRL-W_CTRL-Z* *:pc* *:pclose*997:pc[lose][!]	Close any "Preview" window currently open.  When the 'hidden'998		option is set, or when the buffer was changed and the [!] is999		used, the buffer becomes hidden (unless there is another1000		window editing it).  The command fails if any "Preview" buffer1001		cannot be closed.  See also |:close|.1002 1003							*:pp* *:ppop*1004:[count]pp[op][!]1005		Does ":[count]pop[!]" in the preview window.  See |:pop| and1006		|:ptag|.1007 1008CTRL-W }						*CTRL-W_}*1009		Use identifier under cursor as a tag and perform a :ptag on1010		it.  Make the new Preview window (if required) N high.  If N1011		is not given, 'previewheight' is used.1012 1013CTRL-W g }						*CTRL-W_g}*1014		Use identifier under cursor as a tag and perform a :ptjump on1015		it.  Make the new Preview window (if required) N high.  If N1016		is not given, 'previewheight' is used.1017 1018							*:pb* *:pbuffer*1019:[N]pb[uffer][!] [+cmd] [N]1020		Edit buffer [N] from the buffer list in the preview window.1021		If [N] is not given, the current buffer remains being edited.1022		See |:buffer-!| for [!].  This will also edit a buffer that is1023		not in the buffer list, without setting the 'buflisted' flag.1024		The notation with single quotes does not work here,1025		`:pbuffer 12'345'` uses 12'345' as a buffer name.1026		Also see |+cmd|.1027 1028							*:ped* *:pedit*1029:ped[it][!] [++opt] [+cmd] {file}1030		Edit {file} in the preview window.  The preview window is1031		opened like with |:ptag|.  The current window and cursor1032		position isn't changed.  Useful example: >1033			:pedit +/fputc /usr/include/stdio.h1034<1035		Also see |++opt| and |+cmd|.1036 1037							*:ps* *:psearch*1038:[range]ps[earch][!] [count] [/]pattern[/]1039		Works like |:ijump| but shows the found match in the preview1040		window.  The preview window is opened like with |:ptag|.  The1041		current window and cursor position isn't changed.  Useful1042		example: >1043			:psearch popen1044<		Like with the |:ptag| command, you can use this to1045		automatically show information about the word under the1046		cursor.  This is less clever than using |:ptag|, but you don't1047		need a tags file and it will also find matches in system1048		include files.  Example: >1049  :au! CursorHold *.[ch] ++nested exe "silent! psearch " .. expand("<cword>")1050<		Warning: This can be slow.1051 1052Example						*CursorHold-example*  >1053 1054  :au! CursorHold *.[ch] ++nested exe "silent! ptag " .. expand("<cword>")1055 1056This will cause a ":ptag" to be executed for the keyword under the cursor,1057when the cursor hasn't moved for the time set with 'updatetime'.  The "nested"1058makes other autocommands be executed, so that syntax highlighting works in the1059preview window.  The "silent!" avoids an error message when the tag could not1060be found.  Also see |CursorHold|.  To disable this again: >1061 1062  :au! CursorHold1063 1064A nice addition is to highlight the found tag, avoid the ":ptag" when there1065is no word under the cursor, and a few other things: >1066 1067  :au! CursorHold *.[ch] ++nested call PreviewWord()1068  :func PreviewWord()1069  :  if &previewwindow			" don't do this in the preview window1070  :    return1071  :  endif1072  :  let w = expand("<cword>")		" get the word under cursor1073  :  if w =~ '\a'			" if the word contains a letter1074  :1075  :    " Delete any existing highlight before showing another tag1076  :    silent! wincmd P			" jump to preview window1077  :    if &previewwindow		" if we really get there...1078  :      match none			" delete existing highlight1079  :      wincmd p			" back to old window1080  :    endif1081  :1082  :    " Try displaying a matching tag for the word under the cursor1083  :    try1084  :       exe "ptag " .. w1085  :    catch1086  :      return1087  :    endtry1088  :1089  :    silent! wincmd P			" jump to preview window1090  :    if &previewwindow		" if we really get there...1091  :	 if has("folding")1092  :	   silent! .foldopen		" don't want a closed fold1093  :	 endif1094  :	 call search("$", "b")		" to end of previous line1095  :	 let w = substitute(w, '\\', '\\\\', "")1096  :	 call search('\<\V' .. w .. '\>')	" position cursor on match1097  :	 " Add a match highlight to the word at this position1098  :      hi previewWord term=bold ctermbg=green guibg=green1099  :	 exe 'match previewWord "\%' .. line(".") .. 'l\%' .. col(".") .. 'c\k*"'1100  :      wincmd p			" back to old window1101  :    endif1102  :  endif1103  :endfun1104 1105==============================================================================110611. Using hidden buffers				*buffer-hidden*1107 1108A hidden buffer is not displayed in a window, but is still loaded into memory.1109This makes it possible to jump from file to file, without the need to read or1110write the file every time you get another buffer in a window.1111 1112							*:buffer-!*1113If the option 'hidden' ('hid') is set, abandoned buffers are kept for all1114commands that start editing another file: ":edit", ":next", ":tag", etc.  The1115commands that move through the buffer list sometimes make the current buffer1116hidden although the 'hidden' option is not set.  This happens when a buffer is1117modified, but is forced (with '!') to be removed from a window, and1118'autowrite' is off or the buffer can't be written.1119 1120You can make a hidden buffer not hidden by starting to edit it with any1121command, or by deleting it with the ":bdelete" command.1122 1123The 'hidden' is global, it is used for all buffers.  The 'bufhidden' option1124can be used to make an exception for a specific buffer.  It can take these1125values:1126	<empty>		Use the value of 'hidden'.1127	hide		Hide this buffer, also when 'hidden' is not set.1128	unload		Don't hide but unload this buffer, also when 'hidden'1129			is set.1130	delete		Delete the buffer.1131 1132							*hidden-quit*1133When you try to quit Vim while there is a hidden, modified buffer, you will1134get an error message and Vim will make that buffer the current buffer.  You1135can then decide to write this buffer (":wq") or quit without writing (":q!").1136Be careful: there may be more hidden, modified buffers!1137 1138A buffer can also be unlisted.  This means it exists, but it is not in the1139list of buffers. |unlisted-buffer|1140 1141 1142:files[!] [flags]				*:files*1143:buffers[!] [flags]				*:buffers* *:ls*1144:ls[!] [flags]1145		Show all buffers.  Example:1146 1147			1 #h   "/test/text"		line 1 ~1148			2u     "asdf"			line 0 ~1149			3 %a + "version.c"		line 1 ~1150 1151		When the [!] is included the list will show unlisted buffers1152		(the term "unlisted" is a bit confusing then...).1153 1154		Each buffer has a unique number.  That number will not change,1155		thus you can always go to a specific buffer with ":buffer N"1156		or "N CTRL-^", where N is the buffer number.1157 1158		For the file name these special values are used:1159			"[Prompt]"	|prompt-buffer|1160			"[Popup]"	buffer of a |popup-window|1161			"[Scratch]"	'buftype' is "nofile"1162			"[No Name]"	no file name specified1163		For a |terminal-window| buffer the status is used.1164 1165		Indicators (chars in the same column are mutually exclusive):1166		u	an unlisted buffer (only displayed when [!] is used)1167			   |unlisted-buffer|1168		 %	the buffer in the current window1169		 #	the alternate buffer for ":e #" and CTRL-^1170		  a	an active buffer: it is loaded and visible1171		  h	a hidden buffer: It is loaded, but currently not1172			   displayed in a window |hidden-buffer|1173		   -	a buffer with 'modifiable' off1174		   =	a readonly buffer1175		   R	a terminal buffer with a running job1176		   F	a terminal buffer with a finished job1177		   ?    a terminal buffer without a job: `:terminal NONE`1178		    +	a modified buffer1179		    x   a buffer with read errors1180 1181		[flags] can be a combination of the following characters,1182		which restrict the buffers to be listed:1183		     +   modified buffers1184		     -   buffers with 'modifiable' off1185		     =   readonly buffers1186		     a   active buffers1187		     u   unlisted buffers (overrides the "!")1188		     h   hidden buffers1189		     x   buffers with a read error1190		     %   current buffer1191		     #   alternate buffer1192		     R	 terminal buffers with a running job1193		     F	 terminal buffers with a finished job1194		     ?   terminal buffers without a job: `:terminal NONE`1195		     t   show time last used and sort buffers1196		Combining flags means they are "and"ed together, e.g.:1197		     h+   hidden buffers which are modified1198		     a+   active buffers which are modified1199 1200		When using |:filter| the pattern is matched against the

Showing the first 1,200 of 1480 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai