comparison runtime/doc/eval.txt @ 685:d7e33248b9c8 v7.0206

updated for version 7.0206
author vimboss
date Fri, 24 Feb 2006 23:53:04 +0000
parents 9364d114ed8d
children bcd2edc4539e
comparison
equal deleted inserted replaced
684:a8caf7dd853d 685:d7e33248b9c8
1 *eval.txt* For Vim version 7.0aa. Last change: 2006 Feb 22 1 *eval.txt* For Vim version 7.0aa. Last change: 2006 Feb 24
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
575 expr5 ==? expr5 equal, ignoring case 575 expr5 ==? expr5 equal, ignoring case
576 expr5 ==# expr5 equal, match case 576 expr5 ==# expr5 equal, match case
577 etc. As above, append ? for ignoring case, # for 577 etc. As above, append ? for ignoring case, # for
578 matching case 578 matching case
579 579
580 expr5 is expr5 same List instance 580 expr5 is expr5 same |List| instance
581 expr5 isnot expr5 different List instance 581 expr5 isnot expr5 different |List| instance
582 582
583 |expr5| expr6 + expr6 .. number addition or list concatenation 583 |expr5| expr6 + expr6 .. number addition or list concatenation
584 expr6 - expr6 .. number subtraction 584 expr6 - expr6 .. number subtraction
585 expr6 . expr6 .. string concatenation 585 expr6 . expr6 .. string concatenation
586 586
591 |expr7| ! expr7 logical NOT 591 |expr7| ! expr7 logical NOT
592 - expr7 unary minus 592 - expr7 unary minus
593 + expr7 unary plus 593 + expr7 unary plus
594 594
595 595
596 |expr8| expr8[expr1] byte of a String or item of a List 596 |expr8| expr8[expr1] byte of a String or item of a |List|
597 expr8[expr1 : expr1] substring of a String or sublist of a List 597 expr8[expr1 : expr1] substring of a String or sublist of a |List|
598 expr8.name entry in a Dictionary 598 expr8.name entry in a |Dictionary|
599 expr8(expr1, ...) function call with Funcref variable 599 expr8(expr1, ...) function call with |Funcref| variable
600 600
601 |expr9| number number constant 601 |expr9| number number constant
602 "string" string constant, backslash is special 602 "string" string constant, backslash is special
603 'string' string constant, ' is doubled 603 'string' string constant, ' is doubled
604 [expr1, ...] List 604 [expr1, ...] |List|
605 {expr1: expr1, ...} Dictionary 605 {expr1: expr1, ...} |Dictionary|
606 &option option value 606 &option option value
607 (expr1) nested expression 607 (expr1) nested expression
608 variable internal variable 608 variable internal variable
609 va{ria}ble internal variable with curly braces 609 va{ria}ble internal variable with curly braces
610 $VAR environment variable 610 $VAR environment variable
712 "abc" ==# "Abc" evaluates to 0 712 "abc" ==# "Abc" evaluates to 0
713 "abc" ==? "Abc" evaluates to 1 713 "abc" ==? "Abc" evaluates to 1
714 "abc" == "Abc" evaluates to 1 if 'ignorecase' is set, 0 otherwise 714 "abc" == "Abc" evaluates to 1 if 'ignorecase' is set, 0 otherwise
715 715
716 *E691* *E692* 716 *E691* *E692*
717 A List can only be compared with a List and only "equal", "not equal" and "is" 717 A |List| can only be compared with a |List| and only "equal", "not equal" and
718 can be used. This compares the values of the list, recursively. Ignoring 718 "is" can be used. This compares the values of the list, recursively.
719 case means case is ignored when comparing item values. 719 Ignoring case means case is ignored when comparing item values.
720 720
721 *E735* *E736* 721 *E735* *E736*
722 A Dictionary can only be compared with a Dictionary and only "equal", "not 722 A |Dictionary| can only be compared with a |Dictionary| and only "equal", "not
723 equal" and "is" can be used. This compares the key/values of the Dictionary, 723 equal" and "is" can be used. This compares the key/values of the |Dictionary|
724 recursively. Ignoring case means case is ignored when comparing item values. 724 recursively. Ignoring case means case is ignored when comparing item values.
725 725
726 *E693* *E694* 726 *E693* *E694*
727 A Funcref can only be compared with a Funcref and only "equal" and "not equal" 727 A |Funcref| can only be compared with a |Funcref| and only "equal" and "not
728 can be used. Case is never ignored. 728 equal" can be used. Case is never ignored.
729 729
730 When using "is" or "isnot" with a List this checks if the expressions are 730 When using "is" or "isnot" with a |List| this checks if the expressions are
731 referring to the same List instance. A copy of a List is different from the 731 referring to the same |List| instance. A copy of a |List| is different from
732 original List. When using "is" without a List it is equivalent to using 732 the original |List|. When using "is" without a |List| it is equivalent to
733 "equal", using "isnot" equivalent to using "not equal". Except that a 733 using "equal", using "isnot" equivalent to using "not equal". Except that a
734 different type means the values are different. "4 == '4'" is true, "4 is '4'" 734 different type means the values are different. "4 == '4'" is true, "4 is '4'"
735 is false. 735 is false.
736 736
737 When comparing a String with a Number, the String is converted to a Number, 737 When comparing a String with a Number, the String is converted to a Number,
738 and the comparison is done on Numbers. This means that "0 == 'x'" is TRUE, 738 and the comparison is done on Numbers. This means that "0 == 'x'" is TRUE,
761 "foo\nbar" =~ "\\n" evaluates to 0 761 "foo\nbar" =~ "\\n" evaluates to 0
762 762
763 763
764 expr5 and expr6 *expr5* *expr6* 764 expr5 and expr6 *expr5* *expr6*
765 --------------- 765 ---------------
766 expr6 + expr6 .. Number addition or List concatenation *expr-+* 766 expr6 + expr6 .. Number addition or |List| concatenation *expr-+*
767 expr6 - expr6 .. Number subtraction *expr--* 767 expr6 - expr6 .. Number subtraction *expr--*
768 expr6 . expr6 .. String concatenation *expr-.* 768 expr6 . expr6 .. String concatenation *expr-.*
769 769
770 For Lists only "+" is possible and then both expr6 must be a list. The result 770 For |List|s only "+" is possible and then both expr6 must be a list. The
771 is a new list with the two lists Concatenated. 771 result is a new list with the two lists Concatenated.
772 772
773 expr7 * expr7 .. number multiplication *expr-star* 773 expr7 * expr7 .. number multiplication *expr-star*
774 expr7 / expr7 .. number division *expr-/* 774 expr7 / expr7 .. number division *expr-/*
775 expr7 % expr7 .. number modulo *expr-%* 775 expr7 % expr7 .. number modulo *expr-%*
776 776
781 "123" . "456" = "123456" 781 "123" . "456" = "123456"
782 782
783 When the righthand side of '/' is zero, the result is 0x7fffffff. 783 When the righthand side of '/' is zero, the result is 0x7fffffff.
784 When the righthand side of '%' is zero, the result is 0. 784 When the righthand side of '%' is zero, the result is 0.
785 785
786 None of these work for Funcrefs. 786 None of these work for |Funcref|s.
787 787
788 788
789 expr7 *expr7* 789 expr7 *expr7*
790 ----- 790 -----
791 ! expr7 logical NOT *expr-!* 791 ! expr7 logical NOT *expr-!*
804 --9 == 9 804 --9 == 9
805 805
806 806
807 expr8 *expr8* 807 expr8 *expr8*
808 ----- 808 -----
809 expr8[expr1] item of String or List *expr-[]* *E111* 809 expr8[expr1] item of String or |List| *expr-[]* *E111*
810 810
811 If expr8 is a Number or String this results in a String that contains the 811 If expr8 is a Number or String this results in a String that contains the
812 expr1'th single byte from expr8. expr8 is used as a String, expr1 as a 812 expr1'th single byte from expr8. expr8 is used as a String, expr1 as a
813 Number. Note that this doesn't recognize multi-byte encodings. 813 Number. Note that this doesn't recognize multi-byte encodings.
814 814
819 819
820 If the length of the String is less than the index, the result is an empty 820 If the length of the String is less than the index, the result is an empty
821 String. A negative index always results in an empty string (reason: backwards 821 String. A negative index always results in an empty string (reason: backwards
822 compatibility). Use [-1:] to get the last byte. 822 compatibility). Use [-1:] to get the last byte.
823 823
824 If expr8 is a List then it results the item at index expr1. See |list-index| 824 If expr8 is a |List| then it results the item at index expr1. See |list-index|
825 for possible index values. If the index is out of range this results in an 825 for possible index values. If the index is out of range this results in an
826 error. Example: > 826 error. Example: >
827 :let item = mylist[-1] " get last item 827 :let item = mylist[-1] " get last item
828 828
829 Generally, if a List index is equal to or higher than the length of the List, 829 Generally, if a |List| index is equal to or higher than the length of the
830 or more negative than the length of the List, this results in an error. 830 |List|, or more negative than the length of the |List|, this results in an
831 error.
831 832
832 833
833 expr8[expr1a : expr1b] substring or sublist *expr-[:]* 834 expr8[expr1a : expr1b] substring or sublist *expr-[:]*
834 835
835 If expr8 is a Number or String this results in the substring with the bytes 836 If expr8 is a Number or String this results in the substring with the bytes
850 :let c = name[-1:] " last byte of a string 851 :let c = name[-1:] " last byte of a string
851 :let c = name[-2:-2] " last but one byte of a string 852 :let c = name[-2:-2] " last but one byte of a string
852 :let s = line(".")[4:] " from the fifth byte to the end 853 :let s = line(".")[4:] " from the fifth byte to the end
853 :let s = s[:-3] " remove last two bytes 854 :let s = s[:-3] " remove last two bytes
854 855
855 If expr8 is a List this results in a new List with the items indicated by the 856 If expr8 is a |List| this results in a new |List| with the items indicated by
856 indexes expr1a and expr1b. This works like with a String, as explained just 857 the indexes expr1a and expr1b. This works like with a String, as explained
857 above, except that indexes out of range cause an error. Examples: > 858 just above, except that indexes out of range cause an error. Examples: >
858 :let l = mylist[:3] " first four items 859 :let l = mylist[:3] " first four items
859 :let l = mylist[4:4] " List with one item 860 :let l = mylist[4:4] " List with one item
860 :let l = mylist[:] " shallow copy of a List 861 :let l = mylist[:] " shallow copy of a List
861 862
862 Using expr8[expr1] or expr8[expr1a : expr1b] on a Funcref results in an error. 863 Using expr8[expr1] or expr8[expr1a : expr1b] on a |Funcref| results in an
863 864 error.
864 865
865 expr8.name entry in a Dictionary *expr-entry* 866
866 867 expr8.name entry in a |Dictionary| *expr-entry*
867 If expr8 is a Dictionary and it is followed by a dot, then the following name 868
868 will be used as a key in the Dictionary. This is just like: expr8[name]. 869 If expr8 is a |Dictionary| and it is followed by a dot, then the following
870 name will be used as a key in the |Dictionary|. This is just like:
871 expr8[name].
869 872
870 The name must consist of alphanumeric characters, just like a variable name, 873 The name must consist of alphanumeric characters, just like a variable name,
871 but it may start with a number. Curly braces cannot be used. 874 but it may start with a number. Curly braces cannot be used.
872 875
873 There must not be white space before or after the dot. 876 There must not be white space before or after the dot.
879 882
880 Note that the dot is also used for String concatenation. To avoid confusion 883 Note that the dot is also used for String concatenation. To avoid confusion
881 always put spaces around the dot for String concatenation. 884 always put spaces around the dot for String concatenation.
882 885
883 886
884 expr8(expr1, ...) Funcref function call 887 expr8(expr1, ...) |Funcref| function call
885 888
886 When expr8 is a |Funcref| type variable, invoke the function it refers to. 889 When expr8 is a |Funcref| type variable, invoke the function it refers to.
887 890
888 891
889 892
1027 |local-variable| l: Local to a function. 1030 |local-variable| l: Local to a function.
1028 |script-variable| s: Local to a |:source|'ed Vim script. 1031 |script-variable| s: Local to a |:source|'ed Vim script.
1029 |function-argument| a: Function argument (only inside a function). 1032 |function-argument| a: Function argument (only inside a function).
1030 |vim-variable| v: Global, predefined by Vim. 1033 |vim-variable| v: Global, predefined by Vim.
1031 1034
1032 The scope name by itself can be used as a Dictionary. For example, to delete 1035 The scope name by itself can be used as a |Dictionary|. For example, to
1033 all script-local variables: > 1036 delete all script-local variables: >
1034 :for k in keys(s:) 1037 :for k in keys(s:)
1035 : unlet s:[k] 1038 : unlet s:[k]
1036 :endfor 1039 :endfor
1037 < 1040 <
1038 *buffer-variable* *b:var* 1041 *buffer-variable* *b:var*
1325 i Insert mode 1328 i Insert mode
1326 r Replace mode 1329 r Replace mode
1327 v Virtual Replace mode 1330 v Virtual Replace mode
1328 1331
1329 *v:key* *key-variable* 1332 *v:key* *key-variable*
1330 v:key Key of the current item of a Dictionary. Only valid while 1333 v:key Key of the current item of a |Dictionary|. Only valid while
1331 evaluating the expression used with |map()| and |filter()|. 1334 evaluating the expression used with |map()| and |filter()|.
1332 Read-only. 1335 Read-only.
1333 1336
1334 *v:lang* *lang-variable* 1337 *v:lang* *lang-variable*
1335 v:lang The current locale setting for messages of the runtime 1338 v:lang The current locale setting for messages of the runtime
1457 : echo "Exception from" v:throwpoint 1460 : echo "Exception from" v:throwpoint
1458 :endtry 1461 :endtry
1459 < Output: "Exception from test.vim, line 2" 1462 < Output: "Exception from test.vim, line 2"
1460 1463
1461 *v:val* *val-variable* 1464 *v:val* *val-variable*
1462 v:val Value of the current item of a List or Dictionary. Only valid 1465 v:val Value of the current item of a |List| or |Dictionary|. Only
1463 while evaluating the expression used with |map()| and 1466 valid while evaluating the expression used with |map()| and
1464 |filter()|. Read-only. 1467 |filter()|. Read-only.
1465 1468
1466 *v:version* *version-variable* 1469 *v:version* *version-variable*
1467 v:version Version number of Vim: Major version number times 100 plus 1470 v:version Version number of Vim: Major version number times 100 plus
1468 minor version number. Version 5.0 is 500. Version 5.1 (5.01) 1471 minor version number. Version 5.0 is 500. Version 5.1 (5.01)
1484 1487
1485 (Use CTRL-] on the function name to jump to the full explanation.) 1488 (Use CTRL-] on the function name to jump to the full explanation.)
1486 1489
1487 USAGE RESULT DESCRIPTION ~ 1490 USAGE RESULT DESCRIPTION ~
1488 1491
1489 add( {list}, {item}) List append {item} to List {list} 1492 add( {list}, {item}) List append {item} to |List| {list}
1490 append( {lnum}, {string}) Number append {string} below line {lnum} 1493 append( {lnum}, {string}) Number append {string} below line {lnum}
1491 append( {lnum}, {list}) Number append lines {list} below line {lnum} 1494 append( {lnum}, {list}) Number append lines {list} below line {lnum}
1492 argc() Number number of files in the argument list 1495 argc() Number number of files in the argument list
1493 argidx() Number current index in the argument list 1496 argidx() Number current index in the argument list
1494 argv( {nr}) String {nr} entry of the argument list 1497 argv( {nr}) String {nr} entry of the argument list
1593 inputsave() Number save and clear typeahead 1596 inputsave() Number save and clear typeahead
1594 inputsecret( {prompt} [, {text}]) String like input() but hiding the text 1597 inputsecret( {prompt} [, {text}]) String like input() but hiding the text
1595 insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] 1598 insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}]
1596 isdirectory( {directory}) Number TRUE if {directory} is a directory 1599 isdirectory( {directory}) Number TRUE if {directory} is a directory
1597 islocked( {expr}) Number TRUE if {expr} is locked 1600 islocked( {expr}) Number TRUE if {expr} is locked
1598 items( {dict}) List List of key-value pairs in {dict} 1601 items( {dict}) List key-value pairs in {dict}
1599 join( {list} [, {sep}]) String join {list} items into one String 1602 join( {list} [, {sep}]) String join {list} items into one String
1600 keys( {dict}) List List of keys in {dict} 1603 keys( {dict}) List keys in {dict}
1601 len( {expr}) Number the length of {expr} 1604 len( {expr}) Number the length of {expr}
1602 libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg} 1605 libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg}
1603 libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number 1606 libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number
1604 line( {expr}) Number line nr of cursor, last line or mark 1607 line( {expr}) Number line nr of cursor, last line or mark
1605 line2byte( {lnum}) Number byte count of line {lnum} 1608 line2byte( {lnum}) Number byte count of line {lnum}
1669 soundfold( {word}) String sound-fold {word} 1672 soundfold( {word}) String sound-fold {word}
1670 spellbadword() String badly spelled word at cursor 1673 spellbadword() String badly spelled word at cursor
1671 spellsuggest( {word} [, {max} [, {capital}]]) 1674 spellsuggest( {word} [, {max} [, {capital}]])
1672 List spelling suggestions 1675 List spelling suggestions
1673 split( {expr} [, {pat} [, {keepempty}]]) 1676 split( {expr} [, {pat} [, {keepempty}]])
1674 List make List from {pat} separated {expr} 1677 List make |List| from {pat} separated {expr}
1675 strftime( {format}[, {time}]) String time in specified format 1678 strftime( {format}[, {time}]) String time in specified format
1676 stridx( {haystack}, {needle}[, {start}]) 1679 stridx( {haystack}, {needle}[, {start}])
1677 Number index of {needle} in {haystack} 1680 Number index of {needle} in {haystack}
1678 string( {expr}) String String representation of {expr} value 1681 string( {expr}) String String representation of {expr} value
1679 strlen( {expr}) Number length of the String {expr} 1682 strlen( {expr}) Number length of the String {expr}
1700 tolower( {expr}) String the String {expr} switched to lowercase 1703 tolower( {expr}) String the String {expr} switched to lowercase
1701 toupper( {expr}) String the String {expr} switched to uppercase 1704 toupper( {expr}) String the String {expr} switched to uppercase
1702 tr( {src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr} 1705 tr( {src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr}
1703 to chars in {tostr} 1706 to chars in {tostr}
1704 type( {name}) Number type of variable {name} 1707 type( {name}) Number type of variable {name}
1705 values( {dict}) List List of values in {dict} 1708 values( {dict}) List values in {dict}
1706 virtcol( {expr}) Number screen column of cursor or mark 1709 virtcol( {expr}) Number screen column of cursor or mark
1707 visualmode( [expr]) String last visual mode used 1710 visualmode( [expr]) String last visual mode used
1708 winbufnr( {nr}) Number buffer number of window {nr} 1711 winbufnr( {nr}) Number buffer number of window {nr}
1709 wincol() Number window column of the cursor 1712 wincol() Number window column of the cursor
1710 winheight( {nr}) Number height of window {nr} 1713 winheight( {nr}) Number height of window {nr}
1714 winwidth( {nr}) Number width of window {nr} 1717 winwidth( {nr}) Number width of window {nr}
1715 writefile({list}, {fname} [, {binary}]) 1718 writefile({list}, {fname} [, {binary}])
1716 Number write list of lines to file {fname} 1719 Number write list of lines to file {fname}
1717 1720
1718 add({list}, {expr}) *add()* 1721 add({list}, {expr}) *add()*
1719 Append the item {expr} to List {list}. Returns the resulting 1722 Append the item {expr} to |List| {list}. Returns the
1720 List. Examples: > 1723 resulting |List|. Examples: >
1721 :let alist = add([1, 2, 3], item) 1724 :let alist = add([1, 2, 3], item)
1722 :call add(mylist, "woodstock") 1725 :call add(mylist, "woodstock")
1723 < Note that when {expr} is a List it is appended as a single 1726 < Note that when {expr} is a |List| it is appended as a single
1724 item. Use |extend()| to concatenate Lists. 1727 item. Use |extend()| to concatenate |List|s.
1725 Use |insert()| to add an item at another position. 1728 Use |insert()| to add an item at another position.
1726 1729
1727 1730
1728 append({lnum}, {expr}) *append()* 1731 append({lnum}, {expr}) *append()*
1729 When {expr} is a List: Append each item of the List as a text 1732 When {expr} is a |List|: Append each item of the |List| as a
1730 line below line {lnum} in the current buffer. 1733 text line below line {lnum} in the current buffer.
1731 Otherwise append {expr} as one text line below line {lnum} in 1734 Otherwise append {expr} as one text line below line {lnum} in
1732 the current buffer. 1735 the current buffer.
1733 {lnum} can be zero to insert a line before the first one. 1736 {lnum} can be zero to insert a line before the first one.
1734 Returns 1 for failure ({lnum} out of range or out of memory), 1737 Returns 1 for failure ({lnum} out of range or out of memory),
1735 0 for success. Example: > 1738 0 for success. Example: >
1889 < If there are less than {nr} characters -1 is returned. 1892 < If there are less than {nr} characters -1 is returned.
1890 If there are exactly {nr} characters the length of the string 1893 If there are exactly {nr} characters the length of the string
1891 is returned. 1894 is returned.
1892 1895
1893 call({func}, {arglist} [, {dict}]) *call()* *E699* 1896 call({func}, {arglist} [, {dict}]) *call()* *E699*
1894 Call function {func} with the items in List {arglist} as 1897 Call function {func} with the items in |List| {arglist} as
1895 arguments. 1898 arguments.
1896 {func} can either be a Funcref or the name of a function. 1899 {func} can either be a |Funcref| or the name of a function.
1897 a:firstline and a:lastline are set to the cursor line. 1900 a:firstline and a:lastline are set to the cursor line.
1898 Returns the return value of the called function. 1901 Returns the return value of the called function.
1899 {dict} is for functions with the "dict" attribute. It will be 1902 {dict} is for functions with the "dict" attribute. It will be
1900 used to set the local variable "self". |Dictionary-function| 1903 used to set the local variable "self". |Dictionary-function|
1901 1904
2007 the horizontal layout is always used. 2010 the horizontal layout is always used.
2008 2011
2009 *copy()* 2012 *copy()*
2010 copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't 2013 copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't
2011 different from using {expr} directly. 2014 different from using {expr} directly.
2012 When {expr} is a List a shallow copy is created. This means 2015 When {expr} is a |List| a shallow copy is created. This means
2013 that the original List can be changed without changing the 2016 that the original |List| can be changed without changing the
2014 copy, and vise versa. But the items are identical, thus 2017 copy, and vise versa. But the items are identical, thus
2015 changing an item changes the contents of both Lists. Also see 2018 changing an item changes the contents of both |List|s. Also
2016 |deepcopy()|. 2019 see |deepcopy()|.
2017 2020
2018 count({comp}, {expr} [, {ic} [, {start}]]) *count()* 2021 count({comp}, {expr} [, {ic} [, {start}]]) *count()*
2019 Return the number of times an item with value {expr} appears 2022 Return the number of times an item with value {expr} appears
2020 in List or Dictionary {comp}. 2023 in |List| or |Dictionary| {comp}.
2021 If {start} is given then start with the item with this index. 2024 If {start} is given then start with the item with this index.
2022 {start} can only be used with a List. 2025 {start} can only be used with a |List|.
2023 When {ic} is given and it's non-zero then case is ignored. 2026 When {ic} is given and it's non-zero then case is ignored.
2024 2027
2025 2028
2026 *cscope_connection()* 2029 *cscope_connection()*
2027 cscope_connection([{num} , {dbpath} [, {prepend}]]) 2030 cscope_connection([{num} , {dbpath} [, {prepend}]])
2078 2081
2079 2082
2080 deepcopy({expr}[, {noref}]) *deepcopy()* *E698* 2083 deepcopy({expr}[, {noref}]) *deepcopy()* *E698*
2081 Make a copy of {expr}. For Numbers and Strings this isn't 2084 Make a copy of {expr}. For Numbers and Strings this isn't
2082 different from using {expr} directly. 2085 different from using {expr} directly.
2083 When {expr} is a List a full copy is created. This means 2086 When {expr} is a |List| a full copy is created. This means
2084 that the original List can be changed without changing the 2087 that the original |List| can be changed without changing the
2085 copy, and vise versa. When an item is a List, a copy for it 2088 copy, and vise versa. When an item is a |List|, a copy for it
2086 is made, recursively. Thus changing an item in the copy does 2089 is made, recursively. Thus changing an item in the copy does
2087 not change the contents of the original List. 2090 not change the contents of the original |List|.
2088 When {noref} is omitted or zero a contained List or Dictionary 2091 When {noref} is omitted or zero a contained |List| or
2089 is only copied once. All references point to this single 2092 |Dictionary| is only copied once. All references point to
2090 copy. With {noref} set to 1 every occurrence of a List or 2093 this single copy. With {noref} set to 1 every occurrence of a
2091 Dictionary results in a new copy. This also means that a 2094 |List| or |Dictionary| results in a new copy. This also means
2092 cyclic reference causes deepcopy() to fail. 2095 that a cyclic reference causes deepcopy() to fail.
2093 *E724* 2096 *E724*
2094 Nesting is possible up to 100 levels. When there is an item 2097 Nesting is possible up to 100 levels. When there is an item
2095 that refers back to a higher level making a deep copy with 2098 that refers back to a higher level making a deep copy with
2096 {noref} set to 1 will fail. 2099 {noref} set to 1 will fail.
2097 Also see |copy()|. 2100 Also see |copy()|.
2098 2101
2099 delete({fname}) *delete()* 2102 delete({fname}) *delete()*
2100 Deletes the file by the name {fname}. The result is a Number, 2103 Deletes the file by the name {fname}. The result is a Number,
2101 which is 0 if the file was deleted successfully, and non-zero 2104 which is 0 if the file was deleted successfully, and non-zero
2102 when the deletion failed. 2105 when the deletion failed.
2103 Use |remove()| to delete an item from a List. 2106 Use |remove()| to delete an item from a |List|.
2104 2107
2105 *did_filetype()* 2108 *did_filetype()*
2106 did_filetype() Returns non-zero when autocommands are being executed and the 2109 did_filetype() Returns non-zero when autocommands are being executed and the
2107 FileType event has been triggered at least once. Can be used 2110 FileType event has been triggered at least once. Can be used
2108 to avoid triggering the FileType event again in the scripts 2111 to avoid triggering the FileType event again in the scripts
2133 The highlight ID can be used with |synIDattr()| to obtain 2136 The highlight ID can be used with |synIDattr()| to obtain
2134 syntax information about the highlighting. 2137 syntax information about the highlighting.
2135 2138
2136 empty({expr}) *empty()* 2139 empty({expr}) *empty()*
2137 Return the Number 1 if {expr} is empty, zero otherwise. 2140 Return the Number 1 if {expr} is empty, zero otherwise.
2138 A List or Dictionary is empty when it does not have any items. 2141 A |List| or |Dictionary| is empty when it does not have any
2139 A Number is empty when its value is zero. 2142 items. A Number is empty when its value is zero.
2140 For a long List this is much faster then comparing the length 2143 For a long |List| this is much faster then comparing the
2141 with zero. 2144 length with zero.
2142 2145
2143 escape({string}, {chars}) *escape()* 2146 escape({string}, {chars}) *escape()*
2144 Escape the characters in {chars} that occur in {string} with a 2147 Escape the characters in {chars} that occur in {string} with a
2145 backslash. Example: > 2148 backslash. Example: >
2146 :echo escape('c:\program files\vim', ' \') 2149 :echo escape('c:\program files\vim', ' \')
2149 2152
2150 < *eval()* 2153 < *eval()*
2151 eval({string}) Evaluate {string} and return the result. Especially useful to 2154 eval({string}) Evaluate {string} and return the result. Especially useful to
2152 turn the result of |string()| back into the original value. 2155 turn the result of |string()| back into the original value.
2153 This works for Numbers, Strings and composites of them. 2156 This works for Numbers, Strings and composites of them.
2154 Also works for Funcrefs that refer to existing functions. 2157 Also works for |Funcref|s that refer to existing functions.
2155 2158
2156 eventhandler() *eventhandler()* 2159 eventhandler() *eventhandler()*
2157 Returns 1 when inside an event handler. That is that Vim got 2160 Returns 1 when inside an event handler. That is that Vim got
2158 interrupted while waiting for the user to type a character, 2161 interrupted while waiting for the user to type a character,
2159 e.g., when dropping a file on Vim. This means interactive 2162 e.g., when dropping a file on Vim. This means interactive
2193 *funcname built-in function (see |functions|) 2196 *funcname built-in function (see |functions|)
2194 or user defined function (see 2197 or user defined function (see
2195 |user-functions|). 2198 |user-functions|).
2196 varname internal variable (see 2199 varname internal variable (see
2197 |internal-variables|). Also works 2200 |internal-variables|). Also works
2198 for |curly-braces-names|, Dictionary 2201 for |curly-braces-names|, |Dictionary|
2199 entries, List items, etc. Beware that 2202 entries, |List| items, etc. Beware
2200 this may cause functions to be 2203 that this may cause functions to be
2201 invoked cause an error message for an 2204 invoked cause an error message for an
2202 invalid expression. 2205 invalid expression.
2203 :cmdname Ex command: built-in command, user 2206 :cmdname Ex command: built-in command, user
2204 command or command modifier |:command|. 2207 command or command modifier |:command|.
2205 Returns: 2208 Returns:
2321 2324
2322 See |glob()| for finding existing files. See |system()| for 2325 See |glob()| for finding existing files. See |system()| for
2323 getting the raw output of an external command. 2326 getting the raw output of an external command.
2324 2327
2325 extend({expr1}, {expr2} [, {expr3}]) *extend()* 2328 extend({expr1}, {expr2} [, {expr3}]) *extend()*
2326 {expr1} and {expr2} must be both Lists or both Dictionaries. 2329 {expr1} and {expr2} must be both |List|s or both Dictionaries.
2327 2330
2328 If they are Lists: Append {expr2} to {expr1}. 2331 If they are |List|s: Append {expr2} to {expr1}.
2329 If {expr3} is given insert the items of {expr2} before item 2332 If {expr3} is given insert the items of {expr2} before item
2330 {expr3} in {expr1}. When {expr3} is zero insert before the 2333 {expr3} in {expr1}. When {expr3} is zero insert before the
2331 first item. When {expr3} is equal to len({expr1}) then 2334 first item. When {expr3} is equal to len({expr1}) then
2332 {expr2} is appended. 2335 {expr2} is appended.
2333 Examples: > 2336 Examples: >
2360 *file_readable()* 2363 *file_readable()*
2361 Obsolete name: file_readable(). 2364 Obsolete name: file_readable().
2362 2365
2363 2366
2364 filter({expr}, {string}) *filter()* 2367 filter({expr}, {string}) *filter()*
2365 {expr} must be a List or a Dictionary. 2368 {expr} must be a |List| or a |Dictionary|.
2366 For each item in {expr} evaluate {string} and when the result 2369 For each item in {expr} evaluate {string} and when the result
2367 is zero remove the item from the List or Dictionary. 2370 is zero remove the item from the |List| or |Dictionary|.
2368 Inside {string} |v:val| has the value of the current item. 2371 Inside {string} |v:val| has the value of the current item.
2369 For a Dictionary |v:key| has the key of the current item. 2372 For a |Dictionary| |v:key| has the key of the current item.
2370 Examples: > 2373 Examples: >
2371 :call filter(mylist, 'v:val !~ "OLD"') 2374 :call filter(mylist, 'v:val !~ "OLD"')
2372 < Removes the items where "OLD" appears. > 2375 < Removes the items where "OLD" appears. >
2373 :call filter(mydict, 'v:key >= 8') 2376 :call filter(mydict, 'v:key >= 8')
2374 < Removes the items with a key below 8. > 2377 < Removes the items with a key below 8. >
2375 :call filter(var, 0) 2378 :call filter(var, 0)
2376 < Removes all the items, thus clears the List or Dictionary. 2379 < Removes all the items, thus clears the |List| or |Dictionary|.
2377 2380
2378 Note that {string} is the result of expression and is then 2381 Note that {string} is the result of expression and is then
2379 used as an expression again. Often it is good to use a 2382 used as an expression again. Often it is good to use a
2380 |literal-string| to avoid having to double backslashes. 2383 |literal-string| to avoid having to double backslashes.
2381 2384
2382 The operation is done in-place. If you want a List or 2385 The operation is done in-place. If you want a |List| or
2383 Dictionary to remain unmodified make a copy first: > 2386 |Dictionary| to remain unmodified make a copy first: >
2384 :let l = filter(copy(mylist), 'v:val =~ "KEEP"') 2387 :let l = filter(copy(mylist), 'v:val =~ "KEEP"')
2385 2388
2386 < Returns {expr}, the List or Dictionary that was filtered. 2389 < Returns {expr}, the |List| or |Dictionary| that was filtered.
2387 When an error is encountered while evaluating {string} no 2390 When an error is encountered while evaluating {string} no
2388 further items in {expr} are processed. 2391 further items in {expr} are processed.
2389 2392
2390 2393
2391 finddir({name}[, {path}[, {count}]]) *finddir()* 2394 finddir({name}[, {path}[, {count}]]) *finddir()*
2475 {only in the Win32, Athena, Motif and GTK GUI versions and the 2478 {only in the Win32, Athena, Motif and GTK GUI versions and the
2476 Win32 console version} 2479 Win32 console version}
2477 2480
2478 2481
2479 function({name}) *function()* *E700* 2482 function({name}) *function()* *E700*
2480 Return a Funcref variable that refers to function {name}. 2483 Return a |Funcref| variable that refers to function {name}.
2481 {name} can be a user defined function or an internal function. 2484 {name} can be a user defined function or an internal function.
2482 2485
2483 2486
2484 garbagecollect() *garbagecollect()* 2487 garbagecollect() *garbagecollect()*
2485 Cleanup unused Lists and Dictionaries that have circular 2488 Cleanup unused |List|s and Dictionaries that have circular
2486 references. There is hardly ever a need to invoke this 2489 references. There is hardly ever a need to invoke this
2487 function, as it is automatically done when Vim runs out of 2490 function, as it is automatically done when Vim runs out of
2488 memory or is waiting for the user to press a key after 2491 memory or is waiting for the user to press a key after
2489 'updatetime'. Items without circular references are always 2492 'updatetime'. Items without circular references are always
2490 freed when they become unused. 2493 freed when they become unused.
2491 This is useful if you have deleted a very big List and/or 2494 This is useful if you have deleted a very big |List| and/or
2492 Dictionary with circular references in a script that runs for 2495 |Dictionary| with circular references in a script that runs
2493 a long time. 2496 for a long time.
2494 2497
2495 get({list}, {idx} [, {default}]) *get()* 2498 get({list}, {idx} [, {default}]) *get()*
2496 Get item {idx} from List {list}. When this item is not 2499 Get item {idx} from |List| {list}. When this item is not
2497 available return {default}. Return zero when {default} is 2500 available return {default}. Return zero when {default} is
2498 omitted. 2501 omitted.
2499 get({dict}, {key} [, {default}]) 2502 get({dict}, {key} [, {default}])
2500 Get item with key {key} from Dictionary {dict}. When this 2503 Get item with key {key} from |Dictionary| {dict}. When this
2501 item is not available return {default}. Return zero when 2504 item is not available return {default}. Return zero when
2502 {default} is omitted. 2505 {default} is omitted.
2503 2506
2504 *getbufline()* 2507 *getbufline()*
2505 getbufline({expr}, {lnum} [, {end}]) 2508 getbufline({expr}, {lnum} [, {end}])
2506 Return a List with the lines starting from {lnum} to {end} 2509 Return a |List| with the lines starting from {lnum} to {end}
2507 (inclusive) in the buffer {expr}. If {end} is omitted, a List 2510 (inclusive) in the buffer {expr}. If {end} is omitted, a
2508 with only the line {lnum} is returned. 2511 |List| with only the line {lnum} is returned.
2509 2512
2510 For the use of {expr}, see |bufname()| above. 2513 For the use of {expr}, see |bufname()| above.
2511 2514
2512 For {lnum} and {end} "$" can be used for the last line of the 2515 For {lnum} and {end} "$" can be used for the last line of the
2513 buffer. Otherwise a number must be used. 2516 buffer. Otherwise a number must be used.
2514 2517
2515 When {lnum} is smaller than 1 or bigger than the number of 2518 When {lnum} is smaller than 1 or bigger than the number of
2516 lines in the buffer, an empty List is returned. 2519 lines in the buffer, an empty |List| is returned.
2517 2520
2518 When {end} is greater than the number of lines in the buffer, 2521 When {end} is greater than the number of lines in the buffer,
2519 it is treated as {end} is set to the number of lines in the 2522 it is treated as {end} is set to the number of lines in the
2520 buffer. When {end} is before {lnum} an empty List is 2523 buffer. When {end} is before {lnum} an empty |List| is
2521 returned. 2524 returned.
2522 2525
2523 This function works only for loaded buffers. For unloaded and 2526 This function works only for loaded buffers. For unloaded and
2524 non-existing buffers, an empty List is returned. 2527 non-existing buffers, an empty |List| is returned.
2525 2528
2526 Example: > 2529 Example: >
2527 :let lines = getbufline(bufnr("myfile"), 1, "$") 2530 :let lines = getbufline(bufnr("myfile"), 1, "$")
2528 2531
2529 getbufvar({expr}, {varname}) *getbufvar()* 2532 getbufvar({expr}, {varname}) *getbufvar()*
2695 To get the line under the cursor: > 2698 To get the line under the cursor: >
2696 getline(".") 2699 getline(".")
2697 < When {lnum} is smaller than 1 or bigger than the number of 2700 < When {lnum} is smaller than 1 or bigger than the number of
2698 lines in the buffer, an empty string is returned. 2701 lines in the buffer, an empty string is returned.
2699 2702
2700 When {end} is given the result is a List where each item is a 2703 When {end} is given the result is a |List| where each item is
2701 line from the current buffer in the range {lnum} to {end}, 2704 a line from the current buffer in the range {lnum} to {end},
2702 including line {end}. 2705 including line {end}.
2703 {end} is used in the same way as {lnum}. 2706 {end} is used in the same way as {lnum}.
2704 Non-existing lines are silently omitted. 2707 Non-existing lines are silently omitted.
2705 When {end} is before {lnum} an empty List is returned. 2708 When {end} is before {lnum} an empty |List| is returned.
2706 Example: > 2709 Example: >
2707 :let start = line('.') 2710 :let start = line('.')
2708 :let end = search("^$") - 1 2711 :let end = search("^$") - 1
2709 :let lines = getline(start, end) 2712 :let lines = getline(start, end)
2710 2713
2827 string. See |feature-list| below. 2830 string. See |feature-list| below.
2828 Also see |exists()|. 2831 Also see |exists()|.
2829 2832
2830 2833
2831 has_key({dict}, {key}) *has_key()* 2834 has_key({dict}, {key}) *has_key()*
2832 The result is a Number, which is 1 if Dictionary {dict} has an 2835 The result is a Number, which is 1 if |Dictionary| {dict} has
2833 entry with key {key}. Zero otherwise. 2836 an entry with key {key}. Zero otherwise.
2834 2837
2835 2838
2836 hasmapto({what} [, {mode}]) *hasmapto()* 2839 hasmapto({what} [, {mode}]) *hasmapto()*
2837 The result is a Number, which is 1 if there is a mapping that 2840 The result is a Number, which is 1 if there is a mapping that
2838 contains {what} in somewhere in the rhs (what it is mapped to) 2841 contains {what} in somewhere in the rhs (what it is mapped to)
2980 |getline()|. 2983 |getline()|.
2981 When {lnum} is invalid -1 is returned. 2984 When {lnum} is invalid -1 is returned.
2982 2985
2983 2986
2984 index({list}, {expr} [, {start} [, {ic}]]) *index()* 2987 index({list}, {expr} [, {start} [, {ic}]]) *index()*
2985 Return the lowest index in List {list} where the item has a 2988 Return the lowest index in |List| {list} where the item has a
2986 value equal to {expr}. 2989 value equal to {expr}.
2987 If {start} is given then start looking at the item with index 2990 If {start} is given then start looking at the item with index
2988 {start} (may be negative for an item relative to the end). 2991 {start} (may be negative for an item relative to the end).
2989 When {ic} is given and it is non-zero, ignore case. Otherwise 2992 When {ic} is given and it is non-zero, ignore case. Otherwise
2990 case must match. 2993 case must match.
3091 The result is a String, which is whatever the user actually 3094 The result is a String, which is whatever the user actually
3092 typed on the command-line in response to the issued prompt. 3095 typed on the command-line in response to the issued prompt.
3093 NOTE: Command-line completion is not supported. 3096 NOTE: Command-line completion is not supported.
3094 3097
3095 insert({list}, {item} [, {idx}]) *insert()* 3098 insert({list}, {item} [, {idx}]) *insert()*
3096 Insert {item} at the start of List {list}. 3099 Insert {item} at the start of |List| {list}.
3097 If {idx} is specified insert {item} before the item with index 3100 If {idx} is specified insert {item} before the item with index
3098 {idx}. If {idx} is zero it goes before the first item, just 3101 {idx}. If {idx} is zero it goes before the first item, just
3099 like omitting {idx}. A negative {idx} is also possible, see 3102 like omitting {idx}. A negative {idx} is also possible, see
3100 |list-index|. -1 inserts just before the last item. 3103 |list-index|. -1 inserts just before the last item.
3101 Returns the resulting List. Examples: > 3104 Returns the resulting |List|. Examples: >
3102 :let mylist = insert([2, 3, 5], 1) 3105 :let mylist = insert([2, 3, 5], 1)
3103 :call insert(mylist, 4, -1) 3106 :call insert(mylist, 4, -1)
3104 :call insert(mylist, 6, len(mylist)) 3107 :call insert(mylist, 6, len(mylist))
3105 < The last example can be done simpler with |add()|. 3108 < The last example can be done simpler with |add()|.
3106 Note that when {item} is a List it is inserted as a single 3109 Note that when {item} is a |List| it is inserted as a single
3107 item. Use |extend()| to concatenate Lists. 3110 item. Use |extend()| to concatenate |List|s.
3108 3111
3109 isdirectory({directory}) *isdirectory()* 3112 isdirectory({directory}) *isdirectory()*
3110 The result is a Number, which is non-zero when a directory 3113 The result is a Number, which is non-zero when a directory
3111 with the name {directory} exists. If {directory} doesn't 3114 with the name {directory} exists. If {directory} doesn't
3112 exist, or isn't a directory, the result is FALSE. {directory} 3115 exist, or isn't a directory, the result is FALSE. {directory}
3113 is any expression, which is used as a String. 3116 is any expression, which is used as a String.
3114 3117
3115 islocked({expr}) *islocked()* 3118 islocked({expr}) *islocked()*
3116 The result is a Number, which is non-zero when {expr} is the 3119 The result is a Number, which is non-zero when {expr} is the
3117 name of a locked variable. 3120 name of a locked variable.
3118 {expr} must be the name of a variable, List item or Dictionary 3121 {expr} must be the name of a variable, |List| item or
3119 entry, not the variable itself! Example: > 3122 |Dictionary| entry, not the variable itself! Example: >
3120 :let alist = [0, ['a', 'b'], 2, 3] 3123 :let alist = [0, ['a', 'b'], 2, 3]
3121 :lockvar 1 alist 3124 :lockvar 1 alist
3122 :echo islocked('alist') " 1 3125 :echo islocked('alist') " 1
3123 :echo islocked('alist[1]') " 0 3126 :echo islocked('alist[1]') " 0
3124 3127
3125 < When {expr} is a variable that does not exist you get an error 3128 < When {expr} is a variable that does not exist you get an error
3126 message. Use |exists()| to check for existance. 3129 message. Use |exists()| to check for existance.
3127 3130
3128 items({dict}) *items()* 3131 items({dict}) *items()*
3129 Return a List with all the key-value pairs of {dict}. Each 3132 Return a |List| with all the key-value pairs of {dict}. Each
3130 List item is a list with two items: the key of a {dict} entry 3133 |List| item is a list with two items: the key of a {dict}
3131 and the value of this entry. The List is in arbitrary order. 3134 entry and the value of this entry. The |List| is in arbitrary
3135 order.
3132 3136
3133 3137
3134 join({list} [, {sep}]) *join()* 3138 join({list} [, {sep}]) *join()*
3135 Join the items in {list} together into one String. 3139 Join the items in {list} together into one String.
3136 When {sep} is specified it is put in between the items. If 3140 When {sep} is specified it is put in between the items. If
3137 {sep} is omitted a single space is used. 3141 {sep} is omitted a single space is used.
3138 Note that {sep} is not added at the end. You might want to 3142 Note that {sep} is not added at the end. You might want to
3139 add it there too: > 3143 add it there too: >
3140 let lines = join(mylist, "\n") . "\n" 3144 let lines = join(mylist, "\n") . "\n"
3141 < String items are used as-is. Lists and Dictionaries are 3145 < String items are used as-is. |List|s and Dictionaries are
3142 converted into a string like with |string()|. 3146 converted into a string like with |string()|.
3143 The opposite function is |split()|. 3147 The opposite function is |split()|.
3144 3148
3145 keys({dict}) *keys()* 3149 keys({dict}) *keys()*
3146 Return a List with all the keys of {dict}. The List is in 3150 Return a |List| with all the keys of {dict}. The |List| is in
3147 arbitrary order. 3151 arbitrary order.
3148 3152
3149 *len()* *E701* 3153 *len()* *E701*
3150 len({expr}) The result is a Number, which is the length of the argument. 3154 len({expr}) The result is a Number, which is the length of the argument.
3151 When {expr} is a String or a Number the length in bytes is 3155 When {expr} is a String or a Number the length in bytes is
3152 used, as with |strlen()|. 3156 used, as with |strlen()|.
3153 When {expr} is a List the number of items in the List is 3157 When {expr} is a |List| the number of items in the |List| is
3154 returned. 3158 returned.
3155 When {expr} is a Dictionary the number of entries in the 3159 When {expr} is a |Dictionary| the number of entries in the
3156 Dictionary is returned. 3160 |Dictionary| is returned.
3157 Otherwise an error is given. 3161 Otherwise an error is given.
3158 3162
3159 *libcall()* *E364* *E368* 3163 *libcall()* *E364* *E368*
3160 libcall({libname}, {funcname}, {argument}) 3164 libcall({libname}, {funcname}, {argument})
3161 Call function {funcname} in the run-time library {libname} 3165 Call function {funcname} in the run-time library {libname}
3257 Return the current time, measured as seconds since 1st Jan 3261 Return the current time, measured as seconds since 1st Jan
3258 1970. See also |strftime()| and |getftime()|. 3262 1970. See also |strftime()| and |getftime()|.
3259 3263
3260 3264
3261 map({expr}, {string}) *map()* 3265 map({expr}, {string}) *map()*
3262 {expr} must be a List or a Dictionary. 3266 {expr} must be a |List| or a |Dictionary|.
3263 Replace each item in {expr} with the result of evaluating 3267 Replace each item in {expr} with the result of evaluating
3264 {string}. 3268 {string}.
3265 Inside {string} |v:val| has the value of the current item. 3269 Inside {string} |v:val| has the value of the current item.
3266 For a Dictionary |v:key| has the key of the current item. 3270 For a |Dictionary| |v:key| has the key of the current item.
3267 Example: > 3271 Example: >
3268 :call map(mylist, '"> " . v:val . " <"') 3272 :call map(mylist, '"> " . v:val . " <"')
3269 < This puts "> " before and " <" after each item in "mylist". 3273 < This puts "> " before and " <" after each item in "mylist".
3270 3274
3271 Note that {string} is the result of an expression and is then 3275 Note that {string} is the result of an expression and is then
3272 used as an expression again. Often it is good to use a 3276 used as an expression again. Often it is good to use a
3273 |literal-string| to avoid having to double backslashes. You 3277 |literal-string| to avoid having to double backslashes. You
3274 still have to double ' quotes 3278 still have to double ' quotes
3275 3279
3276 The operation is done in-place. If you want a List or 3280 The operation is done in-place. If you want a |List| or
3277 Dictionary to remain unmodified make a copy first: > 3281 |Dictionary| to remain unmodified make a copy first: >
3278 :let tlist = map(copy(mylist), ' & . "\t"') 3282 :let tlist = map(copy(mylist), ' & . "\t"')
3279 3283
3280 < Returns {expr}, the List or Dictionary that was filtered. 3284 < Returns {expr}, the |List| or |Dictionary| that was filtered.
3281 When an error is encountered while evaluating {string} no 3285 When an error is encountered while evaluating {string} no
3282 further items in {expr} are processed. 3286 further items in {expr} are processed.
3283 3287
3284 3288
3285 maparg({name}[, {mode}]) *maparg()* 3289 maparg({name}[, {mode}]) *maparg()*
3333 :endif 3337 :endif
3334 < This avoids adding the "_vv" mapping when there already is a 3338 < This avoids adding the "_vv" mapping when there already is a
3335 mapping for "_v" or for "_vvv". 3339 mapping for "_v" or for "_vvv".
3336 3340
3337 match({expr}, {pat}[, {start}[, {count}]]) *match()* 3341 match({expr}, {pat}[, {start}[, {count}]]) *match()*
3338 When {expr} is a List then this returns the index of the first 3342 When {expr} is a |List| then this returns the index of the
3339 item where {pat} matches. Each item is used as a String, 3343 first item where {pat} matches. Each item is used as a
3340 Lists and Dictionaries are used as echoed. 3344 String, |List|s and Dictionaries are used as echoed.
3341 Otherwise, {expr} is used as a String. The result is a 3345 Otherwise, {expr} is used as a String. The result is a
3342 Number, which gives the index (byte offset) in {expr} where 3346 Number, which gives the index (byte offset) in {expr} where
3343 {pat} matches. 3347 {pat} matches.
3344 A match at the first character or List item returns zero. 3348 A match at the first character or |List| item returns zero.
3345 If there is no match -1 is returned. 3349 If there is no match -1 is returned.
3346 Example: > 3350 Example: >
3347 :echo match("testing", "ing") " results in 4 3351 :echo match("testing", "ing") " results in 4
3348 :echo match([1, 'x'], '\a') " results in 2 3352 :echo match([1, 'x'], '\a') " results in 2
3349 < See |string-match| for how {pat} is used. 3353 < See |string-match| for how {pat} is used.
3357 < 3361 <
3358 When {count} is given use the {count}'th match. When a match 3362 When {count} is given use the {count}'th match. When a match
3359 is found in a String the search for the next one starts on 3363 is found in a String the search for the next one starts on
3360 character further. Thus this example results in 1: > 3364 character further. Thus this example results in 1: >
3361 echo match("testing", "..", 0, 2) 3365 echo match("testing", "..", 0, 2)
3362 < In a List the search continues in the next item. 3366 < In a |List| the search continues in the next item.
3363 3367
3364 If {start} is given, the search starts from byte index 3368 If {start} is given, the search starts from byte index
3365 {start} in a String or item {start} in a List. 3369 {start} in a String or item {start} in a |List|.
3366 The result, however, is still the index counted from the 3370 The result, however, is still the index counted from the
3367 first character/item. Example: > 3371 first character/item. Example: >
3368 :echo match("testing", "ing", 2) 3372 :echo match("testing", "ing", 2)
3369 < result is again "4". > 3373 < result is again "4". >
3370 :echo match("testing", "ing", 4) 3374 :echo match("testing", "ing", 4)
3372 :echo match("testing", "t", 2) 3376 :echo match("testing", "t", 2)
3373 < result is "3". 3377 < result is "3".
3374 For a String, if {start} < 0, it will be set to 0. For a list 3378 For a String, if {start} < 0, it will be set to 0. For a list
3375 the index is counted from the end. 3379 the index is counted from the end.
3376 If {start} is out of range (> strlen({expr} for a String or 3380 If {start} is out of range (> strlen({expr} for a String or
3377 > len({expr} for a List) -1 is returned. 3381 > len({expr} for a |List|) -1 is returned.
3378 3382
3379 See |pattern| for the patterns that are accepted. 3383 See |pattern| for the patterns that are accepted.
3380 The 'ignorecase' option is used to set the ignore-caseness of 3384 The 'ignorecase' option is used to set the ignore-caseness of
3381 the pattern. 'smartcase' is NOT used. The matching is always 3385 the pattern. 'smartcase' is NOT used. The matching is always
3382 done like 'magic' is set and 'cpoptions' is empty. 3386 done like 'magic' is set and 'cpoptions' is empty.
3396 The {start}, if given, has the same meaning as for match(). > 3400 The {start}, if given, has the same meaning as for match(). >
3397 :echo matchend("testing", "ing", 2) 3401 :echo matchend("testing", "ing", 2)
3398 < results in "7". > 3402 < results in "7". >
3399 :echo matchend("testing", "ing", 5) 3403 :echo matchend("testing", "ing", 5)
3400 < result is "-1". 3404 < result is "-1".
3401 When {expr} is a List the result is equal to match(). 3405 When {expr} is a |List| the result is equal to match().
3402 3406
3403 matchlist({expr}, {pat}[, {start}[, {count}]]) *matchlist()* 3407 matchlist({expr}, {pat}[, {start}[, {count}]]) *matchlist()*
3404 Same as match(), but return a List. The first item in the 3408 Same as match(), but return a |List|. The first item in the
3405 list is the matched string, same as what matchstr() would 3409 list is the matched string, same as what matchstr() would
3406 return. Following items are submatches, like "\1", "\2", etc. 3410 return. Following items are submatches, like "\1", "\2", etc.
3407 in |:substitute|. 3411 in |:substitute|.
3408 When there is no match an empty list is returned. 3412 When there is no match an empty list is returned.
3409 3413
3415 The {start}, if given, has the same meaning as for match(). > 3419 The {start}, if given, has the same meaning as for match(). >
3416 :echo matchstr("testing", "ing", 2) 3420 :echo matchstr("testing", "ing", 2)
3417 < results in "ing". > 3421 < results in "ing". >
3418 :echo matchstr("testing", "ing", 5) 3422 :echo matchstr("testing", "ing", 5)
3419 < result is "". 3423 < result is "".
3420 When {expr} is a List then the matching item is returned. 3424 When {expr} is a |List| then the matching item is returned.
3421 The type isn't changed, it's not necessarily a String. 3425 The type isn't changed, it's not necessarily a String.
3422 3426
3423 *max()* 3427 *max()*
3424 max({list}) Return the maximum value of all items in {list}. 3428 max({list}) Return the maximum value of all items in {list}.
3425 If {list} is not a list or one of the items in {list} cannot 3429 If {list} is not a list or one of the items in {list} cannot
3426 be used as a Number this results in an error. 3430 be used as a Number this results in an error.
3427 An empty List results in zero. 3431 An empty |List| results in zero.
3428 3432
3429 *min()* 3433 *min()*
3430 min({list}) Return the minumum value of all items in {list}. 3434 min({list}) Return the minumum value of all items in {list}.
3431 If {list} is not a list or one of the items in {list} cannot 3435 If {list} is not a list or one of the items in {list} cannot
3432 be used as a Number this results in an error. 3436 be used as a Number this results in an error.
3433 An empty List results in zero. 3437 An empty |List| results in zero.
3434 3438
3435 *mkdir()* *E749* 3439 *mkdir()* *E749*
3436 mkdir({name} [, {path} [, {prot}]]) 3440 mkdir({name} [, {path} [, {prot}]])
3437 Create directory {name}. 3441 Create directory {name}.
3438 If {path} is "p" then intermediate directories are created as 3442 If {path} is "p" then intermediate directories are created as
3622 otherwise. See |ins-completion-menu|. 3626 otherwise. See |ins-completion-menu|.
3623 3627
3624 3628
3625 *E726* *E727* 3629 *E726* *E727*
3626 range({expr} [, {max} [, {stride}]]) *range()* 3630 range({expr} [, {max} [, {stride}]]) *range()*
3627 Returns a List with Numbers: 3631 Returns a |List| with Numbers:
3628 - If only {expr} is specified: [0, 1, ..., {expr} - 1] 3632 - If only {expr} is specified: [0, 1, ..., {expr} - 1]
3629 - If {max} is specified: [{expr}, {expr} + 1, ..., {max}] 3633 - If {max} is specified: [{expr}, {expr} + 1, ..., {max}]
3630 - If {stride} is specified: [{expr}, {expr} + {stride}, ..., 3634 - If {stride} is specified: [{expr}, {expr} + {stride}, ...,
3631 {max}] (increasing {expr} with {stride} each time, not 3635 {max}] (increasing {expr} with {stride} each time, not
3632 producing a value past {max}). 3636 producing a value past {max}).
3641 range(0) " [] 3645 range(0) " []
3642 range(2, 0) " error! 3646 range(2, 0) " error!
3643 < 3647 <
3644 *readfile()* 3648 *readfile()*
3645 readfile({fname} [, {binary} [, {max}]]) 3649 readfile({fname} [, {binary} [, {max}]])
3646 Read file {fname} and return a List, each line of the file as 3650 Read file {fname} and return a |List|, each line of the file
3647 an item. Lines broken at NL characters. Macintosh files 3651 as an item. Lines broken at NL characters. Macintosh files
3648 separated with CR will result in a single long line (unless a 3652 separated with CR will result in a single long line (unless a
3649 NL appears somewhere). 3653 NL appears somewhere).
3650 When {binary} is equal to "b" binary mode is used: 3654 When {binary} is equal to "b" binary mode is used:
3651 - When the last line ends in a NL an extra empty list item is 3655 - When the last line ends in a NL an extra empty list item is
3652 added. 3656 added.
3746 \ echo remote_read(expand("<amatch>")) 3750 \ echo remote_read(expand("<amatch>"))
3747 :echo remote_send("gvim", ":sleep 10 | echo ". 3751 :echo remote_send("gvim", ":sleep 10 | echo ".
3748 \ 'server2client(expand("<client>"), "HELLO")<CR>') 3752 \ 'server2client(expand("<client>"), "HELLO")<CR>')
3749 < 3753 <
3750 remove({list}, {idx} [, {end}]) *remove()* 3754 remove({list}, {idx} [, {end}]) *remove()*
3751 Without {end}: Remove the item at {idx} from List {list} and 3755 Without {end}: Remove the item at {idx} from |List| {list} and
3752 return it. 3756 return it.
3753 With {end}: Remove items from {idx} to {end} (inclusive) and 3757 With {end}: Remove items from {idx} to {end} (inclusive) and
3754 return a list with these items. When {idx} points to the same 3758 return a list with these items. When {idx} points to the same
3755 item as {end} a list with one item is returned. When {end} 3759 item as {end} a list with one item is returned. When {end}
3756 points to an item before {idx} this is an error. 3760 points to an item before {idx} this is an error.
3775 repeat({expr}, {count}) *repeat()* 3779 repeat({expr}, {count}) *repeat()*
3776 Repeat {expr} {count} times and return the concatenated 3780 Repeat {expr} {count} times and return the concatenated
3777 result. Example: > 3781 result. Example: >
3778 :let seperator = repeat('-', 80) 3782 :let seperator = repeat('-', 80)
3779 < When {count} is zero or negative the result is empty. 3783 < When {count} is zero or negative the result is empty.
3780 When {expr} is a List the result is {expr} concatenated 3784 When {expr} is a |List| the result is {expr} concatenated
3781 {count} times. Example: > 3785 {count} times. Example: >
3782 :let longlist = repeat(['a', 'b'], 3) 3786 :let longlist = repeat(['a', 'b'], 3)
3783 < Results in ['a', 'b', 'a', 'b', 'a', 'b']. 3787 < Results in ['a', 'b', 'a', 'b', 'a', 'b'].
3784 3788
3785 3789
3938 :echo searchpair('{', '', '}', 'bW', 3942 :echo searchpair('{', '', '}', 'bW',
3939 \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"') 3943 \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
3940 < 3944 <
3941 *searchpairpos()* 3945 *searchpairpos()*
3942 searchpairpos({start}, {middle}, {end} [, {flags} [, {skip}]]) 3946 searchpairpos({start}, {middle}, {end} [, {flags} [, {skip}]])
3943 Same as searchpair(), but returns a List with the line and 3947 Same as searchpair(), but returns a |List| with the line and
3944 column position of the match. The first element of the List is 3948 column position of the match. The first element of the |List|
3945 the line number and the second element is the byte index of 3949 is the line number and the second element is the byte index of
3946 the column position of the match. If no match is found, 3950 the column position of the match. If no match is found,
3947 returns [0, 0]. 3951 returns [0, 0].
3948 > 3952 >
3949 :let [lnum,col] = searchpairpos('{', '', '}', 'n') 3953 :let [lnum,col] = searchpairpos('{', '', '}', 'n')
3950 < 3954 <
3951 See |match-parens| for a bigger and more useful example. 3955 See |match-parens| for a bigger and more useful example.
3952 3956
3953 searchpos({pattern} [, {flags}]) *searchpos()* 3957 searchpos({pattern} [, {flags}]) *searchpos()*
3954 Same as search(), but returns a List with the line and column 3958 Same as search(), but returns a |List| with the line and
3955 position of the match. The first element of the List is the 3959 column position of the match. The first element of the |List|
3956 line number and the second element is the byte index of the 3960 is the line number and the second element is the byte index of
3957 column position of the match. If no match is found, returns 3961 the column position of the match. If no match is found,
3958 [0, 0]. 3962 returns [0, 0].
3959 > 3963 >
3960 :let [lnum,col] = searchpos('mypattern', 'n') 3964 :let [lnum,col] = searchpos('mypattern', 'n')
3961 < 3965 <
3962 server2client( {clientid}, {string}) *server2client()* 3966 server2client( {clientid}, {string}) *server2client()*
3963 Send a reply string to {clientid}. The most recent {clientid} 3967 Send a reply string to {clientid}. The most recent {clientid}
4013 When {lnum} is just below the last line the {line} will be 4017 When {lnum} is just below the last line the {line} will be
4014 added as a new line. 4018 added as a new line.
4015 If this succeeds, 0 is returned. If this fails (most likely 4019 If this succeeds, 0 is returned. If this fails (most likely
4016 because {lnum} is invalid) 1 is returned. Example: > 4020 because {lnum} is invalid) 1 is returned. Example: >
4017 :call setline(5, strftime("%c")) 4021 :call setline(5, strftime("%c"))
4018 < When {line} is a List then line {lnum} and following lines 4022 < When {line} is a |List| then line {lnum} and following lines
4019 will be set to the items in the list. Example: > 4023 will be set to the items in the list. Example: >
4020 :call setline(5, ['aaa', 'bbb', 'ccc']) 4024 :call setline(5, ['aaa', 'bbb', 'ccc'])
4021 < This is equivalent to: > 4025 < This is equivalent to: >
4022 :for [n, l] in [[5, 6, 7], ['aaa', 'bbb', 'ccc']] 4026 :for [n, l] in [[5, 6, 7], ['aaa', 'bbb', 'ccc']]
4023 : call setline(n, l) 4027 : call setline(n, l)
4136 sort({list} [, {func}]) *sort()* *E702* 4140 sort({list} [, {func}]) *sort()* *E702*
4137 Sort the items in {list} in-place. Returns {list}. If you 4141 Sort the items in {list} in-place. Returns {list}. If you
4138 want a list to remain unmodified make a copy first: > 4142 want a list to remain unmodified make a copy first: >
4139 :let sortedlist = sort(copy(mylist)) 4143 :let sortedlist = sort(copy(mylist))
4140 < Uses the string representation of each item to sort on. 4144 < Uses the string representation of each item to sort on.
4141 Numbers sort after Strings, Lists after Numbers. 4145 Numbers sort after Strings, |List|s after Numbers.
4142 For sorting text in the current buffer use |:sort|. 4146 For sorting text in the current buffer use |:sort|.
4143 When {func} is given and it is one then case is ignored. 4147 When {func} is given and it is one then case is ignored.
4144 When {func} is a Funcref or a function name, this function is 4148 When {func} is a |Funcref| or a function name, this function
4145 called to compare items. The function is invoked with two 4149 is called to compare items. The function is invoked with two
4146 items as argument and must return zero if they are equal, 1 if 4150 items as argument and must return zero if they are equal, 1 if
4147 the first one sorts after the second one, -1 if the first one 4151 the first one sorts after the second one, -1 if the first one
4148 sorts before the second one. Example: > 4152 sorts before the second one. Example: >
4149 func MyCompare(i1, i2) 4153 func MyCompare(i1, i2)
4150 return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1 4154 return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
4187 'spell' option must be set and the value of 'spelllang' is 4191 'spell' option must be set and the value of 'spelllang' is
4188 used. 4192 used.
4189 4193
4190 *spellsuggest()* 4194 *spellsuggest()*
4191 spellsuggest({word} [, {max} [, {capital}]]) 4195 spellsuggest({word} [, {max} [, {capital}]])
4192 Return a List with spelling suggestions to replace {word}. 4196 Return a |List| with spelling suggestions to replace {word}.
4193 When {max} is given up to this number of suggestions are 4197 When {max} is given up to this number of suggestions are
4194 returned. Otherwise up to 25 suggestions are returned. 4198 returned. Otherwise up to 25 suggestions are returned.
4195 4199
4196 When the {capital} argument is given and it's non-zero only 4200 When the {capital} argument is given and it's non-zero only
4197 suggestions with a leading capital will be given. Use this 4201 suggestions with a leading capital will be given. Use this
4210 'spell' option must be set and the values of 'spelllang' and 4214 'spell' option must be set and the values of 'spelllang' and
4211 'spellsuggest' are used. 4215 'spellsuggest' are used.
4212 4216
4213 4217
4214 split({expr} [, {pattern} [, {keepempty}]]) *split()* 4218 split({expr} [, {pattern} [, {keepempty}]]) *split()*
4215 Make a List out of {expr}. When {pattern} is omitted or empty 4219 Make a |List| out of {expr}. When {pattern} is omitted or
4216 each white-separated sequence of characters becomes an item. 4220 empty each white-separated sequence of characters becomes an
4221 item.
4217 Otherwise the string is split where {pattern} matches, 4222 Otherwise the string is split where {pattern} matches,
4218 removing the matched characters. 4223 removing the matched characters.
4219 When the first or last item is empty it is omitted, unless the 4224 When the first or last item is empty it is omitted, unless the
4220 {keepempty} argument is given and it's non-zero. 4225 {keepempty} argument is given and it's non-zero.
4221 Other empty items are kept when {pattern} matches at least one 4226 Other empty items are kept when {pattern} matches at least one
4452 Unlike ":!cmd" there is no automatic check for changed files. 4457 Unlike ":!cmd" there is no automatic check for changed files.
4453 Use |:checktime| to force a check. 4458 Use |:checktime| to force a check.
4454 4459
4455 4460
4456 tabpagebuflist([{arg}]) *tabpagebuflist()* 4461 tabpagebuflist([{arg}]) *tabpagebuflist()*
4457 The result is a List, where each item is the number of the 4462 The result is a |List|, where each item is the number of the
4458 buffer associated with each window in the current tab page. 4463 buffer associated with each window in the current tab page.
4459 {arg} specifies the number of tab page to be used. When 4464 {arg} specifies the number of tab page to be used. When
4460 omitted the current tab page is used. 4465 omitted the current tab page is used.
4461 When {arg} is invalid the number zero is returned. 4466 When {arg} is invalid the number zero is returned.
4462 To get a list of all buffers in all tabs use this: > 4467 To get a list of all buffers in all tabs use this: >
4523 Refer to |'tags'| for information about how the tags file is 4528 Refer to |'tags'| for information about how the tags file is
4524 located by Vim. Refer to |tags-file-format| for the format of 4529 located by Vim. Refer to |tags-file-format| for the format of
4525 the tags file generated by the different ctags tools. 4530 the tags file generated by the different ctags tools.
4526 4531
4527 *tagfiles()* 4532 *tagfiles()*
4528 tagfiles() Returns a List with the file names used to search for tags for 4533 tagfiles() Returns a |List| with the file names used to search for tags
4529 the current buffer. This is the 'tags' option expanded. 4534 for the current buffer. This is the 'tags' option expanded.
4530 4535
4531 4536
4532 tempname() *tempname()* *temp-file-name* 4537 tempname() *tempname()* *temp-file-name*
4533 The result is a String, which is the name of a file that 4538 The result is a String, which is the name of a file that
4534 doesn't exist. It can be used for a temporary file. The name 4539 doesn't exist. It can be used for a temporary file. The name
4579 :if type(myvar) == type(function("tr")) 4584 :if type(myvar) == type(function("tr"))
4580 :if type(myvar) == type([]) 4585 :if type(myvar) == type([])
4581 :if type(myvar) == type({}) 4586 :if type(myvar) == type({})
4582 4587
4583 values({dict}) *values()* 4588 values({dict}) *values()*
4584 Return a List with all the values of {dict}. The List is in 4589 Return a |List| with all the values of {dict}. The |List| is
4585 arbitrary order. 4590 in arbitrary order.
4586 4591
4587 4592
4588 virtcol({expr}) *virtcol()* 4593 virtcol({expr}) *virtcol()*
4589 The result is a Number, which is the screen column of the file 4594 The result is a Number, which is the screen column of the file
4590 position given with {expr}. That is, the last screen position 4595 position given with {expr}. That is, the last screen position
4591 occupied by the character at that position, when the screen 4596 occupied by the character at that position, when the screen
4592 would be of unlimited width. When there is a <Tab> at the 4597 would be of unlimited width. When there is a <Tab> at the
4593 position, the returned Number will be the column at the end of 4598 position, the returned Number will be the column at the end of
4594 the <Tab>. For example, for a <Tab> in column 1, with 'ts' 4599 the <Tab>. For example, for a <Tab> in column 1, with 'ts'
4595 set to 8, it returns 8. 4600 set to 8, it returns 8.
4601 For the use of {expr} see |col()|. Additionally you can use
4602 [lnum, col]: a |List| with the line and column number.
4596 For the byte position use |col()|. 4603 For the byte position use |col()|.
4597 When Virtual editing is active in the current mode, a position 4604 When Virtual editing is active in the current mode, a position
4598 beyond the end of the line can be returned. |'virtualedit'| 4605 beyond the end of the line can be returned. |'virtualedit'|
4599 The accepted positions are: 4606 The accepted positions are:
4600 . the cursor position 4607 . the cursor position
4686 : exe "normal 50\<C-W>|" 4693 : exe "normal 50\<C-W>|"
4687 :endif 4694 :endif
4688 < 4695 <
4689 *writefile()* 4696 *writefile()*
4690 writefile({list}, {fname} [, {binary}]) 4697 writefile({list}, {fname} [, {binary}])
4691 Write List {list} to file {fname}. Each list item is 4698 Write |List| {list} to file {fname}. Each list item is
4692 separated with a NL. Each list item must be a String or 4699 separated with a NL. Each list item must be a String or
4693 Number. 4700 Number.
4694 When {binary} is equal to "b" binary mode is used: There will 4701 When {binary} is equal to "b" binary mode is used: There will
4695 not be a NL after the last list item. An empty item at the 4702 not be a NL after the last list item. An empty item at the
4696 end does cause the last line in the file to end in a NL. 4703 end does cause the last line in the file to end in a NL.
4928 4935
4929 *:fu* *:function* *E128* *E129* *E123* 4936 *:fu* *:function* *E128* *E129* *E123*
4930 :fu[nction] List all functions and their arguments. 4937 :fu[nction] List all functions and their arguments.
4931 4938
4932 :fu[nction] {name} List function {name}. 4939 :fu[nction] {name} List function {name}.
4933 {name} can also be a Dictionary entry that is a 4940 {name} can also be a |Dictionary| entry that is a
4934 Funcref: > 4941 |Funcref|: >
4935 :function dict.init 4942 :function dict.init
4936 4943
4937 :fu[nction] /{pattern} List functions with a name matching {pattern}. 4944 :fu[nction] /{pattern} List functions with a name matching {pattern}.
4938 Example that lists all functions ending with "File": > 4945 Example that lists all functions ending with "File": >
4939 :function /File$ 4946 :function /File$
4952 :fu[nction][!] {name}([arguments]) [range] [abort] [dict] 4959 :fu[nction][!] {name}([arguments]) [range] [abort] [dict]
4953 Define a new function by the name {name}. The name 4960 Define a new function by the name {name}. The name
4954 must be made of alphanumeric characters and '_', and 4961 must be made of alphanumeric characters and '_', and
4955 must start with a capital or "s:" (see above). 4962 must start with a capital or "s:" (see above).
4956 4963
4957 {name} can also be a Dictionary entry that is a 4964 {name} can also be a |Dictionary| entry that is a
4958 Funcref: > 4965 |Funcref|: >
4959 :function dict.init(arg) 4966 :function dict.init(arg)
4960 < "dict" must be an existing dictionary. The entry 4967 < "dict" must be an existing dictionary. The entry
4961 "init" is added if it didn't exist yet. Otherwise [!] 4968 "init" is added if it didn't exist yet. Otherwise [!]
4962 is required to overwrite an existing function. The 4969 is required to overwrite an existing function. The
4963 result is a |Funcref| to a numbered function. The 4970 result is a |Funcref| to a numbered function. The
4981 4988
4982 When the [abort] argument is added, the function will 4989 When the [abort] argument is added, the function will
4983 abort as soon as an error is detected. 4990 abort as soon as an error is detected.
4984 4991
4985 When the [dict] argument is added, the function must 4992 When the [dict] argument is added, the function must
4986 be invoked through an entry in a Dictionary. The 4993 be invoked through an entry in a |Dictionary|. The
4987 local variable "self" will then be set to the 4994 local variable "self" will then be set to the
4988 dictionary. See |Dictionary-function|. 4995 dictionary. See |Dictionary-function|.
4989 4996
4990 The last used search pattern and the redo command "." 4997 The last used search pattern and the redo command "."
4991 will not be changed by the function. 4998 will not be changed by the function.
4994 :endf[unction] The end of a function definition. Must be on a line 5001 :endf[unction] The end of a function definition. Must be on a line
4995 by its own, without other commands. 5002 by its own, without other commands.
4996 5003
4997 *:delf* *:delfunction* *E130* *E131* 5004 *:delf* *:delfunction* *E130* *E131*
4998 :delf[unction] {name} Delete function {name}. 5005 :delf[unction] {name} Delete function {name}.
4999 {name} can also be a Dictionary entry that is a 5006 {name} can also be a |Dictionary| entry that is a
5000 Funcref: > 5007 |Funcref|: >
5001 :delfunc dict.init 5008 :delfunc dict.init
5002 < This will remove the "init" entry from "dict". The 5009 < This will remove the "init" entry from "dict". The
5003 function is deleted if there are no more references to 5010 function is deleted if there are no more references to
5004 it. 5011 it.
5005 *:retu* *:return* *E133* 5012 *:retu* *:return* *E133*
5024 *a:0* *a:1* *a:000* *E740* 5031 *a:0* *a:1* *a:000* *E740*
5025 Up to 20 arguments can be given, separated by commas. After the named 5032 Up to 20 arguments can be given, separated by commas. After the named
5026 arguments an argument "..." can be specified, which means that more arguments 5033 arguments an argument "..." can be specified, which means that more arguments
5027 may optionally be following. In the function the extra arguments can be used 5034 may optionally be following. In the function the extra arguments can be used
5028 as "a:1", "a:2", etc. "a:0" is set to the number of extra arguments (which 5035 as "a:1", "a:2", etc. "a:0" is set to the number of extra arguments (which
5029 can be 0). "a:000" is set to a List that contains these arguments. Note that 5036 can be 0). "a:000" is set to a |List| that contains these arguments. Note
5030 "a:1" is the same as "a:000[0]". 5037 that "a:1" is the same as "a:000[0]".
5031 *E742* 5038 *E742*
5032 The a: scope and the variables in it cannot be changed, they are fixed. 5039 The a: scope and the variables in it cannot be changed, they are fixed.
5033 However, if a List or Dictionary is used, you can changes their contents. 5040 However, if a |List| or |Dictionary| is used, you can changes their contents.
5034 Thus you can pass a List to a function and have the function add an item to 5041 Thus you can pass a |List| to a function and have the function add an item to
5035 it. If you want to make sure the function cannot change a List or Dictionary 5042 it. If you want to make sure the function cannot change a |List| or
5036 use |:lockvar|. 5043 |Dictionary| use |:lockvar|.
5037 5044
5038 When not using "...", the number of arguments in a function call must be equal 5045 When not using "...", the number of arguments in a function call must be equal
5039 to the number of named arguments. When using "...", the number of arguments 5046 to the number of named arguments. When using "...", the number of arguments
5040 may be larger. 5047 may be larger.
5041 5048
5267 the index can be repeated. 5274 the index can be repeated.
5268 This cannot be used to add an item to a list. 5275 This cannot be used to add an item to a list.
5269 5276
5270 *E711* *E719* 5277 *E711* *E719*
5271 :let {var-name}[{idx1}:{idx2}] = {expr1} *E708* *E709* *E710* 5278 :let {var-name}[{idx1}:{idx2}] = {expr1} *E708* *E709* *E710*
5272 Set a sequence of items in a List to the result of the 5279 Set a sequence of items in a |List| to the result of
5273 expression {expr1}, which must be a list with the 5280 the expression {expr1}, which must be a list with the
5274 correct number of items. 5281 correct number of items.
5275 {idx1} can be omitted, zero is used instead. 5282 {idx1} can be omitted, zero is used instead.
5276 {idx2} can be omitted, meaning the end of the list. 5283 {idx2} can be omitted, meaning the end of the list.
5277 When the selected range of items is partly past the 5284 When the selected range of items is partly past the
5278 end of the list, items will be added. 5285 end of the list, items will be added.
5343 :let &g:{option-name} -= {expr1} 5350 :let &g:{option-name} -= {expr1}
5344 Like above, but only set the global value of an option 5351 Like above, but only set the global value of an option
5345 (if there is one). Works like |:setglobal|. 5352 (if there is one). Works like |:setglobal|.
5346 5353
5347 :let [{name1}, {name2}, ...] = {expr1} *:let-unpack* *E687* *E688* 5354 :let [{name1}, {name2}, ...] = {expr1} *:let-unpack* *E687* *E688*
5348 {expr1} must evaluate to a List. The first item in 5355 {expr1} must evaluate to a |List|. The first item in
5349 the list is assigned to {name1}, the second item to 5356 the list is assigned to {name1}, the second item to
5350 {name2}, etc. 5357 {name2}, etc.
5351 The number of names must match the number of items in 5358 The number of names must match the number of items in
5352 the List. 5359 the |List|.
5353 Each name can be one of the items of the ":let" 5360 Each name can be one of the items of the ":let"
5354 command as mentioned above. 5361 command as mentioned above.
5355 Example: > 5362 Example: >
5356 :let [s, item] = GetItem(s) 5363 :let [s, item] = GetItem(s)
5357 < Detail: {expr1} is evaluated first, then the 5364 < Detail: {expr1} is evaluated first, then the
5365 5372
5366 :let [{name1}, {name2}, ...] .= {expr1} 5373 :let [{name1}, {name2}, ...] .= {expr1}
5367 :let [{name1}, {name2}, ...] += {expr1} 5374 :let [{name1}, {name2}, ...] += {expr1}
5368 :let [{name1}, {name2}, ...] -= {expr1} 5375 :let [{name1}, {name2}, ...] -= {expr1}
5369 Like above, but append/add/subtract the value for each 5376 Like above, but append/add/subtract the value for each
5370 List item. 5377 |List| item.
5371 5378
5372 :let [{name}, ..., ; {lastname}] = {expr1} 5379 :let [{name}, ..., ; {lastname}] = {expr1}
5373 Like |:let-unpack| above, but the List may have more 5380 Like |:let-unpack| above, but the |List| may have more
5374 items than there are names. A list of the remaining 5381 items than there are names. A list of the remaining
5375 items is assigned to {lastname}. If there are no 5382 items is assigned to {lastname}. If there are no
5376 remaining items {lastname} is set to an empty list. 5383 remaining items {lastname} is set to an empty list.
5377 Example: > 5384 Example: >
5378 :let [a, b; rest] = ["aval", "bval", 3, 4] 5385 :let [a, b; rest] = ["aval", "bval", 3, 4]
5379 < 5386 <
5380 :let [{name}, ..., ; {lastname}] .= {expr1} 5387 :let [{name}, ..., ; {lastname}] .= {expr1}
5381 :let [{name}, ..., ; {lastname}] += {expr1} 5388 :let [{name}, ..., ; {lastname}] += {expr1}
5382 :let [{name}, ..., ; {lastname}] -= {expr1} 5389 :let [{name}, ..., ; {lastname}] -= {expr1}
5383 Like above, but append/add/subtract the value for each 5390 Like above, but append/add/subtract the value for each
5384 List item. 5391 |List| item.
5385 *E106* 5392 *E106*
5386 :let {var-name} .. List the value of variable {var-name}. Multiple 5393 :let {var-name} .. List the value of variable {var-name}. Multiple
5387 variable names may be given. Special names recognized 5394 variable names may be given. Special names recognized
5388 here: *E738* 5395 here: *E738*
5389 g: global variables. 5396 g: global variables.
5399 5406
5400 5407
5401 :unl[et][!] {name} ... *:unlet* *:unl* *E108* 5408 :unl[et][!] {name} ... *:unlet* *:unl* *E108*
5402 Remove the internal variable {name}. Several variable 5409 Remove the internal variable {name}. Several variable
5403 names can be given, they are all removed. The name 5410 names can be given, they are all removed. The name
5404 may also be a List or Dictionary item. 5411 may also be a |List| or |Dictionary| item.
5405 With [!] no error message is given for non-existing 5412 With [!] no error message is given for non-existing
5406 variables. 5413 variables.
5407 One or more items from a List can be removed: > 5414 One or more items from a |List| can be removed: >
5408 :unlet list[3] " remove fourth item 5415 :unlet list[3] " remove fourth item
5409 :unlet list[3:] " remove fourth item to last 5416 :unlet list[3:] " remove fourth item to last
5410 < One item from a Dictionary can be removed at a time: > 5417 < One item from a |Dictionary| can be removed at a time: >
5411 :unlet dict['two'] 5418 :unlet dict['two']
5412 :unlet dict.two 5419 :unlet dict.two
5413 5420
5414 :lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv* 5421 :lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv*
5415 Lock the internal variable {name}. Locking means that 5422 Lock the internal variable {name}. Locking means that
5420 :unlet v 5427 :unlet v
5421 < *E741* 5428 < *E741*
5422 If you try to change a locked variable you get an 5429 If you try to change a locked variable you get an
5423 error message: "E741: Value of {name} is locked" 5430 error message: "E741: Value of {name} is locked"
5424 5431
5425 [depth] is relevant when locking a List or Dictionary. 5432 [depth] is relevant when locking a |List| or
5426 It specifies how deep the locking goes: 5433 |Dictionary|. It specifies how deep the locking goes:
5427 1 Lock the List or Dictionary itself, 5434 1 Lock the |List| or |Dictionary| itself,
5428 cannot add or remove items, but can 5435 cannot add or remove items, but can
5429 still change their values. 5436 still change their values.
5430 2 Also lock the values, cannot change 5437 2 Also lock the values, cannot change
5431 the items. If an item is a List or 5438 the items. If an item is a |List| or
5432 Dictionary, cannot add or remove 5439 |Dictionary|, cannot add or remove
5433 items, but can still change the 5440 items, but can still change the
5434 values. 5441 values.
5435 3 Like 2 but for the List/Dictionary in 5442 3 Like 2 but for the |List| /
5436 the List/Dictionary, one level deeper. 5443 |Dictionary| in the |List| /
5437 The default [depth] is 2, thus when {name} is a List 5444 |Dictionary|, one level deeper.
5438 or Dictionary the values cannot be changed. 5445 The default [depth] is 2, thus when {name} is a |List|
5446 or |Dictionary| the values cannot be changed.
5439 *E743* 5447 *E743*
5440 For unlimited depth use [!] and omit [depth]. 5448 For unlimited depth use [!] and omit [depth].
5441 However, there is a maximum depth of 100 to catch 5449 However, there is a maximum depth of 100 to catch
5442 loops. 5450 loops.
5443 5451
5444 Note that when two variables refer to the same List 5452 Note that when two variables refer to the same |List|
5445 and you lock one of them, the List will also be locked 5453 and you lock one of them, the |List| will also be
5446 when used through the other variable. Example: > 5454 locked when used through the other variable. Example:
5455 >
5447 :let l = [0, 1, 2, 3] 5456 :let l = [0, 1, 2, 3]
5448 :let cl = l 5457 :let cl = l
5449 :lockvar l 5458 :lockvar l
5450 :let cl[1] = 99 " won't work! 5459 :let cl[1] = 99 " won't work!
5451 < You may want to make a copy of a list to avoid this. 5460 < You may want to make a copy of a list to avoid this.