Home Explore Blog CI



neovim

89th chunk of `runtime/doc/vimfn.txt`
00bf062edb1ab5c1d2da9b1915d68b98759cf4d00871d2a50000000100000faf
                Parameters: ~
                  • {path} (`string`)
                  • {len} (`integer?`)

                Return: ~
                  (`string`)

perleval({expr})                                                    *perleval()*
		Evaluate |perl| expression {expr} and return its result
		converted to Vim data structures.
		Numbers and strings are returned as they are (strings are
		copied though).
		Lists are represented as Vim |List| type.
		Dictionaries are represented as Vim |Dictionary| type,
		non-string keys result in error.

		Note: If you want an array or hash, {expr} must return a
		reference to it.
		Example: >vim
			echo perleval('[1 .. 4]')
<			[1, 2, 3, 4]

                Parameters: ~
                  • {expr} (`any`)

                Return: ~
                  (`any`)

pow({x}, {y})                                                            *pow()*
		Return the power of {x} to the exponent {y} as a |Float|.
		{x} and {y} must evaluate to a |Float| or a |Number|.
		Returns 0.0 if {x} or {y} is not a |Float| or a |Number|.
		Examples: >vim
			echo pow(3, 3)
<			27.0 >vim
			echo pow(2, 16)
<			65536.0 >vim
			echo pow(32, 0.20)
<			2.0

                Parameters: ~
                  • {x} (`number`)
                  • {y} (`number`)

                Return: ~
                  (`number`)

prevnonblank({lnum})                                            *prevnonblank()*
		Return the line number of the first line at or above {lnum}
		that is not blank.  Example: >vim
			let ind = indent(prevnonblank(v:lnum - 1))
<		When {lnum} is invalid or there is no non-blank line at or
		above it, zero is returned.
		{lnum} is used like with |getline()|.
		Also see |nextnonblank()|.

                Parameters: ~
                  • {lnum} (`integer|string`)

                Return: ~
                  (`integer`)

printf({fmt}, {expr1} ...)                                            *printf()*
		Return a String with {fmt}, where "%" items are replaced by
		the formatted form of their respective arguments.  Example: >vim
			echo printf("%4d: E%d %.30s", lnum, errno, msg)
<		May result in:
			"  99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~

		When used as a |method| the base is passed as the second
		argument: >vim
			Compute()->printf("result: %d")
<
		You can use `call()` to pass the items as a list.

		Often used items are:
		  %s	string
		  %6S	string right-aligned in 6 display cells
		  %6s	string right-aligned in 6 bytes
		  %.9s	string truncated to 9 bytes
		  %c	single byte
		  %d	decimal number
		  %5d	decimal number padded with spaces to 5 characters
		  %b	binary number
		  %08b	binary number padded with zeros to at least 8 characters
		  %B	binary number using upper case letters
		  %x	hex number
		  %04x	hex number padded with zeros to at least 4 characters
		  %X	hex number using upper case letters
		  %o	octal number
		  %f	floating point number as 12.23, inf, -inf or nan
		  %F	floating point number as 12.23, INF, -INF or NAN
		  %e	floating point number as 1.23e3, inf, -inf or nan
		  %E	floating point number as 1.23E3, INF, -INF or NAN
		  %g	floating point number, as %f or %e depending on value
		  %G	floating point number, as %F or %E depending on value
		  %%	the % character itself
		  %p	representation of the pointer to the container

		Conversion specifications start with '%' and end with the
		conversion type.  All other characters are copied unchanged to
		the result.

		The "%" starts a conversion specification.  The following
		arguments appear in sequence:

			% [pos-argument] [flags] [field-width] [.precision] type

		pos-argument
			At most one positional argument specifier. These
			take the form {n$}, where n is >= 1.

		flags
			Zero or more of the following flags:

		    #	      The value should be converted to an "alternate
			      form".  For c, d, and s conversions, this option
			      has no effect.  For o conversions, the precision
			      of the number is increased to force

Title: perleval, pow, prevnonblank, and printf Functions
Summary
This section describes the `perleval({expr})` function, which evaluates a Perl expression and converts the result to Vim data structures; the `pow({x}, {y})` function, which returns the power of {x} to the exponent {y}; the `prevnonblank({lnum})` function, which returns the line number of the first non-blank line at or above {lnum}; and the `printf({fmt}, {expr1} ...)` function, which returns a formatted string, similar to the C `printf` function.