Home Explore Blog CI



neovim

91th chunk of `runtime/doc/vimfn.txt`
2fbbb197ee9bf38fb0f2ea68bc6f5d65476d2facf6a730e50000000100000fa4
 applied, see below.

		A field width or precision, or both, may be indicated by an
		asterisk "*" instead of a digit string.  In this case, a
		Number argument supplies the field width or precision.  A
		negative field width is treated as a left adjustment flag
		followed by a positive field width; a negative precision is
		treated as though it were missing.  Example: >vim
			echo printf("%d: %.*s", nr, width, line)
<		This limits the length of the text used from "line" to
		"width" bytes.

		If the argument to be formatted is specified using a
		positional argument specifier, and a '*' is used to indicate
		that a number argument is to be used to specify the width or
		precision, the argument(s) to be used must also be specified
		using a {n$} positional argument specifier. See |printf-$|.

		The conversion specifiers and their meanings are:

				*printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X*
		dbBoxX	The Number argument is converted to signed decimal (d),
			unsigned binary (b and B), unsigned octal (o), or
			unsigned hexadecimal (x and X) notation.  The letters
			"abcdef" are used for x conversions; the letters
			"ABCDEF" are used for X conversions.  The precision, if
			any, gives the minimum number of digits that must
			appear; if the converted value requires fewer digits, it
			is padded on the left with zeros.  In no case does a
			non-existent or small field width cause truncation of a
			numeric field; if the result of a conversion is wider
			than the field width, the field is expanded to contain
			the conversion result.
			The 'h' modifier indicates the argument is 16 bits.
			The 'l' modifier indicates the argument is a long
			integer.  The size will be 32 bits or 64 bits
			depending on your platform.
			The "ll" modifier indicates the argument is 64 bits.
			The b and B conversion specifiers never take a width
			modifier and always assume their argument is a 64 bit
			integer.
			Generally, these modifiers are not useful. They are
			ignored when type is known from the argument.

		i	alias for d
		D	alias for ld
		U	alias for lu
		O	alias for lo

							*printf-c*
		c	The Number argument is converted to a byte, and the
			resulting character is written.

							*printf-s*
		s	The text of the String argument is used.  If a
			precision is specified, no more bytes than the number
			specified are used.
			If the argument is not a String type, it is
			automatically converted to text with the same format
			as ":echo".
							*printf-S*
		S	The text of the String argument is used.  If a
			precision is specified, no more display cells than the
			number specified are used.

							*printf-f* *E807*
		f F	The Float argument is converted into a string of the
			form 123.456.  The precision specifies the number of
			digits after the decimal point.  When the precision is
			zero the decimal point is omitted.  When the precision
			is not specified 6 is used.  A really big number
			(out of range or dividing by zero) results in "inf"
			 or "-inf" with %f (INF or -INF with %F).
			 "0.0 / 0.0" results in "nan" with %f (NAN with %F).
			Example: >vim
				echo printf("%.2f", 12.115)
<				12.12
			Note that roundoff depends on the system libraries.
			Use |round()| when in doubt.

							*printf-e* *printf-E*
		e E	The Float argument is converted into a string of the
			form 1.234e+03 or 1.234E+03 when using 'E'.  The
			precision specifies the number of digits after the
			decimal point, like with 'f'.

							*printf-g* *printf-G*
		g G	The Float argument is converted like with 'f' if the
			value is between 0.001 (inclusive) and 10000000.0
			(exclusive).  Otherwise 'e' is used for 'g' and 'E'
			for 'G'.  When no precision is specified superfluous
			zeroes and '+' signs are removed, except for the zero
			immediately after the decimal point.  Thus 10000000.0
			results in 1.0e7.

							*printf-%*
		%	A '%' is written.  No argument is converted.  The
			complete conversion specification is "%%".

Title: printf Conversion Specifiers and Their Meanings
Summary
This section details the conversion specifiers for the `printf` function, including `d, b, B, o, x, X, c, s, S, f, F, e, E, g, G, and %`. It explains how each specifier converts and formats different types of arguments (Number, String, Float), including handling precision, field width, and modifiers like 'h', 'l', and 'll'. The section also covers special cases such as NaN and Infinity for floating-point numbers.