Mercurial > vim
comparison runtime/doc/eval.txt @ 55:225cc00b2eda
updated for version 7.0029
author | vimboss |
---|---|
date | Mon, 03 Jan 2005 21:02:03 +0000 |
parents | fdf55076c53f |
children | a97c6902ecd9 |
comparison
equal
deleted
inserted
replaced
54:6bfddb1d126a | 55:225cc00b2eda |
---|---|
1 *eval.txt* For Vim version 7.0aa. Last change: 2004 Dec 10 | 1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 03 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
27 {Vi does not have any of these commands} | 27 {Vi does not have any of these commands} |
28 | 28 |
29 ============================================================================== | 29 ============================================================================== |
30 1. Variables *variables* | 30 1. Variables *variables* |
31 | 31 |
32 There are two types of variables: | 32 There are three types of variables: |
33 | 33 |
34 Number a 32 bit signed number. | 34 Number a 32 bit signed number |
35 String a NUL terminated string of 8-bit unsigned characters. | 35 String a NUL terminated string of 8-bit unsigned characters (bytes) |
36 | 36 Funcref a reference to a function |Funcref| |
37 These are converted automatically, depending on how they are used. | 37 List an ordered sequence of items |List| |
38 | |
39 The Number and String types are converted automatically, depending on how they | |
40 are used. | |
38 | 41 |
39 Conversion from a Number to a String is by making the ASCII representation of | 42 Conversion from a Number to a String is by making the ASCII representation of |
40 the Number. Examples: > | 43 the Number. Examples: > |
41 Number 123 --> String "123" | 44 Number 123 --> String "123" |
42 Number 0 --> String "0" | 45 Number 0 --> String "0" |
62 :if "foo" | 65 :if "foo" |
63 "foo" is converted to 0, which means FALSE. To test for a non-empty string, | 66 "foo" is converted to 0, which means FALSE. To test for a non-empty string, |
64 use strlen(): > | 67 use strlen(): > |
65 :if strlen("foo") | 68 :if strlen("foo") |
66 | 69 |
70 | |
71 Function references ~ | |
72 *Funcref* | |
73 | |
74 A Funcref variable is obtained with the |function()| function. It can be used | |
75 in an expression to invoke the function it refers to by using it in the place | |
76 of a function name, before the parenthesis around the arguments. Example: > | |
77 | |
78 :let Fn = function("MyFunc") | |
79 :echo Fn() | |
80 | |
81 Note that this doesn't work with |:call|, because its argument is not an | |
82 expression. | |
83 The name of the referenced function can be obtained with |string()|. A | |
84 Funcref variable must start with a capital, "s:", "w:" or "b:". | |
85 | |
86 | |
87 Lists ~ | |
88 *List* | |
89 A List is an ordered sequence of items. An item can be of any type. Items | |
90 can be accessed by their index number. Items can be added and removed at any | |
91 position in the sequence. | |
92 | |
93 A List is created with a comma separated list of items in square brackets. | |
94 Example: > | |
95 :let mylist = [1, 'two', 3, "four"] | |
96 | |
97 An item can be any expression. Using a List for an item creates a | |
98 two-dimensional List: > | |
99 :let mylist = [[11, 12], [21, 22], [31, 32]] | |
100 | |
101 An extra comma after the last item is ignored. | |
102 | |
103 An item in the List can be accessed by putting the index in square brackets | |
104 after the List: > | |
105 :let item = mylist[2] " get the third item: 3 | |
106 < | |
107 *list-index* | |
108 Indexes are zero-based, thus the first item has index zero. A negative index | |
109 is counted from the end. Index -1 refers to the last item in the List, -2 to | |
110 the last but one item, etc. > | |
111 :let last = mylist[-1] " get the last item: "four" | |
112 | |
113 A part of the List can be obtained by specifying the first and last index, | |
114 separated by a colon in square brackets: > | |
115 :let smalllist = mylist[2:-1] " get List [3, "four"] | |
116 | |
117 Omitting the first index is similar to zero. Omitting the last index is | |
118 similar to -1. The difference is that there is no error if the items are not | |
119 available. > | |
120 :let endlist = [2:] " from item 2 to the end: [3, "four"] | |
121 :let shortlist = [1:1] " List with one item: ['two'] | |
122 :let otherlist = [:] " make a copy | |
123 | |
124 | |
125 More about variables ~ | |
126 | |
67 If you need to know the type of a variable or expression, use the |type()| | 127 If you need to know the type of a variable or expression, use the |type()| |
68 function. | 128 function. |
69 | 129 |
70 When the '!' flag is included in the 'viminfo' option, global variables that | 130 When the '!' flag is included in the 'viminfo' option, global variables that |
71 start with an uppercase letter, and don't contain a lowercase letter, are | 131 start with an uppercase letter, and don't contain a lowercase letter, are |
120 |expr7| ! expr7 logical NOT | 180 |expr7| ! expr7 logical NOT |
121 - expr7 unary minus | 181 - expr7 unary minus |
122 + expr7 unary plus | 182 + expr7 unary plus |
123 expr8 | 183 expr8 |
124 | 184 |
125 |expr8| expr9[expr1] index in String | 185 |expr8| expr9[expr1] byte of a String or item of a List |
186 expr9[expr1 : expr2] substring of a String or sublist of a List | |
126 | 187 |
127 |expr9| number number constant | 188 |expr9| number number constant |
128 "string" string constant, backslash is special | 189 "string" string constant, backslash is special |
129 'string' string constant | 190 'string' string constant |
191 [expr1, ...] List | |
130 &option option value | 192 &option option value |
131 (expr1) nested expression | 193 (expr1) nested expression |
132 variable internal variable | 194 variable internal variable |
133 va{ria}ble internal variable with curly braces | 195 va{ria}ble internal variable with curly braces |
134 $VAR environment variable | 196 $VAR environment variable |
135 @r contents of register 'r' | 197 @r contents of register 'r' |
136 function(expr1, ...) function call | 198 function(expr1, ...) function call |
199 Funcref(expr1, ...) function call with Funcref variable | |
137 func{ti}on(expr1, ...) function call with curly braces | 200 func{ti}on(expr1, ...) function call with curly braces |
138 | 201 |
139 | 202 |
140 ".." indicates that the operations in this level can be concatenated. | 203 ".." indicates that the operations in this level can be concatenated. |
141 Example: > | 204 Example: > |
299 --9 == 9 | 362 --9 == 9 |
300 | 363 |
301 | 364 |
302 expr8 *expr8* | 365 expr8 *expr8* |
303 ----- | 366 ----- |
304 expr9[expr1] index in String *expr-[]* *E111* | 367 expr9[expr1] item of String or List *expr-[]* *E111* |
305 | 368 |
306 This results in a String that contains the expr1'th single byte from expr9. | 369 If expr9 is a Number or String this results in a String that contains the |
307 expr9 is used as a String, expr1 as a Number. Note that this doesn't work for | 370 expr1'th single byte from expr9. expr9 is used as a String, expr1 as a |
308 multi-byte encodings. | 371 Number. Note that this doesn't recognize multi-byte encodings. |
309 | 372 |
310 Note that index zero gives the first character. This is like it works in C. | 373 Index zero gives the first character. This is like it works in C. Careful: |
311 Careful: text column numbers start with one! Example, to get the character | 374 text column numbers start with one! Example, to get the character under the |
312 under the cursor: > | 375 cursor: > |
313 :let c = getline(line("."))[col(".") - 1] | 376 :let c = getline(line("."))[col(".") - 1] |
314 | 377 |
315 If the length of the String is less than the index, the result is an empty | 378 If the length of the String is less than the index, the result is an empty |
316 String. | 379 String. A negative index always results in an empty string (reason: backwards |
380 compatibility). Use [-1:] to get the last byte. | |
381 | |
382 If expr9 is a List then it results the item at index expr1. See |list-index| | |
383 for possible index values. If the index is out of range this results in an | |
384 error. Example: > | |
385 :let item = mylist[-1] " get last item | |
386 | |
387 Generally, if a List index is equal to or higher than the length of the List, | |
388 or more negative than the length of the List, this results in an error. | |
389 | |
390 expr9[expr1a : expr1b] substring or sublist *expr-[:]* | |
391 | |
392 If expr9 is a Number or String this results in the substring with the bytes | |
393 from expr1a to and including expr1b. expr9 is used as a String, expr1a and | |
394 expr1b are used as a Number. Note that this doesn't recognize multi-byte | |
395 encodings. | |
396 | |
397 If expr1a is omitted zero is used. If expr1b is omitted the length of the | |
398 string minus one is used. | |
399 | |
400 A negative number can be used to measure from the end of the string. -1 is | |
401 the last character, -2 the last but one, etc. | |
402 | |
403 If an index goes out of range for the string characters are omitted. If | |
404 expr1b is smaller than expr1a the result is an empty string. | |
405 | |
406 Examples: > | |
407 :let c = name[-1:] " last byte of a string | |
408 :let c = name[-2:-2] " last but one byte of a string | |
409 :let s = line(".")[4:] " from the fifth byte to the end | |
410 :let s = s[:-3] " remove last two bytes | |
411 | |
412 If expr9 is a List this results in a new List with the items indicated by the | |
413 indexes expr1a and expr1b. This works like with a String, as explained just | |
414 above, except that indexes out of range cause an error. Examples: > | |
415 :let l = mylist[:3] " first four items | |
416 :let l = mylist[4:4] " List with one item | |
417 :let l = mylist[:] " shallow copy of a List | |
418 | |
419 Using expr9[expr1] or expr9[expr1a : expr1b] on a Funcref results in an error. | |
317 | 420 |
318 *expr9* | 421 *expr9* |
319 number | 422 number |
320 ------ | 423 ------ |
321 number number constant *expr-number* | 424 number number constant *expr-number* |
804 | 907 |
805 (Use CTRL-] on the function name to jump to the full explanation) | 908 (Use CTRL-] on the function name to jump to the full explanation) |
806 | 909 |
807 USAGE RESULT DESCRIPTION ~ | 910 USAGE RESULT DESCRIPTION ~ |
808 | 911 |
809 append( {lnum}, {string}) Number append {string} below line {lnum} | 912 append( {lnum}, {string}) Number append {string} below line {lnum} |
913 append( {list}, {item}) List append {item} to List {list} | |
810 argc() Number number of files in the argument list | 914 argc() Number number of files in the argument list |
811 argidx() Number current index in the argument list | 915 argidx() Number current index in the argument list |
812 argv( {nr}) String {nr} entry of the argument list | 916 argv( {nr}) String {nr} entry of the argument list |
813 browse( {save}, {title}, {initdir}, {default}) | 917 browse( {save}, {title}, {initdir}, {default}) |
814 String put up a file requester | 918 String put up a file requester |
815 browsedir( {title}, {initdir}) String put up a directory requester | 919 browsedir( {title}, {initdir}) String put up a directory requester |
816 bufexists( {expr}) Number TRUE if buffer {expr} exists | 920 bufexists( {expr}) Number TRUE if buffer {expr} exists |
817 buflisted( {expr}) Number TRUE if buffer {expr} is listed | 921 buflisted( {expr}) Number TRUE if buffer {expr} is listed |
818 bufloaded( {expr}) Number TRUE if buffer {expr} is loaded | 922 bufloaded( {expr}) Number TRUE if buffer {expr} is loaded |
819 bufname( {expr}) String Name of the buffer {expr} | 923 bufname( {expr}) String Name of the buffer {expr} |
820 bufnr( {expr}) Number Number of the buffer {expr} | 924 bufnr( {expr}) Number Number of the buffer {expr} |
821 bufwinnr( {expr}) Number window number of buffer {expr} | 925 bufwinnr( {expr}) Number window number of buffer {expr} |
822 byte2line( {byte}) Number line number at byte count {byte} | 926 byte2line( {byte}) Number line number at byte count {byte} |
823 byteidx( {expr}, {nr}) Number byte index of {nr}'th char in {expr} | 927 byteidx( {expr}, {nr}) Number byte index of {nr}'th char in {expr} |
824 char2nr( {expr}) Number ASCII value of first char in {expr} | 928 char2nr( {expr}) Number ASCII value of first char in {expr} |
825 cindent( {lnum}) Number C indent for line {lnum} | 929 cindent( {lnum}) Number C indent for line {lnum} |
826 col( {expr}) Number column nr of cursor or mark | 930 col( {expr}) Number column nr of cursor or mark |
827 confirm( {msg} [, {choices} [, {default} [, {type}]]]) | 931 confirm( {msg} [, {choices} [, {default} [, {type}]]]) |
828 Number number of choice picked by user | 932 Number number of choice picked by user |
933 copy( {expr}) any make a shallow copy of {expr} | |
829 cscope_connection( [{num} , {dbpath} [, {prepend}]]) | 934 cscope_connection( [{num} , {dbpath} [, {prepend}]]) |
830 Number checks existence of cscope connection | 935 Number checks existence of cscope connection |
831 cursor( {lnum}, {col}) Number position cursor at {lnum}, {col} | 936 cursor( {lnum}, {col}) Number position cursor at {lnum}, {col} |
937 deepcopy( {expr}) any make a full copy of {expr} | |
832 delete( {fname}) Number delete file {fname} | 938 delete( {fname}) Number delete file {fname} |
833 did_filetype() Number TRUE if FileType autocommand event used | 939 did_filetype() Number TRUE if FileType autocommand event used |
834 diff_filler( {lnum}) Number diff filler lines about {lnum} | 940 diff_filler( {lnum}) Number diff filler lines about {lnum} |
835 diff_hlID( {lnum}, {col}) Number diff highlighting at {lnum}/{col} | 941 diff_hlID( {lnum}, {col}) Number diff highlighting at {lnum}/{col} |
836 escape( {string}, {chars}) String escape {chars} in {string} with '\' | 942 escape( {string}, {chars}) String escape {chars} in {string} with '\' |
837 eventhandler( ) Number TRUE if inside an event handler | 943 eventhandler( ) Number TRUE if inside an event handler |
838 executable( {expr}) Number 1 if executable {expr} exists | 944 executable( {expr}) Number 1 if executable {expr} exists |
839 exists( {expr}) Number TRUE if {expr} exists | 945 exists( {expr}) Number TRUE if {expr} exists |
840 expand( {expr}) String expand special keywords in {expr} | 946 expand( {expr}) String expand special keywords in {expr} |
841 filereadable( {file}) Number TRUE if {file} is a readable file | 947 filereadable( {file}) Number TRUE if {file} is a readable file |
842 findfile( {name}[, {path}[, {count}]]) | 948 findfile( {name}[, {path}[, {count}]]) |
843 String Find fine {name} in {path} | 949 String Find fine {name} in {path} |
844 filewritable( {file}) Number TRUE if {file} is a writable file | 950 filewritable( {file}) Number TRUE if {file} is a writable file |
845 fnamemodify( {fname}, {mods}) String modify file name | 951 fnamemodify( {fname}, {mods}) String modify file name |
846 foldclosed( {lnum}) Number first line of fold at {lnum} if closed | 952 foldclosed( {lnum}) Number first line of fold at {lnum} if closed |
847 foldclosedend( {lnum}) Number last line of fold at {lnum} if closed | 953 foldclosedend( {lnum}) Number last line of fold at {lnum} if closed |
848 foldlevel( {lnum}) Number fold level at {lnum} | 954 foldlevel( {lnum}) Number fold level at {lnum} |
849 foldtext( ) String line displayed for closed fold | 955 foldtext( ) String line displayed for closed fold |
850 foreground( ) Number bring the Vim window to the foreground | 956 foreground( ) Number bring the Vim window to the foreground |
851 getchar( [expr]) Number get one character from the user | 957 function( {name}) Funcref reference to function {name} |
852 getcharmod( ) Number modifiers for the last typed character | 958 getchar( [expr]) Number get one character from the user |
959 getcharmod( ) Number modifiers for the last typed character | |
853 getbufvar( {expr}, {varname}) variable {varname} in buffer {expr} | 960 getbufvar( {expr}, {varname}) variable {varname} in buffer {expr} |
854 getcmdline() String return the current command-line | 961 getcmdline() String return the current command-line |
855 getcmdpos() Number return cursor position in command-line | 962 getcmdpos() Number return cursor position in command-line |
856 getcwd() String the current working directory | 963 getcwd() String the current working directory |
857 getfperm( {fname}) String file permissions of file {fname} | 964 getfperm( {fname}) String file permissions of file {fname} |
858 getfsize( {fname}) Number size in bytes of file {fname} | 965 getfsize( {fname}) Number size in bytes of file {fname} |
859 getfontname( [{name}]) String name of font being used | 966 getfontname( [{name}]) String name of font being used |
860 getftime( {fname}) Number last modification time of file | 967 getftime( {fname}) Number last modification time of file |
861 getftype( {fname}) String description of type of file {fname} | 968 getftype( {fname}) String description of type of file {fname} |
862 getline( {lnum}) String line {lnum} from current buffer | 969 getline( {lnum}) String line {lnum} from current buffer |
863 getreg( [{regname}]) String contents of register | 970 getreg( [{regname}]) String contents of register |
864 getregtype( [{regname}]) String type of register | 971 getregtype( [{regname}]) String type of register |
865 getwinposx() Number X coord in pixels of GUI Vim window | 972 getwinposx() Number X coord in pixels of GUI Vim window |
866 getwinposy() Number Y coord in pixels of GUI Vim window | 973 getwinposy() Number Y coord in pixels of GUI Vim window |
867 getwinvar( {nr}, {varname}) variable {varname} in window {nr} | 974 getwinvar( {nr}, {varname}) variable {varname} in window {nr} |
868 glob( {expr}) String expand file wildcards in {expr} | 975 glob( {expr}) String expand file wildcards in {expr} |
869 globpath( {path}, {expr}) String do glob({expr}) for all dirs in {path} | 976 globpath( {path}, {expr}) String do glob({expr}) for all dirs in {path} |
874 histget( {history} [, {index}]) String get the item {index} from a history | 981 histget( {history} [, {index}]) String get the item {index} from a history |
875 histnr( {history}) Number highest index of a history | 982 histnr( {history}) Number highest index of a history |
876 hlexists( {name}) Number TRUE if highlight group {name} exists | 983 hlexists( {name}) Number TRUE if highlight group {name} exists |
877 hlID( {name}) Number syntax ID of highlight group {name} | 984 hlID( {name}) Number syntax ID of highlight group {name} |
878 hostname() String name of the machine Vim is running on | 985 hostname() String name of the machine Vim is running on |
879 iconv( {expr}, {from}, {to}) String convert encoding of {expr} | 986 iconv( {expr}, {from}, {to}) String convert encoding of {expr} |
880 indent( {lnum}) Number indent of line {lnum} | 987 indent( {lnum}) Number indent of line {lnum} |
881 input( {prompt} [, {text}]) String get input from the user | 988 input( {prompt} [, {text}]) String get input from the user |
882 inputdialog( {p} [, {t} [, {c}]]) String like input() but in a GUI dialog | 989 inputdialog( {p} [, {t} [, {c}]]) String like input() but in a GUI dialog |
883 inputrestore() Number restore typeahead | 990 inputrestore() Number restore typeahead |
884 inputsave() Number save and clear typeahead | 991 inputsave() Number save and clear typeahead |
885 inputsecret( {prompt} [, {text}]) String like input() but hiding the text | 992 inputsecret( {prompt} [, {text}]) String like input() but hiding the text |
993 insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] | |
886 isdirectory( {directory}) Number TRUE if {directory} is a directory | 994 isdirectory( {directory}) Number TRUE if {directory} is a directory |
887 libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg} | 995 len( {expr}) Number the length of {expr} |
996 libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg} | |
888 libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number | 997 libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number |
889 line( {expr}) Number line nr of cursor, last line or mark | 998 line( {expr}) Number line nr of cursor, last line or mark |
890 line2byte( {lnum}) Number byte count of line {lnum} | 999 line2byte( {lnum}) Number byte count of line {lnum} |
891 lispindent( {lnum}) Number Lisp indent for line {lnum} | 1000 lispindent( {lnum}) Number Lisp indent for line {lnum} |
892 localtime() Number current time | 1001 localtime() Number current time |
893 maparg( {name}[, {mode}]) String rhs of mapping {name} in mode {mode} | 1002 maparg( {name}[, {mode}]) String rhs of mapping {name} in mode {mode} |
894 mapcheck( {name}[, {mode}]) String check for mappings matching {name} | 1003 mapcheck( {name}[, {mode}]) String check for mappings matching {name} |
895 match( {expr}, {pat}[, {start}[, {count}]]) | 1004 match( {expr}, {pat}[, {start}[, {count}]]) |
896 Number position where {pat} matches in {expr} | 1005 Number position where {pat} matches in {expr} |
897 matchend( {expr}, {pat}[, {start}[, {count}]]) | 1006 matchend( {expr}, {pat}[, {start}[, {count}]]) |
898 Number position where {pat} ends in {expr} | 1007 Number position where {pat} ends in {expr} |
899 matchstr( {expr}, {pat}[, {start}[, {count}]]) | 1008 matchstr( {expr}, {pat}[, {start}[, {count}]]) |
900 String {count}'th match of {pat} in {expr} | 1009 String {count}'th match of {pat} in {expr} |
901 mode() String current editing mode | 1010 mode() String current editing mode |
902 nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum} | 1011 nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum} |
903 nr2char( {expr}) String single char with ASCII value {expr} | 1012 nr2char( {expr}) String single char with ASCII value {expr} |
904 prevnonblank( {lnum}) Number line nr of non-blank line <= {lnum} | 1013 prevnonblank( {lnum}) Number line nr of non-blank line <= {lnum} |
905 remote_expr( {server}, {string} [, {idvar}]) | 1014 remote_expr( {server}, {string} [, {idvar}]) |
906 String send expression | 1015 String send expression |
908 remote_peek( {serverid} [, {retvar}]) | 1017 remote_peek( {serverid} [, {retvar}]) |
909 Number check for reply string | 1018 Number check for reply string |
910 remote_read( {serverid}) String read reply string | 1019 remote_read( {serverid}) String read reply string |
911 remote_send( {server}, {string} [, {idvar}]) | 1020 remote_send( {server}, {string} [, {idvar}]) |
912 String send key sequence | 1021 String send key sequence |
913 rename( {from}, {to}) Number rename (move) file from {from} to {to} | 1022 remove( {list}, {idx}) any remove item {idx} from {list} |
914 repeat( {expr}, {count}) String repeat {expr} {count} times | 1023 rename( {from}, {to}) Number rename (move) file from {from} to {to} |
915 resolve( {filename}) String get filename a shortcut points to | 1024 repeat( {expr}, {count}) String repeat {expr} {count} times |
916 search( {pattern} [, {flags}]) Number search for {pattern} | 1025 resolve( {filename}) String get filename a shortcut points to |
1026 search( {pattern} [, {flags}]) Number search for {pattern} | |
917 searchpair( {start}, {middle}, {end} [, {flags} [, {skip}]]) | 1027 searchpair( {start}, {middle}, {end} [, {flags} [, {skip}]]) |
918 Number search for other end of start/end pair | 1028 Number search for other end of start/end pair |
919 server2client( {clientid}, {string}) | 1029 server2client( {clientid}, {string}) |
920 Number send reply string | 1030 Number send reply string |
921 serverlist() String get a list of available servers | 1031 serverlist() String get a list of available servers |
922 setbufvar( {expr}, {varname}, {val}) set {varname} in buffer {expr} to {val} | 1032 setbufvar( {expr}, {varname}, {val}) set {varname} in buffer {expr} to {val} |
923 setcmdpos( {pos}) Number set cursor position in command-line | 1033 setcmdpos( {pos}) Number set cursor position in command-line |
924 setline( {lnum}, {line}) Number set line {lnum} to {line} | 1034 setline( {lnum}, {line}) Number set line {lnum} to {line} |
925 setreg( {n}, {v}[, {opt}]) Number set register to value and type | 1035 setreg( {n}, {v}[, {opt}]) Number set register to value and type |
926 setwinvar( {nr}, {varname}, {val}) set {varname} in window {nr} to {val} | 1036 setwinvar( {nr}, {varname}, {val}) set {varname} in window {nr} to {val} |
927 simplify( {filename}) String simplify filename as much as possible | 1037 simplify( {filename}) String simplify filename as much as possible |
928 strftime( {format}[, {time}]) String time in specified format | 1038 strftime( {format}[, {time}]) String time in specified format |
929 stridx( {haystack}, {needle}) Number first index of {needle} in {haystack} | 1039 stridx( {haystack}, {needle}) Number first index of {needle} in {haystack} |
1040 string( {expr}) String {expr} converted to a String | |
930 strlen( {expr}) Number length of the String {expr} | 1041 strlen( {expr}) Number length of the String {expr} |
931 strpart( {src}, {start}[, {len}]) | 1042 strpart( {src}, {start}[, {len}]) |
932 String {len} characters of {src} at {start} | 1043 String {len} characters of {src} at {start} |
933 strridx( {haystack}, {needle}) Number last index of {needle} in {haystack} | 1044 strridx( {haystack}, {needle}) Number last index of {needle} in {haystack} |
934 strtrans( {expr}) String translate string to make it printable | 1045 strtrans( {expr}) String translate string to make it printable |
935 submatch( {nr}) String specific match in ":substitute" | 1046 submatch( {nr}) String specific match in ":substitute" |
936 substitute( {expr}, {pat}, {sub}, {flags}) | 1047 substitute( {expr}, {pat}, {sub}, {flags}) |
937 String all {pat} in {expr} replaced with {sub} | 1048 String all {pat} in {expr} replaced with {sub} |
938 synID( {lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col} | 1049 synID( {lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col} |
939 synIDattr( {synID}, {what} [, {mode}]) | 1050 synIDattr( {synID}, {what} [, {mode}]) |
940 String attribute {what} of syntax ID {synID} | 1051 String attribute {what} of syntax ID {synID} |
951 winbufnr( {nr}) Number buffer number of window {nr} | 1062 winbufnr( {nr}) Number buffer number of window {nr} |
952 wincol() Number window column of the cursor | 1063 wincol() Number window column of the cursor |
953 winheight( {nr}) Number height of window {nr} | 1064 winheight( {nr}) Number height of window {nr} |
954 winline() Number window line of the cursor | 1065 winline() Number window line of the cursor |
955 winnr() Number number of current window | 1066 winnr() Number number of current window |
956 winrestcmd() String returns command to restore window sizes | 1067 winrestcmd() String returns command to restore window sizes |
957 winwidth( {nr}) Number width of window {nr} | 1068 winwidth( {nr}) Number width of window {nr} |
958 | 1069 |
959 append({lnum}, {string}) *append()* | 1070 append({expr1}, {expr2}) *append()* |
960 Append the text {string} after line {lnum} in the current | 1071 If {expr1} is a List: Append the item {expr2} to List {expr1}. |
961 buffer. {lnum} can be zero, to insert a line before the first | 1072 Returns the resulting List. Examples: > |
962 one. Returns 1 for failure ({lnum} out of range) or 0 for | 1073 :let alist = append([1, 2, 3], item) |
963 success. | 1074 :call append(mylist, "woodstock") |
964 | 1075 < Note that when {expr2} is a List it is appended as a single |
1076 item. Use |extend()| to concatenate Lists. | |
1077 | |
1078 When {expr1} is not a List: Append the text {expr2} after line | |
1079 {expr1} in the current buffer. {expr1} can be zero, to insert | |
1080 a line before the first one. Returns 1 for failure ({expr1} | |
1081 out of range or out of memory), 0 for success. Example: > | |
1082 :let failed = append(line('$'), "# THE END") | |
1083 < | |
965 *argc()* | 1084 *argc()* |
966 argc() The result is the number of files in the argument list of the | 1085 argc() The result is the number of files in the argument list of the |
967 current window. See |arglist|. | 1086 current window. See |arglist|. |
968 | 1087 |
969 *argidx()* | 1088 *argidx()* |
1203 the buttons are always put vertically. Otherwise, confirm() | 1322 the buttons are always put vertically. Otherwise, confirm() |
1204 tries to put the buttons in one horizontal line. If they | 1323 tries to put the buttons in one horizontal line. If they |
1205 don't fit, a vertical layout is used anyway. For some systems | 1324 don't fit, a vertical layout is used anyway. For some systems |
1206 the horizontal layout is always used. | 1325 the horizontal layout is always used. |
1207 | 1326 |
1327 *copy()* | |
1328 copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't | |
1329 different from using {expr} directly. | |
1330 When {expr} is a List a shallow copy is created. This means | |
1331 that the original List can be changed without changing the | |
1332 copy, and vise versa. But the items are identical, thus | |
1333 changing an item changes the contents of both Lists. Also see | |
1334 |deepcopy()|. | |
1335 | |
1208 *cscope_connection()* | 1336 *cscope_connection()* |
1209 cscope_connection([{num} , {dbpath} [, {prepend}]]) | 1337 cscope_connection([{num} , {dbpath} [, {prepend}]]) |
1210 Checks for the existence of a |cscope| connection. If no | 1338 Checks for the existence of a |cscope| connection. If no |
1211 parameters are specified, then the function returns: | 1339 parameters are specified, then the function returns: |
1212 0, if cscope was not available (not compiled in), or | 1340 0, if cscope was not available (not compiled in), or |
1255 If {col} is greater than the number of characters in the line, | 1383 If {col} is greater than the number of characters in the line, |
1256 the cursor will be positioned at the last character in the | 1384 the cursor will be positioned at the last character in the |
1257 line. | 1385 line. |
1258 If {col} is zero, the cursor will stay in the current column. | 1386 If {col} is zero, the cursor will stay in the current column. |
1259 | 1387 |
1260 *delete()* | 1388 |
1261 delete({fname}) Deletes the file by the name {fname}. The result is a Number, | 1389 deepcopy({expr}) *deepcopy()* |
1390 Make a copy of {expr}. For Numbers and Strings this isn't | |
1391 different from using {expr} directly. | |
1392 When {expr} is a List a full copy is created. This means | |
1393 that the original List can be changed without changing the | |
1394 copy, and vise versa. When an item is a List, a copy for it | |
1395 is made, recursively. Thus changing an item in the copy does | |
1396 not change the contents of the original List. | |
1397 Also see |copy()|. | |
1398 | |
1399 delete({fname}) *delete()* | |
1400 Deletes the file by the name {fname}. The result is a Number, | |
1262 which is 0 if the file was deleted successfully, and non-zero | 1401 which is 0 if the file was deleted successfully, and non-zero |
1263 when the deletion failed. | 1402 when the deletion failed. |
1403 Use |remove()| to delete an item from a List. | |
1264 | 1404 |
1265 *did_filetype()* | 1405 *did_filetype()* |
1266 did_filetype() Returns non-zero when autocommands are being executed and the | 1406 did_filetype() Returns non-zero when autocommands are being executed and the |
1267 FileType event has been triggered at least once. Can be used | 1407 FileType event has been triggered at least once. Can be used |
1268 to avoid triggering the FileType event again in the scripts | 1408 to avoid triggering the FileType event again in the scripts |
1542 On Win32 systems this might not work, the OS does not always | 1682 On Win32 systems this might not work, the OS does not always |
1543 allow a window to bring itself to the foreground. Use | 1683 allow a window to bring itself to the foreground. Use |
1544 |remote_foreground()| instead. | 1684 |remote_foreground()| instead. |
1545 {only in the Win32, Athena, Motif and GTK GUI versions and the | 1685 {only in the Win32, Athena, Motif and GTK GUI versions and the |
1546 Win32 console version} | 1686 Win32 console version} |
1687 | |
1688 function({name}) *function()* | |
1689 Return a Funcref variable that refers to function {name}. | |
1690 {name} can be a user defined function or an internal function. | |
1547 | 1691 |
1548 getchar([expr]) *getchar()* | 1692 getchar([expr]) *getchar()* |
1549 Get a single character from the user. If it is an 8-bit | 1693 Get a single character from the user. If it is an 8-bit |
1550 character, the result is a number. Otherwise a String is | 1694 character, the result is a number. Otherwise a String is |
1551 returned with the encoded character. For a special key it's a | 1695 returned with the encoded character. For a special key it's a |
1993 b) the user's response will not be recorded on the input | 2137 b) the user's response will not be recorded on the input |
1994 |history| stack. | 2138 |history| stack. |
1995 The result is a String, which is whatever the user actually | 2139 The result is a String, which is whatever the user actually |
1996 typed on the command-line in response to the issued prompt. | 2140 typed on the command-line in response to the issued prompt. |
1997 | 2141 |
2142 insert({list}, {item} [, {idx}]) *insert()* | |
2143 Insert {item} at the start of List {list}. | |
2144 If {idx} is specified insert {item} before the item with index | |
2145 {idx}. If {idx} is zero it goes before the first item, just | |
2146 like omitting {idx}. A negative {idx} is also possible, see | |
2147 |list-index|. -1 inserts just before the last item. | |
2148 Returns the resulting List. Examples: > | |
2149 :let mylist = insert([2, 3, 5], 1) | |
2150 :call insert(mylist, 4, -1) | |
2151 :call insert(mylist, 6, len(mylist)) | |
2152 < The last example can be done simpler with |append()|. | |
2153 Note that when {item} is a List it is inserted as a single | |
2154 item. Use |extend()| to concatenate Lists. | |
2155 | |
1998 isdirectory({directory}) *isdirectory()* | 2156 isdirectory({directory}) *isdirectory()* |
1999 The result is a Number, which is non-zero when a directory | 2157 The result is a Number, which is non-zero when a directory |
2000 with the name {directory} exists. If {directory} doesn't | 2158 with the name {directory} exists. If {directory} doesn't |
2001 exist, or isn't a directory, the result is FALSE. {directory} | 2159 exist, or isn't a directory, the result is FALSE. {directory} |
2002 is any expression, which is used as a String. | 2160 is any expression, which is used as a String. |
2161 | |
2162 *len()* | |
2163 len({expr}) The result is a Number, which is the length of the argument. | |
2164 When {expr} is a String or a Number the length in bytes is | |
2165 used, as with |strlen()|. | |
2166 When {expr} is a List the number of items in the List is | |
2167 returned. | |
2168 Otherwise an error is given. | |
2003 | 2169 |
2004 *libcall()* *E364* *E368* | 2170 *libcall()* *E364* *E368* |
2005 libcall({libname}, {funcname}, {argument}) | 2171 libcall({libname}, {funcname}, {argument}) |
2006 Call function {funcname} in the run-time library {libname} | 2172 Call function {funcname} in the run-time library {libname} |
2007 with single argument {argument}. | 2173 with single argument {argument}. |
2316 \ echo remote_read(expand("<amatch>")) | 2482 \ echo remote_read(expand("<amatch>")) |
2317 :echo remote_send("gvim", ":sleep 10 | echo ". | 2483 :echo remote_send("gvim", ":sleep 10 | echo ". |
2318 \ 'server2client(expand("<client>"), "HELLO")<CR>') | 2484 \ 'server2client(expand("<client>"), "HELLO")<CR>') |
2319 | 2485 |
2320 | 2486 |
2487 remove({list}, {idx}) *remove()* | |
2488 Remove the item at {idx} from List {list} and return it. | |
2489 See |list-index| for possible values of {idx}. | |
2490 Example: > | |
2491 :echo "last item: " . remove(mylist, -1) | |
2492 < Use |delete()| to remove a file. | |
2493 | |
2321 rename({from}, {to}) *rename()* | 2494 rename({from}, {to}) *rename()* |
2322 Rename the file by the name {from} to the name {to}. This | 2495 Rename the file by the name {from} to the name {to}. This |
2323 should also work to move files across file systems. The | 2496 should also work to move files across file systems. The |
2324 result is a Number, which is 0 if the file was renamed | 2497 result is a Number, which is 0 if the file was renamed |
2325 successfully, and non-zero when the renaming failed. | 2498 successfully, and non-zero when the renaming failed. |
2593 See also |strridx()|. Examples: > | 2766 See also |strridx()|. Examples: > |
2594 :echo stridx("An Example", "Example") 3 | 2767 :echo stridx("An Example", "Example") 3 |
2595 :echo stridx("Starting point", "Start") 0 | 2768 :echo stridx("Starting point", "Start") 0 |
2596 :echo stridx("Starting point", "start") -1 | 2769 :echo stridx("Starting point", "start") -1 |
2597 < | 2770 < |
2771 *string()* | |
2772 string({expr}) Return {expr} converted to a String. | |
2773 {expr} type result ~ | |
2774 String identical | |
2775 Number decimal representation | |
2776 Funcref name of the function | |
2777 | |
2598 *strlen()* | 2778 *strlen()* |
2599 strlen({expr}) The result is a Number, which is the length of the String | 2779 strlen({expr}) The result is a Number, which is the length of the String |
2600 {expr} in bytes. If you want to count the number of | 2780 {expr} in bytes. If you want to count the number of |
2601 multi-byte characters use something like this: > | 2781 multi-byte characters use something like this: > |
2602 | 2782 |
2603 :let len = strlen(substitute(str, ".", "x", "g")) | 2783 :let len = strlen(substitute(str, ".", "x", "g")) |
2604 | 2784 |
2605 < Composing characters are not counted. | 2785 < Composing characters are not counted. |
2786 If the argument is a Number it is first converted to a String. | |
2787 For other types an error is given. | |
2788 Also see |len()|. | |
2606 | 2789 |
2607 strpart({src}, {start}[, {len}]) *strpart()* | 2790 strpart({src}, {start}[, {len}]) *strpart()* |
2608 The result is a String, which is part of {src}, starting from | 2791 The result is a String, which is part of {src}, starting from |
2609 byte {start}, with the length {len}. | 2792 byte {start}, with the length {len}. |
2610 When non-existing bytes are included, this doesn't result in | 2793 When non-existing bytes are included, this doesn't result in |
3357 | 3540 |
3358 *E106* | 3541 *E106* |
3359 :let {var-name} .. List the value of variable {var-name}. Several | 3542 :let {var-name} .. List the value of variable {var-name}. Several |
3360 variable names may be given. | 3543 variable names may be given. |
3361 | 3544 |
3362 :let List the values of all variables. | 3545 :let List the values of all variables. The type of the |
3546 variable is indicated before the value: | |
3547 <nothing> String | |
3548 # Number | |
3549 * Funcref | |
3363 | 3550 |
3364 *:unlet* *:unl* *E108* | 3551 *:unlet* *:unl* *E108* |
3365 :unl[et][!] {var-name} ... | 3552 :unl[et][!] {var-name} ... |
3366 Remove the internal variable {var-name}. Several | 3553 Remove the internal variable {var-name}. Several |
3367 variable names can be given, they are all removed. | 3554 variable names can be given, they are all removed. |