|
1 |
| -*windows.txt* For Vim version 9.0. Last change: 2022 May 11 |
| 1 | +*windows.txt* For Vim version 9.0. Last change: 2022 Nov 27 |
2 | 2 |
|
3 | 3 |
|
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar
|
@@ -189,7 +189,7 @@ CTRL-W v *CTRL-W_v*
|
189 | 189 | it doesn't!
|
190 | 190 |
|
191 | 191 | CTRL-W n *CTRL-W_n*
|
192 |
| -CTRL-W CTRL_N *CTRL-W_CTRL-N* |
| 192 | +CTRL-W CTRL-N *CTRL-W_CTRL-N* |
193 | 193 | :[N]new [++opt] [+cmd] *:new*
|
194 | 194 | Create a new window and start editing an empty file in it.
|
195 | 195 | Make new window N high (default is to use half the existing
|
@@ -631,6 +631,56 @@ it).
|
631 | 631 | The minimal height and width of a window is set with 'winminheight' and
|
632 | 632 | 'winminwidth'. These are hard values, a window will never become smaller.
|
633 | 633 |
|
| 634 | + |
| 635 | +WinScrolled and WinResized autocommands ~ |
| 636 | + *win-scrolled-resized* |
| 637 | +If you want to get notified of changes in window sizes, the |WinResized| |
| 638 | +autocommand event can be used. |
| 639 | +If you want to get notified of text in windows scrolling vertically or |
| 640 | +horizontally, the |WinScrolled| autocommand event can be used. This will also |
| 641 | +trigger in window size changes. |
| 642 | +Exception: the events will not be triggered when the text scrolls for |
| 643 | +'incsearch'. |
| 644 | + *WinResized-event* |
| 645 | +The |WinResized| event is triggered after updating the display, several |
| 646 | +windows may have changed size then. A list of the IDs of windows that changed |
| 647 | +since last time is provided in the v:event.windows variable, for example: |
| 648 | + [1003, 1006] |
| 649 | + *WinScrolled-event* |
| 650 | +The |WinScrolled| event is triggered after |WinResized|, and also if a window |
| 651 | +was scrolled. That can be vertically (the text at the top of the window |
| 652 | +changed) or horizontally (when 'wrap' is off or when the first displayed part |
| 653 | +of the first line changes). Note that |WinScrolled| will trigger many more |
| 654 | +times than |WinResized|, it may slow down editing a bit. |
| 655 | + |
| 656 | +The information provided by |WinScrolled| is a dictionary for each window that |
| 657 | +has changes, using the window ID as the key, and a total count of the changes |
| 658 | +with the key "all". Example value for |v:event| (|Vim9| syntax): |
| 659 | + { |
| 660 | + all: {width: 0, height: 2, leftcol: 0, skipcol: 0, topline: 1, topfill: 0}, |
| 661 | + 1003: {width: 0, height: -1, leftcol: 0, skipcol: 0, topline: 0, topfill: 0}, |
| 662 | + 1006: {width: 0, height: 1, leftcol: 0, skipcol: 0, topline: 1, topfill: 0}, |
| 663 | + } |
| 664 | + |
| 665 | +Note that the "all" entry has the absolute values of the individual windows |
| 666 | +accumulated. |
| 667 | + |
| 668 | +If you need more information about what changed, or you want to "debounce" the |
| 669 | +events (not handle every event to avoid doing too much work), you may want to |
| 670 | +use the `winlayout()` and `getwininfo()` functions. |
| 671 | + |
| 672 | +|WinScrolled| and |WinResized| do not trigger when the first autocommand is |
| 673 | +added, only after the first scroll or resize. They may trigger when switching |
| 674 | +to another tab page. |
| 675 | + |
| 676 | +The commands executed are expected to not cause window size or scroll changes. |
| 677 | +If this happens anyway, the event will trigger again very soon. In other |
| 678 | +words: Just before triggering the event, the current sizes and scroll |
| 679 | +positions are stored and used to decide whether there was a change. |
| 680 | + *E1312* |
| 681 | +It is not allowed to change the window layout here (split, close or move |
| 682 | +windows). |
| 683 | + |
634 | 684 | ==============================================================================
|
635 | 685 | 7. Argument and buffer list commands *buffer-list*
|
636 | 686 |
|
|
0 commit comments