Home Explore Blog CI



neovim

7th chunk of `runtime/doc/usr_41.txt`
31b57e60d9afca8ef9b9fd402967f59ba5f7910fc4306e7c0000000100000fa2

the line where the cursor is.
   The substitute() function does something similar to the ":substitute"
command.  The first argument is the string on which to perform the
substitution.  The second argument is the pattern, the third the replacement
string.  Finally, the last arguments are the flags.
   The setline() function sets the line, specified by the first argument, to a
new string, the second argument.  In this example the line under the cursor is
replaced with the result of the substitute().  Thus the effect of the three
statements is equal to: >

	:substitute/\a/*/g

Using the functions becomes interesting when you do more work before and
after the substitute() call.


FUNCTIONS						*function-list*

There are many functions.  We will mention them here, grouped by what they are
used for.  You can find an alphabetical list here: |builtin-function-details|.
Use CTRL-] on the function name to jump to detailed help on it.

String manipulation:					*string-functions*
	nr2char()		get a character by its number value
	list2str()		get a character string from a list of numbers
	char2nr()		get number value of a character
	str2list()		get list of numbers from a string
	str2nr()		convert a string to a Number
	str2float()		convert a string to a Float
	printf()		format a string according to % items
	escape()		escape characters in a string with a '\'
	shellescape()		escape a string for use with a shell command
	fnameescape()		escape a file name for use with a Vim command
	tr()			translate characters from one set to another
	strtrans()		translate a string to make it printable
	keytrans()		translate internal keycodes to a form that
				can be used by |:map|
	tolower()		turn a string to lowercase
	toupper()		turn a string to uppercase
	charclass()		class of a character
	match()			position where a pattern matches in a string
	matchbufline()		all the matches of a pattern in a buffer
	matchend()		position where a pattern match ends in a string
	matchfuzzy()		fuzzy matches a string in a list of strings
	matchfuzzypos()		fuzzy matches a string in a list of strings
	matchstr()		match of a pattern in a string
	matchstrlist()		all the matches of a pattern in a List of
				strings
	matchstrpos()		match and positions of a pattern in a string
	matchlist()		like matchstr() and also return submatches
	stridx()		first index of a short string in a long string
	strridx()		last index of a short string in a long string
	strlen()		length of a string in bytes
	strcharlen()		length of a string in characters
	strchars()		number of characters in a string
	strutf16len()		number of UTF-16 code units in a string
	strwidth()		size of string when displayed
	strdisplaywidth()	size of string when displayed, deals with tabs
	setcellwidths()		set character cell width overrides
	getcellwidths()		get character cell width overrides
	reverse()		reverse the order of characters in a string
	substitute()		substitute a pattern match with a string
	submatch()		get a specific match in ":s" and substitute()
	strpart()		get part of a string using byte index
	strcharpart()		get part of a string using char index
	slice()			take a slice of a string, using char index in
				Vim9 script
	strgetchar()		get character from a string using char index
	expand()		expand special keywords
	expandcmd()		expand a command like done for `:edit`
	iconv()			convert text from one encoding to another
	byteidx()		byte index of a character in a string
	byteidxcomp()		like byteidx() but count composing characters
	charidx()		character index of a byte in a string
	utf16idx()		UTF-16 index of a byte in a string
	repeat()		repeat a string multiple times
	eval()			evaluate a string expression
	execute()		execute an Ex command and get the output
	win_execute()		like execute() but in a specified window
	trim()			trim characters from a string
	gettext()		lookup message translation

List manipulation:					*list-functions*
	get()			get an item without error for wrong index
	len()			number of items in a List
	empty()

Title: String and List Manipulation Functions in Vim
Summary
This section details Vim's functions for string and list manipulation. It describes how functions like getline(), substitute(), and setline() work together and highlights the importance of combining functions for more complex tasks. It then provides an extensive list of string manipulation functions, including nr2char(), list2str(), char2nr(), and many others, each designed for tasks like character conversion, string formatting, escaping, translation, case conversion, pattern matching, string indexing, length calculation, substring extraction, expansion, encoding conversion, string repetition, and evaluation. The section also touches on list manipulation functions, mentioning get(), len(), and empty().