Home Explore Blog CI



neovim

3rd chunk of `runtime/doc/if_pyth.txt`
e6c224b33b4dd2652737e4200e1e51f1e08596f46dc51fa80000000100000fa4
	*python-foreach_rtp*
	Call the given callable for each path in 'runtimepath' until either
	callable returns something but None, the exception is raised or there
	are no longer paths. If stopped in case callable returned non-None,
	vim.foreach_rtp function returns the value returned by callable.

`vim.chdir(*args, **kwargs)`				*python-chdir*
`vim.fchdir(*args, **kwargs)`				*python-fchdir*
	Run os.chdir or os.fchdir, then all appropriate vim stuff.
	Note: you should not use these functions directly, use os.chdir and
	      os.fchdir instead. Behavior of vim.fchdir is undefined in case
	      os.fchdir does not exist.

Error object of the "vim" module

vim.error						*python-error*
	Upon encountering a Vim error, Python raises an exception of type
	vim.error.
	Example: >python
		try:
			vim.command("put a")
		except vim.error:
			# nothing in register a

Constants of the "vim" module

	Note that these are not actually constants - you could reassign them.
	But this is silly, as you would then lose access to the vim objects
	to which the variables referred.

vim.buffers						*python-buffers*
	A mapping object providing access to the list of vim buffers.  The
	object supports the following operations: >vim
	    :py b = vim.buffers[i]	# Indexing (read-only)
	    :py b in vim.buffers	# Membership test
	    :py n = len(vim.buffers)	# Number of elements
	    :py for b in vim.buffers:	# Iterating over buffer list
<
vim.windows						*python-windows*
	A sequence object providing access to the list of vim windows.  The
	object supports the following operations: >vim
	    :py w = vim.windows[i]	# Indexing (read-only)
	    :py w in vim.windows	# Membership test
	    :py n = len(vim.windows)	# Number of elements
	    :py for w in vim.windows:	# Sequential access
<	Note: vim.windows object always accesses current tab page.
	|python-tabpage|.windows objects are bound to parent |python-tabpage|
	object and always use windows from that tab page (or throw vim.error
	in case tab page was deleted). You can keep a reference to both
	without keeping a reference to vim module object or |python-tabpage|,
	they will not lose their properties in this case.

vim.tabpages						*python-tabpages*
	A sequence object providing access to the list of vim tab pages. The
	object supports the following operations: >vim
	    :py t = vim.tabpages[i]	# Indexing (read-only)
	    :py t in vim.tabpages	# Membership test
	    :py n = len(vim.tabpages)	# Number of elements
	    :py for t in vim.tabpages:	# Sequential access
<
vim.current						*python-current*
	An object providing access (via specific attributes) to various
	"current" objects available in vim:
		vim.current.line	The current line (RW)		String
		vim.current.buffer	The current buffer (RW)		Buffer
		vim.current.window	The current window (RW)		Window
		vim.current.tabpage	The current tab page (RW)	TabPage
		vim.current.range	The current line range (RO)	Range

	The last case deserves a little explanation.  When the :python or
	:pyfile command specifies a range, this range of lines becomes the
	"current range".  A range is a bit like a buffer, but with all access
	restricted to a subset of lines.  See |python-range| for more details.

	Note: When assigning to vim.current.{buffer,window,tabpage} it expects
	valid |python-buffer|, |python-window| or |python-tabpage| objects
	respectively. Assigning triggers normal (with |autocommand|s)
	switching to given buffer, window or tab page. It is the only way to
	switch UI objects in python: you can't assign to
	|python-tabpage|.window attribute. To switch without triggering
	autocommands use >vim
	    py << EOF
	    saved_eventignore = vim.options['eventignore']
	    vim.options['eventignore'] = 'all'
	    try:
	        vim.current.buffer = vim.buffers[2] # Switch to buffer 2
	    finally:
	        vim.options['eventignore'] = saved_eventignore
	    EOF
<
vim.vars						*python-vars*
vim.vvars						*python-vvars*
	Dictionary-like objects holding dictionaries with global (|g:|)

Title: NVim Python Interface: Further `vim` Module Details - `foreach_rtp`, `chdir`, `error`, and Constants
Summary
This section details more aspects of the `vim` module, including: `vim.foreach_rtp()`, `vim.chdir()` and `vim.fchdir()`. It describes the `vim.error` exception raised upon encountering a Vim error. It outlines the constants within the `vim` module, such as `vim.buffers`, `vim.windows`, `vim.tabpages`, `vim.current`, `vim.vars`, and `vim.vvars`, which provide access to Vim's buffers, windows, tab pages, current objects, and variables. It explains how to interact with these constants, including indexing, membership testing, and iteration, with notes on their specific behaviors and constraints.