Window becomes unusable if the underlying Vim window is closed, so
check that valid is
True if there is any doubt. In practice, most code is
able to assume that the valid property is set.
Attributes and methods¶
Window class provides all the attributes and methods of Vim’s window
class. However some attribute types and return values are different. In such
cases, the VPE value is compatible with the Vim type. The differences are listed
in the folling table.
Window class also provides a number of additional properties and methods, including:
vpe module provides some context managers that support working with
saved_current_window context manager is useful when executing code that
might switch to another window.
with vpe.saved_current_window(): ... # May change current window, but that change will be undone when the # context exits. split_window_if_required()
If you need to temporarily swicth to a different window, use
with vpe.temp_active_window(alt_window): # Now vim.current.window will be alt_window for the duration of the # context. ...
Vim provides the functions winsaveview() and winrestview() as a
mechanism to ‘protect’ the user from operations that jump around a buffer. The
saved_winview context manager wraps these up more conventiently.
with vpe.saved_winview(): vim.command('$') ...