Home Explore Blog CI



neovim

2nd chunk of `runtime/doc/if_perl.txt`
6093bf76f24133b7181800fb6c4940afa6ddccdcaba3a1c60000000100000b60
 gets all of its access to Nvim via the "VIM" module.

Overview >
	print "Hello"				# displays a message
	VIM::Msg("Hello")			# displays a message
	VIM::SetOption("ai")			# sets a vim option
	$nbuf = VIM::Buffers()			# returns the number of buffers
	@buflist = VIM::Buffers()		# returns array of all buffers
	$mybuf = (VIM::Buffers('a.c'))[0]	# returns buffer object for 'a.c'
	@winlist = VIM::Windows()		# returns array of all windows
	$nwin = VIM::Windows()			# returns the number of windows
	($success, $v) = VIM::Eval('&path')	# $v: option 'path', $success: 1
	($success, $v) = VIM::Eval('&xyz')	# $v: '' and $success: 0
	$v = VIM::Eval('expand("<cfile>")')	# expands <cfile>
	$curwin->SetHeight(10)			# sets the window height
	@pos = $curwin->Cursor()		# returns (row, col) array
	@pos = (10, 10)
	$curwin->Cursor(@pos)			# sets cursor to @pos
	$curwin->Cursor(10,10)			# sets cursor to row 10 col 10
	$mybuf = $curwin->Buffer()		# returns the buffer object for window
	$curbuf->Name()				# returns buffer name
	$curbuf->Number()			# returns buffer number
	$curbuf->Count()			# returns the number of lines
	$l = $curbuf->Get(10)			# returns line 10
	@l = $curbuf->Get(1 .. 5)		# returns lines 1 through 5
	$curbuf->Delete(10)			# deletes line 10
	$curbuf->Delete(10, 20)			# delete lines 10 through 20
	$curbuf->Append(10, "Line")		# appends a line
	$curbuf->Append(10, "L1", "L2", "L3")	# appends 3 lines
	@l = ("L1", "L2", "L3")
	$curbuf->Append(10, @l)			# appends L1, L2 and L3
	$curbuf->Set(10, "Line")		# replaces line 10
	$curbuf->Set(10, "Line1", "Line2")	# replaces lines 10 and 11
	$curbuf->Set(10, @l)			# replaces 3 lines

Module Functions:

							*perl-Msg*
VIM::Msg({msg})
			Displays the message {msg}.

							*perl-SetOption*
VIM::SetOption({arg})	Sets a vim option.  {arg} can be any argument that the
			":set" command accepts.  Note that this means that no
			spaces are allowed in the argument!  See |:set|.

							*perl-Buffers*
VIM::Buffers([{bn}...])	With no arguments, returns a list of all the buffers
			in an array context or returns the number of buffers
			in a scalar context.  For a list of buffer names or
			numbers {bn}, returns a list of the buffers matching
			{bn}, using the same rules as Vim's internal
			|bufname()| function.
			WARNING: the list becomes invalid when |:bwipe| is
			used.

							*perl-Windows*
VIM::Windows([{wn}...])	With no arguments, returns a list of all the windows
			in an array context or returns the number of windows
			in a scalar context.  For a list of window numbers
			{wn}, returns a list of the windows with those
			numbers.
			WARNING: the list becomes invalid when a window is
			closed.

							*perl-DoCommand*
VIM::DoCommand({cmd})	Executes Ex command {cmd}.

							*perl-Eval*
VIM::Eval({expr})	Evaluates {expr} and returns (success, value) in list
			context or just value in scalar context.
			success=1 indicates that

Title: The VIM Module: Functions and Overview
Summary
This section details the VIM module, which allows Perl code to interact with Neovim. It provides an overview of key functions, including displaying messages (`VIM::Msg`), setting options (`VIM::SetOption`), managing buffers (`VIM::Buffers`) and windows (`VIM::Windows`), executing Ex commands (`VIM::DoCommand`), and evaluating expressions (`VIM::Eval`). The summary includes examples of retrieving and manipulating buffer content, such as getting, deleting, appending, and setting lines, as well as specific function descriptions with their arguments and return values.