Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
usr_41.txt2011 linesDownload Raw Back to doc
1*usr_41.txt*	For Vim version 9.2.  Last change: 2026 Feb 162 3 4		     VIM USER MANUAL	by Bram Moolenaar5 6 7			      Write a Vim script8 9 10The Vim script language is used for the startup vimrc file, syntax files, and11many other things.  This chapter explains the items that can be used in a Vim12script.  There are a lot of them, therefore this is a long chapter.13 14|41.1|	Introduction15|41.2|	Variables16|41.3|	Expressions17|41.4|	Conditionals18|41.5|	Executing an expression19|41.6|	Using functions20|41.7|	Defining a function21|41.8|	Lists and Dictionaries22|41.9|	White space23|41.10|	Line continuation24|41.11|	Comments25|41.12|	Fileformat26 27     Next chapter: |usr_42.txt|  Add new menus28 Previous chapter: |usr_40.txt|  Make new commands29Table of contents: |usr_toc.txt|30 31==============================================================================32*41.1*	Introduction				*vim-script-intro* *script*33 34Let's start with some nomenclature. A Vim script is any file that Vim can35interpret and execute.  This includes files written in Vim's scripting36language like for example .vim files or configuration files like .vimrc and37.gvimrc.  These scripts may define functions, commands and settings that Vim38uses to customize and extend its behavior.39 40						*vim-script-notation*41The correct notation is "Vim script" (or "Vim9 script" when referring to the42new Vim9 language |Vim9-script|), so we will use "Vim script" to refer to the43Vim scripting language throughout this documentation. This shorthand helps to44streamline explanations and discussions about scripting with Vim.45 46A Vim plugin is a collection of one or more Vim scripts, along with additional47files like help documentation, configuration files, and other resources,48designed to add specific features or functionalities to Vim. A plugin can49provide new commands, enhance existing capabilities, and integrate external50tools or services into the Vim environment.51 52Your first experience with Vim scripts is the vimrc file.  Vim reads it when53it starts up and executes the commands.  You can set options to the values you54prefer, define mappings, select plugins and much more.   You can use any colon55command in it (commands that start with a ":"; these are sometimes referred to56as Ex commands or command-line commands).57 58Syntax files are also Vim scripts.  As are files that set options for a59specific file type.  A complicated macro can be defined by a separate Vim60script file.  You can think of other uses yourself.61 62Vim script comes in two flavors: legacy and |Vim9|.  Since this help file is63for new users, we'll teach you the newer and more convenient |Vim9| syntax.64While legacy script is particularly for Vim, |Vim9| script looks more like65other languages, such as JavaScript and TypeScript.66 67To try out Vim script the best way is to edit a script file and source it.68Basically: >69	:edit test.vim70	[insert the script lines you want]71	:w72	:source %73 74Let's start with a simple example: >75 76	vim9script77	var i = 178	while i < 579	  echo "count is" i80	  i += 181	endwhile82<83The output of the example code is:84 85	count is 1 ~86	count is 2 ~87	count is 3 ~88	count is 4 ~89 90In the first line the `vim9script` command makes clear this is a new, |Vim9|91script file.  That matters for how the rest of the file is used.  It is92recommended to put it in the very first line, before any comments.93							*vim9-declarations*94The `var i = 1` command declares the "i" variable and initializes it.  The95generic form is: >96 97	var {name} = {expression}98 99In this case the variable name is "i" and the expression is a simple value,100the number one.101 102The `while` command starts a loop.  The generic form is: >103 104	while {condition}105	  {statements}106	endwhile107 108The statements until the matching `endwhile` are executed for as long as the109condition is true.  The condition used here is the expression "i < 5".  This110is true when the variable i is smaller than five.111	Note:112	If you happen to write a while loop that keeps on running, you can113	interrupt it by pressing CTRL-C (CTRL-Break on MS-Windows).114 115The `echo` command prints its arguments.  In this case the string "count is"116and the value of the variable i.  Since i is one, this will print:117 118	count is 1 ~119 120Then there is the `i += 1` command.  This does the same thing as "i = i + 1",121it adds one to the variable i and assigns the new value to the same variable.122 123The example was given to explain the commands, but would you really want to124make such a loop, it can be written much more compact: >125 126	for i in range(1, 4)127	  echo $"count is {i}"128	endfor129 130We won't explain how `for`, `range()` and `$"string"` work until later.131Follow the links if you are impatient.132 133 134TRYING OUT EXAMPLES135 136You can easily try out most examples in these help files without saving the137commands to a file.  For example, to try out the "for" loop above do this:1381. position the cursor on the "for"1392. start Visual mode with "v"1403. move down to the "endfor"1414. press colon, then "so" and Enter142 143After pressing colon you will see ":'<,'>", which is the range of the Visually144selected text.145 146For some commands it matters they are executed as in |Vim9| script.  But typed147commands normally use legacy script syntax, such as the example below that148causes the E1004 error.  For that use this fourth step:1494. press colon, then "vim9 so" and Enter150 151"vim9" is short for `vim9cmd`, which is a command modifier to execute the152following command in |Vim9| syntax.153 154Note that this won't work for examples that require a script context.155 156 157FOUR KINDS OF NUMBERS158 159Numbers can be decimal, hexadecimal, octal and binary.160 161A hexadecimal number starts with "0x" or "0X".  For example "0x1f" is decimal16231 and "0x1234" is decimal 4660.163 164An octal number starts with "0o", "0O".  "0o17" is decimal 15.165 166A binary number starts with "0b" or "0B".  For example "0b101" is decimal 5.167 168A decimal number is just digits.  Careful: In legacy script don't put a zero169before a decimal number, it will be interpreted as an octal number!  That's170one reason to use |Vim9| script.171 172The `echo` command evaluates its argument and when it is a number always173prints the decimal form.  Example: >174 175	echo 0x7f 0o36176<	127 30 ~177 178A number is made negative with a minus sign.  This also works for hexadecimal,179octal and binary numbers: >180 181	echo -0x7f182<	-127 ~183 184A minus sign is also used for subtraction.  This can sometimes lead to185confusion.  If we put a minus sign before both numbers we get an error: >186 187	echo -0x7f -0o36188<	E1004: White space required before and after '-' at "-0o36" ~189 190Note: if you are not using a |Vim9| script to try out these commands but type191them directly, they will be executed as legacy script.  Then the echo command192sees the second minus sign as subtraction.  To get the error, prefix the193command with `vim9cmd`: >194 195	vim9cmd echo -0x7f -0o36196<	E1004: White space required before and after '-' at "-0o36" ~197 198White space in an expression is often required to make sure it is easy to read199and avoid errors.  Such as thinking that the "-0o36" above makes the number200negative, while it is actually seen as a subtraction.201 202To actually have the minus sign be used for negation, you can put the second203expression in parentheses: >204 205	echo -0x7f (-0o36)206<	-127 -30 ~207 208==============================================================================209*41.2*	Variables210 211A variable name consists of ASCII letters, digits and the underscore.  It212cannot start with a digit.  Valid variable names are:213 214	counter215	_aap3216	very_long_variable_name_with_underscores217	CamelCaseName218	LENGTH219 220Invalid names are "foo.bar" and "6var".221 222Some variables are global.  To see a list of currently defined global223variables type this command: >224 225	:let226 227You can use global variables everywhere.  However, it is too easy to use the228same name in two unrelated scripts.  Therefore variables declared in a script229are local to that script.  For example, if you have this in "script1.vim": >230 231	vim9script232	var counter = 5233	echo counter234<	5 ~235 236And you try to use the variable in "script2.vim": >237 238	vim9script239	echo counter240<	E121: Undefined variable: counter ~241 242Using a script-local variable means you can be sure that it is only changed in243that script and not elsewhere.244 245If you do want to share variables between scripts, use the "g:" prefix and246assign the value directly, do not use `var`.  And use a specific name to avoid247mistakes.  Thus in "script1.vim": >248 249	vim9script250	g:mash_counter = 5251	echo g:mash_counter252<	5 ~253 254And then in "script2.vim": >255 256	vim9script257	echo g:mash_counter258<	5 ~259 260Global variables can also be accessed on the command line, E.g. typing this: >261	echo g:mash_counter262That will not work for a script-local variable.263 264More about script-local variables here: |script-variable|.265 266There are more kinds of variables, see |internal-variables|.  The most often267used ones are:268 269	b:name		variable local to a buffer270	w:name		variable local to a window271	g:name		global variable (also in a function)272	v:name		variable predefined by Vim273 274 275DELETING VARIABLES276 277Variables take up memory and show up in the output of the `let` command.  To278delete a global variable use the `unlet` command.  Example: >279 280	unlet g:counter281 282This deletes the global variable "g:counter" to free up the memory it uses.283If you are not sure if the variable exists, and don't want an error message284when it doesn't, append !: >285 286	unlet! g:counter287 288You cannot `unlet` script-local variables in |Vim9| script, only in legacy289script.290 291When a script has been processed to the end, the local variables declared292there will not be deleted.  Functions defined in the script can use them.293Example:294>295	vim9script296	var counter = 0297	def g:GetCount(): number298	  counter += 1299	  return counter300	enddef301 302Every time you call the function it will return the next count: >303	:echo g:GetCount()304<	1 ~305>306	:echo g:GetCount()307<	2 ~308 309If you are worried a script-local variable is consuming too much memory, set310it to an empty or null value after you no longer need it.  Example: >311	var lines = readfile(...)312	...313	lines = []314 315Note: below we'll leave out the `vim9script` line from examples, so we can316concentrate on the relevant commands, but you'll still need to put it at the317top of your script file.318 319 320STRING VARIABLES AND CONSTANTS321 322So far only numbers were used for the variable value.  Strings can be used as323well.  Numbers and strings are the basic types of variables that Vim supports.324Example: >325 326	var name = "Peter"327	echo name328<	Peter ~329 330Every variable has a type.  Very often, as in this example, the type is331defined by assigning a value.  This is called type inference.  If you do not332want to give the variable a value yet, you need to specify the type: >333 334	var name: string335	var age: number336	if male337	   name = "Peter"338	   age = 42339	else340	   name = "Elisa"341	   age = 45342	endif343 344If you make a mistake and try to assign the wrong type of value you'll get an345error: >346 347	age = "Peter"348<	E1012: Type mismatch; expected number but got string ~349 350More about types in |41.8|.351 352To assign a string value to a variable, you can use a string constant.  There353are two types of these.  First the string in double quotes, as we used354already.  If you want to include a double quote inside the string, put a355backslash in front of it: >356 357	var name = "he is \"Peter\""358	echo name359<	he is "Peter" ~360 361To avoid the need for backslashes, you can use a string in single quotes: >362 363	var name = 'he is "Peter"'364	echo name365<	he is "Peter" ~366 367Inside a single-quote string all the characters are as they are.  Only the368single quote itself is special: you need to use two to get one.  A backslash369is taken literally, thus you can't use it to change the meaning of the370character after it: >371 372	var name = 'P\e''ter'''373	echo name374<	P\e'ter' ~375 376In double-quote strings it is possible to use special characters.  Here are a377few useful ones:378 379	\t		<Tab>380	\n		<NL>, line break381	\r		<CR>, <Enter>382	\e		<Esc>383	\b		<BS>, backspace384	\"		"385	\\		\, backslash386	\<Esc>		<Esc>387	\<C-W>		CTRL-W388 389The last two are just examples.  The  "\<name>" form can be used to include390the special key "name".391 392See |expr-quote| for the full list of special items in a string.393 394==============================================================================395*41.3*	Expressions396 397Vim has a fairly standard way to handle expressions.  You can read the398definition here: |expression-syntax|.  Here we will show the most common399items.400 401The numbers, strings and variables mentioned above are expressions by402themselves.  Thus everywhere an expression is expected, you can use a number,403string or variable.  Other basic items in an expression are:404 405	$NAME		environment variable406	&name		option value407	@r		register contents408 409Examples: >410 411	echo "The value of 'tabstop' is" &ts412	echo "Your home directory is" $HOME413	if @a == 'text'414 415The &name form can also be used to set an option value, do something and416restore the old value.  Example: >417 418	var save_ic = &ic419	set noic420	s/The Start/The Beginning/421	&ic = save_ic422 423This makes sure the "The Start" pattern is used with the 'ignorecase' option424off.  Still, it keeps the value that the user had set.  (Another way to do425this would be to add "\C" to the pattern, see |/\C|.)426 427 428MATHEMATICS429 430It becomes more interesting if we combine these basic items.  Let's start with431mathematics on numbers:432 433	a + b		add434	a - b		subtract435	a * b		multiply436	a / b		divide437	a % b		modulo438 439The usual precedence is used.  Example: >440 441	echo 10 + 5 * 2442<	20 ~443 444Grouping is done with parentheses.  No surprises here.  Example: >445 446	echo (10 + 5) * 2447<	30 ~448 449 450OTHERS451 452Strings can be concatenated with ".." (see |expr6|).  Example: >453 454	echo "Name: " .. name455	Name: Peter456 457When the "echo" command gets multiple arguments, it separates them with a458space.  In the example the argument is a single expression, thus no space is459inserted.460 461If you don't like the concatenation you can use the $"string" form, which462accepts an expression in curly braces: >463	echo $"Name: {name}"464 465See |interpolated-string| for more information.466 467Borrowed from the C language is the conditional expression: >468 469	a ? b : c470 471If "a" evaluates to true "b" is used, otherwise "c" is used.  Example: >472 473	var nr = 4474	echo nr > 5 ? "nr is big" : "nr is small"475<	nr is small ~476 477The three parts of the constructs are always evaluated first, thus you could478see it works as: >479 480	(a) ? (b) : (c)481 482There is also the falsy operator: >483	echo name ?? "No name given"484See |??|.485 486==============================================================================487*41.4*	Conditionals488 489The `if` commands executes the following statements, until the matching490`endif`, only when a condition is met.  The generic form is:491 492	if {condition}493	   {statements}494	endif495 496Only when the expression {condition} evaluates to true or one will the497{statements} be executed.  If they are not executed they must still be valid498commands.  If they contain garbage, Vim won't be able to find the matching499`endif`.500 501You can also use `else`.  The generic form for this is:502 503	if {condition}504	   {statements}505	else506	   {statements}507	endif508 509The second {statements} block is only executed if the first one isn't.510 511Finally, there is `elseif`512 513	if {condition}514	   {statements}515	elseif {condition}516	   {statements}517	endif518 519This works just like using `else` and then `if`, but without the need for an520extra `endif`.521 522A useful example for your vimrc file is checking the 'term' option and doing523something depending upon its value: >524 525	if &term == "xterm"526	  # Do stuff for xterm527	elseif &term == "vt100"528	  # Do stuff for a vt100 terminal529	else530	  # Do something for other terminals531	endif532 533This uses "#" to start a comment, more about that later.534 535 536LOGIC OPERATIONS537 538We already used some of them in the examples.  These are the most often used539ones:540 541	a == b		equal to542	a != b		not equal to543	a >  b		greater than544	a >= b		greater than or equal to545	a <  b		less than546	a <= b		less than or equal to547 548The result is true if the condition is met and false otherwise.  An example: >549 550	if v:version >= 800551	  echo "congratulations"552	else553	  echo "you are using an old version, upgrade!"554	endif555 556Here "v:version" is a variable defined by Vim, which has the value of the Vim557version.  800 is for version 8.0, version 8.1 has the value 801.  This is558useful to write a script that works with multiple versions of Vim.559See |v:version|.  You can also check for a specific feature with `has()` or a560specific patch, see |has-patch|.561 562The logic operators work both for numbers and strings.  When comparing two563strings, the mathematical difference is used.  This compares byte values,564which may not be right for some languages.565 566If you try to compare a string with a number you will get an error.567 568For strings there are two more useful items:569 570	str =~ pat		matches with571	str !~ pat		does not match with572 573The left item "str" is used as a string.  The right item "pat" is used as a574pattern, like what's used for searching.  Example: >575 576	if str =~ " "577	  echo "str contains a space"578	endif579	if str !~ '\.$'580	  echo "str does not end in a full stop"581	endif582 583Notice the use of a single-quote string for the pattern.  This is useful,584because patterns tend to contain many backslashes and backslashes need to be585doubled in a double-quote string.586 587The match is not anchored, if you want to match the whole string start with588"^" and end with "$".589 590The 'ignorecase' option is not used when comparing strings.  When you do want591to ignore case append "?".  Thus "==?" compares two strings to be equal while592ignoring case.  For the full table see |expr-==|.593 594 595MORE LOOPING596 597The `while` command was already mentioned.  Two more statements can be used in598between the `while` and the `endwhile`:599 600	continue		Jump back to the start of the while loop; the601				loop continues.602	break			Jump forward to the `endwhile`; the loop is603				discontinued.604 605Example: >606 607	var counter = 1608	while counter < 40609	  if skip_number(counter)610	    continue611	  endif612	  if last_number(counter)613	    break614	  endif615	  sleep 50m616	  ++counter617	endwhile618 619The `sleep` command makes Vim take a nap.  The "50m" specifies fifty620milliseconds.  Another example is `sleep 4`, which sleeps for four seconds.621 622`continue` and `break` can also be used in between `for` and `endfor`.623Even more looping can be done with the `for` command, see below in |41.8|.624 625==============================================================================626*41.5*	Executing an expression627 628So far the commands in the script were executed by Vim directly.  The629`execute` command allows executing the result of an expression.  This is a630very powerful way to build commands and execute them.631 632An example is to jump to a tag, which is contained in a variable: >633 634	execute "tag " .. tag_name635 636The ".." is used to concatenate the string "tag " with the value of variable637"tag_name".  Suppose "tag_name" has the value "get_cmd", then the command that638will be executed is: >639 640	tag get_cmd641 642The `execute` command can only execute Ex commands.  The `normal` command643executes Normal mode commands.  However, its argument is not an expression but644the literal command characters.  Example: >645 646	normal gg=G647 648This jumps to the first line with "gg" and formats all lines with the "="649operator and the "G" movement.650 651To make `normal` work with an expression, combine `execute` with it.652Example: >653 654	execute "normal " .. count .. "j"655 656This will move the cursor "count" lines down.657 658Make sure that the argument for `normal` is a complete command.  Otherwise659Vim will run into the end of the argument and silently abort the command.  For660example, if you start the delete operator, you must give the movement command661also.  This works: >662 663	normal d$664 665This does nothing: >666 667	normal d668 669If you start Insert mode and do not end it with Esc, it will end anyway.  This670works to insert "new text": >671 672	execute "normal inew text"673 674If you want to do something after inserting text you do need to end Insert675mode: >676 677	execute "normal inew text\<Esc>b"678 679This inserts "new text" and puts the cursor on the first letter of "text".680Notice the use of the special key "\<Esc>".  This avoids having to enter a681real <Esc> character in your script.  That is where `execute` with a682double-quote string comes in handy.683 684If you don't want to execute a string as a command but evaluate it to get the685result of the expression, you can use the eval() function: >686 687	var optname = "path"688	var optvalue = eval('&' .. optname)689 690A "&" character is prepended to "path", thus the argument to eval() is691"&path".  The result will then be the value of the 'path' option.692 693==============================================================================694*41.6*	Using functions695 696Vim defines many functions and provides a large amount of functionality that697way.  A few examples will be given in this section.  You can find the whole698list below: |function-list|.699 700A function is called with the parameters in between parentheses, separated by701commas.  Example: >702 703	search("Date: ", "W")704 705This calls the search() function, with arguments "Date: " and "W".  The706search() function uses its first argument as a search pattern and the second707one as flags.  The "W" flag means the search doesn't wrap around the end of708the file.709 710Using the `call` command is optional in |Vim9| script.  It is required in711legacy script and on the command line: >712 713	call search("Date: ", "W")714 715A function can be called in an expression.  Example: >716 717	var line = getline(".")718	var repl = substitute(line, '\a', "*", "g")719	setline(".", repl)720 721The getline() function obtains a line from the current buffer.  Its argument722is a specification of the line number.  In this case "." is used, which means723the line where the cursor is.724 725The substitute() function does something similar to the `:substitute` command.726The first argument "line" is the string on which to perform the substitution.727The second argument '\a' is the pattern, the third "*" is the replacement728string.  Finally, the last argument "g" is the flags.729 730The setline() function sets the line, specified by the first argument, to a731new string, the second argument.  In this example the line under the cursor is732replaced with the result of the substitute().  Thus the effect of the three733statements is equal to: >734 735	:substitute/\a/*/g736 737Using the functions becomes interesting when you do more work before and738after the substitute() call.739 740 741FUNCTIONS						*function-list*742 743There are many functions.  We will mention them here, grouped by what they are744used for.  You can find an alphabetical list here: |builtin-function-list|.745Use CTRL-] on the function name to jump to detailed help on it.746 747String manipulation:					*string-functions*748	nr2char()		get a character by its number value749	list2str()		get a character string from a list of numbers750	char2nr()		get number value of a character751	str2list()		get list of numbers from a string752	str2nr()		convert a string to a Number753	str2float()		convert a string to a Float754	printf()		format a string according to "%" items755	escape()		escape characters in a string with a '\'756	shellescape()		escape a string for use with a shell command757	fnameescape()		escape a file name for use with a Vim command758	tr()			translate characters from one set to another759	strtrans()		translate a string to make it printable760	keytrans()		translate internal keycodes to a form that761				can be used by |:map|762	tolower()		turn a string to lowercase763	toupper()		turn a string to uppercase764	charclass()		class of a character765	match()			position where a pattern matches in a string766	matchbufline()		all the matches of a pattern in a buffer767	matchend()		position where a pattern match ends in a768				string769	matchfuzzy()		fuzzy matches a string in a list of strings770	matchfuzzypos()		fuzzy matches a string in a list of strings771	matchstr()		match of a pattern in a string772	matchstrlist()		all the matches of a pattern in a List of773				strings774	matchstrpos()		match and positions of a pattern in a string775	matchlist()		like matchstr() and also return submatches776	stridx()		first index of a short string in a long string777	strridx()		last index of a short string in a long string778	strlen()		length of a string in bytes779	strcharlen()		length of a string in characters780	strchars()		number of characters in a string781	strutf16len()		number of UTF-16 code units in a string782	strwidth()		size of string when displayed783	strdisplaywidth()	size of string when displayed, deals with tabs784	setcellwidths()		set character cell width overrides785	getcellwidths()		get character cell width overrides786	getcellpixels()		get character cell pixel size787	reverse()		reverse the order of characters in a string788	substitute()		substitute a pattern match with a string789	submatch()		get a specific match in ":s" and substitute()790	strpart()		get part of a string using byte index791	strcharpart()		get part of a string using char index792	slice()			take a slice of a string, using char index in793				Vim9 script794	strgetchar()		get character from a string using char index795	expand()		expand special keywords796	expandcmd()		expand a command like done for `:edit`797	iconv()			convert text from one encoding to another798	byteidx()		byte index of a character in a string799	byteidxcomp()		like byteidx() but count composing characters800	charidx()		character index of a byte in a string801	utf16idx()		UTF-16 index of a byte in a string802	repeat()		repeat a string multiple times803	eval()			evaluate a string expression804	execute()		execute an Ex command and get the output805	win_execute()		like execute() but in a specified window806	trim()			trim characters from a string807	bindtextdomain()	set message lookup translation base path808	gettext()		lookup message translation809	ngettext()		lookup single/plural message translation810	str2blob()		convert a list of strings into a blob811	blob2str()		convert a blob into a list of strings812	items()			get List of String index-character pairs813	uri_encode()		URI-encode a string814	uri_decode()		URI-decode a string815 816List manipulation:					*list-functions*817	get()			get an item without error for wrong index818	len()			number of items in a List819	empty()			check if List is empty820	insert()		insert an item somewhere in a List821	add()			append an item to a List822	extend()		append a List to a List823	extendnew()		make a new List and append items824	remove()		remove one or more items from a List825	copy()			make a shallow copy of a List826	deepcopy()		make a full copy of a List827	filter()		remove selected items from a List828	map()			change each List item829	mapnew()		make a new List with changed items830	foreach()		apply function to List items831	reduce()		reduce a List to a value832	slice()			take a slice of a List833	sort()			sort a List834	reverse()		reverse the order of items in a List835	uniq()			remove copies of repeated adjacent items836	split()			split a String into a List837	join()			join List items into a String838	range()			return a List with a sequence of numbers839	string()		String representation of a List840	call()			call a function with List as arguments841	index()			index of a value in a List842	indexof()		index in a List where an expression is true843	max()			maximum value in a List844	min()			minimum value in a List845	count()			count number of times a value appears in a846				List847	repeat()		repeat a List multiple times848	flatten()		flatten a List849	flattennew()		flatten a copy of a List850	items()			get List of List index-value pairs851 852Tuple manipulation:					*tuple-functions*853	copy()			make a shallow copy of a Tuple854	count()			count number of times a value appears in a855				Tuple856	deepcopy()		make a full copy of a Tuple857	empty()			check if Tuple is empty858	foreach()		apply function to Tuple items859	get()			get an item without error for wrong index860	index()			index of a value in a Tuple861	indexof()		index in a Tuple where an expression is true862	items()			get List of Tuple index-value pairs863	join()			join Tuple items into a String864	len()			number of items in a Tuple865	list2tuple()		convert a list of items into a Tuple866	max()			maximum value in a Tuple867	min()			minimum value in a Tuple868	reduce()		reduce a Tuple to a value869	repeat()		repeat a Tuple multiple times870	reverse()		reverse the order of items in a Tuple871	slice()			take a slice of a Tuple872	string()		string representation of a Tuple873	tuple2list()		convert a Tuple into a List874 875Dictionary manipulation:				*dict-functions*876	get()			get an entry without an error for a wrong key877	len()			number of entries in a Dictionary878	has_key()		check whether a key appears in a Dictionary879	empty()			check if Dictionary is empty880	remove()		remove an entry from a Dictionary881	extend()		add entries from one Dictionary to another882	extendnew()		make a new Dictionary and append items883	filter()		remove selected entries from a Dictionary884	map()			change each Dictionary entry885	mapnew()		make a new Dictionary with changed items886	foreach()		apply function to Dictionary items887	keys()			get List of Dictionary keys888	values()		get List of Dictionary values889	items()			get List of Dictionary key-value pairs890	copy()			make a shallow copy of a Dictionary891	deepcopy()		make a full copy of a Dictionary892	string()		String representation of a Dictionary893	max()			maximum value in a Dictionary894	min()			minimum value in a Dictionary895	count()			count number of times a value appears896 897Floating point computation:				*float-functions*898	float2nr()		convert Float to Number899	abs()			absolute value (also works for Number)900	round()			round off901	ceil()			round up902	floor()			round down903	trunc()			remove value after decimal point904	fmod()			remainder of division905	exp()			exponential906	log()			natural logarithm (logarithm to base e)907	log10()			logarithm to base 10908	pow()			value of x to the exponent y909	sqrt()			square root910	sin()			sine911	cos()			cosine912	tan()			tangent913	asin()			arc sine914	acos()			arc cosine915	atan()			arc tangent916	atan2()			arc tangent917	sinh()			hyperbolic sine918	cosh()			hyperbolic cosine919	tanh()			hyperbolic tangent920	isinf()			check for infinity921	isnan()			check for not a number922 923Blob manipulation:					*blob-functions*924	blob2list()		get a list of numbers from a blob925	list2blob()		get a blob from a list of numbers926	reverse()		reverse the order of numbers in a blob927	index()			index of a value in a Blob928	indexof()		index in a Blob where an expression is true929	items()			get List of Blob index-value pairs930 931Other computation:					*bitwise-function*932	and()			bitwise AND933	invert()		bitwise invert934	or()			bitwise OR935	xor()			bitwise XOR936	sha256()		SHA-256 hash937	rand()			get a pseudo-random number938	srand()			initialize seed used by rand()939 940Variables:						*var-functions*941	instanceof()		check if a variable is an instance of a given942				class943	type()			type of a variable as a number944	typename()		type of a variable as text945	islocked()		check if a variable is locked946	funcref()		get a Funcref for a function reference947	function()		get a Funcref for a function name948	getbufvar()		get a variable value from a specific buffer949	setbufvar()		set a variable in a specific buffer950	getwinvar()		get a variable from specific window951	gettabvar()		get a variable from specific tab page952	gettabwinvar()		get a variable from specific window & tab page953	setwinvar()		set a variable in a specific window954	settabvar()		set a variable in a specific tab page955	settabwinvar()		set a variable in a specific window & tab page956	garbagecollect()	possibly free memory957 958Cursor and mark position:		*cursor-functions* *mark-functions*959	col()			column number of the cursor or a mark960	virtcol()		screen column of the cursor or a mark961	line()			line number of the cursor or mark962	wincol()		window column number of the cursor963	winline()		window line number of the cursor964	cursor()		position the cursor at a line/column965	screencol()		get screen column of the cursor966	screenrow()		get screen row of the cursor967	screenpos()		screen row and col of a text character968	virtcol2col()		byte index of a text character on screen969	getcurpos()		get position of the cursor970	getpos()		get position of cursor, mark, etc.971	setpos()		set position of cursor, mark, etc.972	getmarklist()		list of global/local marks973	byte2line()		get line number at a specific byte count974	line2byte()		byte count at a specific line975	diff_filler()		get the number of filler lines above a line976	screenattr()		get attribute at a screen line/row977	screenchar()		get character code at a screen line/row978	screenchars()		get character codes at a screen line/row979	screenstring()		get string of characters at a screen line/row980	charcol()		character number of the cursor or a mark981	getcharpos()		get character position of cursor, mark, etc.982	setcharpos()		set character position of cursor, mark, etc.983	getcursorcharpos()	get character position of the cursor984	setcursorcharpos()	set character position of the cursor985 986Working with text in the current buffer:		*text-functions*987	getline()		get a line or list of lines from the buffer988	getregion()		get a region of text from the buffer989	getregionpos()		get a list of positions for a region990	setline()		replace a line in the buffer991	append()		append line or list of lines in the buffer992	indent()		indent of a specific line993	cindent()		indent according to C indenting994	lispindent()		indent according to Lisp indenting995	nextnonblank()		find next non-blank line996	prevnonblank()		find previous non-blank line997	search()		find a match for a pattern998	searchpos()		find a match for a pattern999	searchcount()		get number of matches before/after the cursor1000	searchpair()		find the other end of a start/skip/end1001	searchpairpos()		find the other end of a start/skip/end1002	searchdecl()		search for the declaration of a name1003	getcharsearch()		return character search information1004	setcharsearch()		set character search information1005 1006Working with text in another buffer:1007	getbufline()		get a list of lines from the specified buffer1008	getbufoneline()		get a one line from the specified buffer1009	setbufline()		replace a line in the specified buffer1010	appendbufline()		append a list of lines in the specified buffer1011	deletebufline()		delete lines from a specified buffer1012 1013					*system-functions* *file-functions*1014System functions and manipulation of files:1015	glob()			expand wildcards1016	globpath()		expand wildcards in a number of directories1017	glob2regpat()		convert a glob pattern into a search pattern1018	findfile()		find a file in a list of directories1019	finddir()		find a directory in a list of directories1020	resolve()		find out where a shortcut points to1021	fnamemodify()		modify a file name1022	pathshorten()		shorten directory names in a path1023	simplify()		simplify a path without changing its meaning1024	executable()		check if an executable program exists1025	exepath()		full path of an executable program1026	filereadable()		check if a file can be read1027	filewritable()		check if a file can be written to1028	getfperm()		get the permissions of a file1029	setfperm()		set the permissions of a file1030	getftype()		get the kind of a file1031	isabsolutepath()	check if a path is absolute1032	isdirectory()		check if a directory exists1033	getfsize()		get the size of a file1034	getcwd()		get the current working directory1035	haslocaldir()		check if current window used |:lcd| or |:tcd|1036	tempname()		get the name of a temporary file1037	mkdir()			create a new directory1038	chdir()			change current working directory1039	delete()		delete a file1040	rename()		rename a file1041	system()		get the result of a shell command as a string1042	systemlist()		get the result of a shell command as a list1043	environ()		get all environment variables1044	getenv()		get one environment variable1045	setenv()		set an environment variable1046	hostname()		name of the system1047	readfile()		read a file into a List of lines1048	readblob()		read a file into a Blob1049	readdir()		get a List of file names in a directory1050	readdirex()		get a List of file information in a directory1051	writefile()		write a List of lines or Blob into a file1052	filecopy()		copy a file {from} to {to}1053 1054Date and Time:				*date-functions* *time-functions*1055	getftime()		get last modification time of a file1056	localtime()		get current time in seconds1057	strftime()		convert time to a string1058	strptime()		convert a date/time string to time1059	reltime()		get the current or elapsed time accurately1060	reltimestr()		convert reltime() result to a string1061	reltimefloat()		convert reltime() result to a Float1062 1063Autocmds:					*autocmd-functions*1064	autocmd_add()		add a list of autocmds and groups1065	autocmd_delete()	delete a list of autocmds and groups1066	autocmd_get()		return a list of autocmds1067 1068			*buffer-functions* *window-functions* *arg-functions*1069Buffers, windows and the argument list:1070	argc()			number of entries in the argument list1071	argidx()		current position in the argument list1072	arglistid()		get id of the argument list1073	argv()			get one entry from the argument list1074	bufadd()		add a file to the list of buffers1075	bufexists()		check if a buffer exists1076	buflisted()		check if a buffer exists and is listed1077	bufload()		ensure a buffer is loaded1078	bufloaded()		check if a buffer exists and is loaded1079	bufname()		get the name of a specific buffer1080	bufnr()			get the buffer number of a specific buffer1081	tabpagebuflist()	return List of buffers in a tab page1082	tabpagenr()		get the number of a tab page1083	tabpagewinnr()		like winnr() for a specified tab page1084	winnr()			get the window number for the current window1085	bufwinid()		get the window ID of a specific buffer1086	bufwinnr()		get the window number of a specific buffer1087	winbufnr()		get the buffer number of a specific window1088	listener_add()		add a callback to listen to changes1089	listener_flush()	invoke listener callbacks1090	listener_remove()	remove a listener callback1091	win_findbuf()		find windows containing a buffer1092	win_getid()		get window ID of a window1093	win_gettype()		get type of window1094	win_gotoid()		go to window with ID1095	win_id2tabwin()		get tab and window nr from window ID1096	win_id2win()		get window nr from window ID1097	win_move_separator()	move window vertical separator1098	win_move_statusline()	move window status line1099	win_splitmove()		move window to a split of another window1100	getbufinfo()		get a list with buffer information1101	gettabinfo()		get a list with tab page information1102	getwininfo()		get a list with window information1103	getchangelist()		get a list of change list entries1104	getjumplist()		get a list of jump list entries1105	swapfilelist()		list of existing swap files in 'directory'1106	swapinfo()		information about a swap file1107	swapname()		get the swap file path of a buffer1108 1109Command line:					*command-line-functions*1110	getcmdcomplpat()	get completion pattern of the current command1111				line1112	getcmdcompltype()	get the type of the current command line1113				completion1114	getcmdline()		get the current command line input1115	getcmdprompt()		get the current command line prompt1116	getcmdpos()		get position of the cursor in the command line1117	getcmdscreenpos()	get screen position of the cursor in the1118				command line1119	setcmdline()		set the current command line1120	setcmdpos()		set position of the cursor in the command line1121	getcmdtype()		return the current command-line type1122	getcmdwintype()		return the current command-line window type1123	getcompletion()		list of command-line completion matches1124	getcompletiontype()	get the type of the command-line completion1125				for specified string1126	fullcommand()		get full command name1127	cmdcomplete_info()	get command-line completion information1128 1129Quickfix and location lists:			*quickfix-functions*1130	getqflist()		list of quickfix errors1131	setqflist()		modify a quickfix list1132	getloclist()		list of location list items1133	setloclist()		modify a location list1134 1135Insert mode completion:				*completion-functions*1136	complete()		set found matches1137	complete_add()		add to found matches1138	complete_check()	check if completion should be aborted1139	complete_info()		get current completion information1140	preinserted()		check if text is inserted after cursor1141	pumvisible()		check if the popup menu is displayed1142	pum_getpos()		position and size of popup menu if visible1143 1144Folding:					*folding-functions*1145	foldclosed()		check for a closed fold at a specific line1146	foldclosedend()		like foldclosed() but return the last line1147	foldlevel()		check for the fold level at a specific line1148	foldtext()		generate the line displayed for a closed fold1149	foldtextresult()	get the text displayed for a closed fold1150 1151Syntax and highlighting:	  *syntax-functions* *highlighting-functions*1152	clearmatches()		clear all matches defined by |matchadd()| and1153				the |:match| commands1154	getmatches()		get all matches defined by |matchadd()| and1155				the |:match| commands1156	hlexists()		check if a highlight group exists1157	hlget()			get highlight group attributes1158	hlset()			set highlight group attributes1159	hlID()			get ID of a highlight group1160	synID()			get syntax ID at a specific position1161	synIDattr()		get a specific attribute of a syntax ID1162	synIDtrans()		get translated syntax ID1163	synstack()		get list of syntax IDs at a specific position1164	synconcealed()		get info about (syntax) concealing1165	diff_hlID()		get highlight ID for diff mode at a position1166	matchadd()		define a pattern to highlight (a "match")1167	matchaddpos()		define a list of positions to highlight1168	matcharg()		get info about |:match| arguments1169	matchdelete()		delete a match defined by |matchadd()| or a1170				|:match| command1171	setmatches()		restore a list of matches saved by1172				|getmatches()|1173 1174Spelling:					*spell-functions*1175	spellbadword()		locate badly spelled word at or after cursor1176	spellsuggest()		return suggested spelling corrections1177	soundfold()		return the sound-a-like equivalent of a word1178 1179History:					*history-functions*1180	histadd()		add an item to a history1181	histdel()		delete an item from a history1182	histget()		get an item from a history1183	histnr()		get highest index of a history list1184 1185Interactive:					*interactive-functions*1186	browse()		put up a file requester1187	browsedir()		put up a directory requester1188	confirm()		let the user make a choice1189	getchar()		get a character from the user1190	getcharstr()		get a character from the user as a string1191	getcharmod()		get modifiers for the last typed character1192	getmousepos()		get last known mouse position1193	getmouseshape()		get name of the current mouse shape1194	echoraw()		output characters as-is1195	feedkeys()		put characters in the typeahead queue1196	input()			get a line from the user1197	inputlist()		let the user pick an entry from a list1198	inputsecret()		get a line from the user without showing it1199	inputdialog()		get a line from the user in a dialog1200	inputsave()		save and clear typeahead

Showing the first 1,200 of 2011 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai