Mercurial > vim
comparison runtime/doc/eval.txt @ 819:23f82b5d2814 v7.0c10
updated for version 7.0c10
author | vimboss |
---|---|
date | Wed, 05 Apr 2006 20:41:53 +0000 |
parents | 1f929f3ca806 |
children | 9ab23f1e137f |
comparison
equal
deleted
inserted
replaced
818:1f929f3ca806 | 819:23f82b5d2814 |
---|---|
1 *eval.txt* For Vim version 7.0c. Last change: 2006 Mar 29 | 1 *eval.txt* For Vim version 7.0c. Last change: 2006 Apr 04 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
108 around the arguments, to invoke the function it refers to. Example: > | 108 around the arguments, to invoke the function it refers to. Example: > |
109 | 109 |
110 :let Fn = function("MyFunc") | 110 :let Fn = function("MyFunc") |
111 :echo Fn() | 111 :echo Fn() |
112 < *E704* *E705* *E707* | 112 < *E704* *E705* *E707* |
113 A Funcref variable must start with a capital, "s:", "w:" or "b:". You cannot | 113 A Funcref variable must start with a capital, "s:", "w:", "t:" or "b:". You |
114 have both a Funcref variable and a function with the same name. | 114 cannot have both a Funcref variable and a function with the same name. |
115 | 115 |
116 A special case is defining a function and directly assigning its Funcref to a | 116 A special case is defining a function and directly assigning its Funcref to a |
117 Dictionary entry. Example: > | 117 Dictionary entry. Example: > |
118 :function dict.init() dict | 118 :function dict.init() dict |
119 : let self.val = 0 | 119 : let self.val = 0 |
502 the function was invoked from. | 502 the function was invoked from. |
503 | 503 |
504 It is also possible to add a function without the "dict" attribute as a | 504 It is also possible to add a function without the "dict" attribute as a |
505 Funcref to a Dictionary, but the "self" variable is not available then. | 505 Funcref to a Dictionary, but the "self" variable is not available then. |
506 | 506 |
507 *numbered-function* | 507 *numbered-function* *anonymous-function* |
508 To avoid the extra name for the function it can be defined and directly | 508 To avoid the extra name for the function it can be defined and directly |
509 assigned to a Dictionary in this way: > | 509 assigned to a Dictionary in this way: > |
510 :let mydict = {'data': [0, 1, 2, 3]} | 510 :let mydict = {'data': [0, 1, 2, 3]} |
511 :function mydict.len() dict | 511 :function mydict.len() dict |
512 : return len(self.data) | 512 : return len(self.data) |
1028 specified by what is prepended: | 1028 specified by what is prepended: |
1029 | 1029 |
1030 (nothing) In a function: local to a function; otherwise: global | 1030 (nothing) In a function: local to a function; otherwise: global |
1031 |buffer-variable| b: Local to the current buffer. | 1031 |buffer-variable| b: Local to the current buffer. |
1032 |window-variable| w: Local to the current window. | 1032 |window-variable| w: Local to the current window. |
1033 |tabpage-variable| t: Local to the current tab page. | |
1033 |global-variable| g: Global. | 1034 |global-variable| g: Global. |
1034 |local-variable| l: Local to a function. | 1035 |local-variable| l: Local to a function. |
1035 |script-variable| s: Local to a |:source|'ed Vim script. | 1036 |script-variable| s: Local to a |:source|'ed Vim script. |
1036 |function-argument| a: Function argument (only inside a function). | 1037 |function-argument| a: Function argument (only inside a function). |
1037 |vim-variable| v: Global, predefined by Vim. | 1038 |vim-variable| v: Global, predefined by Vim. |
1060 :endif | 1061 :endif |
1061 < | 1062 < |
1062 *window-variable* *w:var* | 1063 *window-variable* *w:var* |
1063 A variable name that is preceded with "w:" is local to the current window. It | 1064 A variable name that is preceded with "w:" is local to the current window. It |
1064 is deleted when the window is closed. | 1065 is deleted when the window is closed. |
1066 | |
1067 *tabpage-variable* *t:var* | |
1068 A variable name that is preceded with "t:" is local to the current tab page, | |
1069 It is deleted when the tab page is closed. {not available when compiled | |
1070 without the +windows feature} | |
1065 | 1071 |
1066 *global-variable* *g:var* | 1072 *global-variable* *g:var* |
1067 Inside functions global variables are accessed with "g:". Omitting this will | 1073 Inside functions global variables are accessed with "g:". Omitting this will |
1068 access a variable local to a function. But "g:" can also be used in any other | 1074 access a variable local to a function. But "g:" can also be used in any other |
1069 place if you like. | 1075 place if you like. |
1626 String rhs of mapping {name} in mode {mode} | 1632 String rhs of mapping {name} in mode {mode} |
1627 mapcheck( {name}[, {mode} [, {abbr}]]) | 1633 mapcheck( {name}[, {mode} [, {abbr}]]) |
1628 String check for mappings matching {name} | 1634 String check for mappings matching {name} |
1629 match( {expr}, {pat}[, {start}[, {count}]]) | 1635 match( {expr}, {pat}[, {start}[, {count}]]) |
1630 Number position where {pat} matches in {expr} | 1636 Number position where {pat} matches in {expr} |
1637 matcharg( {nr}) List arguments of |:match| | |
1631 matchend( {expr}, {pat}[, {start}[, {count}]]) | 1638 matchend( {expr}, {pat}[, {start}[, {count}]]) |
1632 Number position where {pat} ends in {expr} | 1639 Number position where {pat} ends in {expr} |
1633 matchlist( {expr}, {pat}[, {start}[, {count}]]) | 1640 matchlist( {expr}, {pat}[, {start}[, {count}]]) |
1634 List match and submatches of {pat} in {expr} | 1641 List match and submatches of {pat} in {expr} |
1635 matchstr( {expr}, {pat}[, {start}[, {count}]]) | 1642 matchstr( {expr}, {pat}[, {start}[, {count}]]) |
1639 mkdir({name} [, {path} [, {prot}]]) | 1646 mkdir({name} [, {path} [, {prot}]]) |
1640 Number create directory {name} | 1647 Number create directory {name} |
1641 mode() String current editing mode | 1648 mode() String current editing mode |
1642 nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum} | 1649 nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum} |
1643 nr2char( {expr}) String single char with ASCII value {expr} | 1650 nr2char( {expr}) String single char with ASCII value {expr} |
1651 pathshorten( {expr}) String shorten directory names in a path | |
1644 prevnonblank( {lnum}) Number line nr of non-blank line <= {lnum} | 1652 prevnonblank( {lnum}) Number line nr of non-blank line <= {lnum} |
1645 printf( {fmt}, {expr1}...) String format text | 1653 printf( {fmt}, {expr1}...) String format text |
1646 pumvisible() Number whether popup menu is visible | 1654 pumvisible() Number whether popup menu is visible |
1647 range( {expr} [, {max} [, {stride}]]) | 1655 range( {expr} [, {max} [, {stride}]]) |
1648 List items from {expr} to {max} | 1656 List items from {expr} to {max} |
2250 the name without an extension. When 'shell' looks like a | 2258 the name without an extension. When 'shell' looks like a |
2251 Unix shell, then the name is also tried without adding an | 2259 Unix shell, then the name is also tried without adding an |
2252 extension. | 2260 extension. |
2253 On MS-DOS and MS-Windows it only checks if the file exists and | 2261 On MS-DOS and MS-Windows it only checks if the file exists and |
2254 is not a directory, not if it's really executable. | 2262 is not a directory, not if it's really executable. |
2263 On MS-Windows an executable in the same directory as Vim is | |
2264 always found. Since this directory is added to $PATH it | |
2265 should also work to execute it |win32-PATH|. | |
2255 The result is a Number: | 2266 The result is a Number: |
2256 1 exists | 2267 1 exists |
2257 0 does not exist | 2268 0 does not exist |
2258 -1 not implemented on this system | 2269 -1 not implemented on this system |
2259 | 2270 |
2718 With an argument a check is done whether {name} is a valid | 2729 With an argument a check is done whether {name} is a valid |
2719 font name. If not then an empty string is returned. | 2730 font name. If not then an empty string is returned. |
2720 Otherwise the actual font name is returned, or {name} if the | 2731 Otherwise the actual font name is returned, or {name} if the |
2721 GUI does not support obtaining the real name. | 2732 GUI does not support obtaining the real name. |
2722 Only works when the GUI is running, thus not you your vimrc or | 2733 Only works when the GUI is running, thus not you your vimrc or |
2734 gvimrc file. Use the |GUIEnter| autocommand to use this | |
2735 function just after the GUI has started. | |
2723 Note that the GTK 2 GUI accepts any font name, thus checking | 2736 Note that the GTK 2 GUI accepts any font name, thus checking |
2724 for a valid name does not work. | 2737 for a valid name does not work. |
2725 gvimrc file. Use the |GUIEnter| autocommand to use this | |
2726 function just after the GUI has started. | |
2727 | 2738 |
2728 getfperm({fname}) *getfperm()* | 2739 getfperm({fname}) *getfperm()* |
2729 The result is a String, which is the read, write, and execute | 2740 The result is a String, which is the read, write, and execute |
2730 permissions of the given file {fname}. | 2741 permissions of the given file {fname}. |
2731 If {fname} does not exist or its directory cannot be read, an | 2742 If {fname} does not exist or its directory cannot be read, an |
3135 Hitting <Enter> works like pressing the OK button. Hitting | 3146 Hitting <Enter> works like pressing the OK button. Hitting |
3136 <Esc> works like pressing the Cancel button. | 3147 <Esc> works like pressing the Cancel button. |
3137 NOTE: Command-line completion is not supported. | 3148 NOTE: Command-line completion is not supported. |
3138 | 3149 |
3139 inputlist({textlist}) *inputlist()* | 3150 inputlist({textlist}) *inputlist()* |
3140 {textlist} must be a list of strings. This list is displayed, | 3151 {textlist} must be a |List| of strings. This |List| is |
3141 one string per line. The user will be prompted to enter a | 3152 displayed, one string per line. The user will be prompted to |
3142 number, which is returned. | 3153 enter a number, which is returned. |
3143 The user can also select an item by clicking on it with the | 3154 The user can also select an item by clicking on it with the |
3144 mouse. For the first string 0 is returned. When clicking | 3155 mouse. For the first string 0 is returned. When clicking |
3145 above the first item a negative number is returned. When | 3156 above the first item a negative number is returned. When |
3146 clicking on the prompt one more than the length of {textlist} | 3157 clicking on the prompt one more than the length of {textlist} |
3147 is returned. | 3158 is returned. |
3194 The result is a Number, which is non-zero when a directory | 3205 The result is a Number, which is non-zero when a directory |
3195 with the name {directory} exists. If {directory} doesn't | 3206 with the name {directory} exists. If {directory} doesn't |
3196 exist, or isn't a directory, the result is FALSE. {directory} | 3207 exist, or isn't a directory, the result is FALSE. {directory} |
3197 is any expression, which is used as a String. | 3208 is any expression, which is used as a String. |
3198 | 3209 |
3199 islocked({expr}) *islocked()* | 3210 islocked({expr}) *islocked()* *E786* |
3200 The result is a Number, which is non-zero when {expr} is the | 3211 The result is a Number, which is non-zero when {expr} is the |
3201 name of a locked variable. | 3212 name of a locked variable. |
3202 {expr} must be the name of a variable, |List| item or | 3213 {expr} must be the name of a variable, |List| item or |
3203 |Dictionary| entry, not the variable itself! Example: > | 3214 |Dictionary| entry, not the variable itself! Example: > |
3204 :let alist = [0, ['a', 'b'], 2, 3] | 3215 :let alist = [0, ['a', 'b'], 2, 3] |
3477 See |pattern| for the patterns that are accepted. | 3488 See |pattern| for the patterns that are accepted. |
3478 The 'ignorecase' option is used to set the ignore-caseness of | 3489 The 'ignorecase' option is used to set the ignore-caseness of |
3479 the pattern. 'smartcase' is NOT used. The matching is always | 3490 the pattern. 'smartcase' is NOT used. The matching is always |
3480 done like 'magic' is set and 'cpoptions' is empty. | 3491 done like 'magic' is set and 'cpoptions' is empty. |
3481 | 3492 |
3493 | |
3494 matcharg({nr}) *matcharg()* | |
3495 Selects the {nr} match item, as set with a |:match|, | |
3496 |:2match| or |:3match| command. | |
3497 Return a |List| with two elements: | |
3498 The name of the highlight group used | |
3499 The pattern used. | |
3500 When {nr} is not 1, 2 or 3 returns an empty |List|. | |
3501 When there is no match item set returns ['', '']. | |
3502 This is usef to save and restore a |:match|. | |
3503 | |
3504 | |
3482 matchend({expr}, {pat}[, {start}[, {count}]]) *matchend()* | 3505 matchend({expr}, {pat}[, {start}[, {count}]]) *matchend()* |
3483 Same as match(), but return the index of first character after | 3506 Same as match(), but return the index of first character after |
3484 the match. Example: > | 3507 the match. Example: > |
3485 :echo matchend("testing", "ing") | 3508 :echo matchend("testing", "ing") |
3486 < results in "7". | 3509 < results in "7". |
3595 This can be used to save and restore the cursor position: > | 3618 This can be used to save and restore the cursor position: > |
3596 let save_cursor = getpos(".") | 3619 let save_cursor = getpos(".") |
3597 MoveTheCursorAround | 3620 MoveTheCursorAround |
3598 call setpos('.', save_cursor) | 3621 call setpos('.', save_cursor) |
3599 < Also see |setpos()|. | 3622 < Also see |setpos()|. |
3623 | |
3624 pathshorten({expr}) *pathshorten()* | |
3625 Shorten directory names in the path {expr} and return the | |
3626 result. The tail, the file name, is kept as-is. The other | |
3627 components in the path are reduced to single letters. Leading | |
3628 '~' and '.' characters are kept. Example: > | |
3629 :echo pathshorten('~/.vim/autoload/myfile.vim') | |
3630 < ~/.v/a/myfile.vim ~ | |
3631 It doesn't matter if the path exists or not. | |
3600 | 3632 |
3601 prevnonblank({lnum}) *prevnonblank()* | 3633 prevnonblank({lnum}) *prevnonblank()* |
3602 Return the line number of the first line at or above {lnum} | 3634 Return the line number of the first line at or above {lnum} |
3603 that is not blank. Example: > | 3635 that is not blank. Example: > |
3604 let ind = indent(prevnonblank(v:lnum - 1)) | 3636 let ind = indent(prevnonblank(v:lnum - 1)) |
5034 gettext Compiled with message translation |multi-lang| | 5066 gettext Compiled with message translation |multi-lang| |
5035 gui Compiled with GUI enabled. | 5067 gui Compiled with GUI enabled. |
5036 gui_athena Compiled with Athena GUI. | 5068 gui_athena Compiled with Athena GUI. |
5037 gui_gtk Compiled with GTK+ GUI (any version). | 5069 gui_gtk Compiled with GTK+ GUI (any version). |
5038 gui_gtk2 Compiled with GTK+ 2 GUI (gui_gtk is also defined). | 5070 gui_gtk2 Compiled with GTK+ 2 GUI (gui_gtk is also defined). |
5039 gui_kde Compiled with KDE GUI |KVim| | |
5040 gui_mac Compiled with Macintosh GUI. | 5071 gui_mac Compiled with Macintosh GUI. |
5041 gui_motif Compiled with Motif GUI. | 5072 gui_motif Compiled with Motif GUI. |
5042 gui_photon Compiled with Photon GUI. | 5073 gui_photon Compiled with Photon GUI. |
5043 gui_win32 Compiled with MS Windows Win32 GUI. | 5074 gui_win32 Compiled with MS Windows Win32 GUI. |
5044 gui_win32s idem, and Win32s system being used (Windows 3.1) | 5075 gui_win32s idem, and Win32s system being used (Windows 3.1) |
5652 variable names may be given. Special names recognized | 5683 variable names may be given. Special names recognized |
5653 here: *E738* | 5684 here: *E738* |
5654 g: global variables | 5685 g: global variables |
5655 b: local buffer variables | 5686 b: local buffer variables |
5656 w: local window variables | 5687 w: local window variables |
5688 t: local tab page variables | |
5657 s: script-local variables | 5689 s: script-local variables |
5658 l: local function variables | 5690 l: local function variables |
5659 v: Vim variables. | 5691 v: Vim variables. |
5660 | 5692 |
5661 :let List the values of all variables. The type of the | 5693 :let List the values of all variables. The type of the |
5709 However, there is a maximum depth of 100 to catch | 5741 However, there is a maximum depth of 100 to catch |
5710 loops. | 5742 loops. |
5711 | 5743 |
5712 Note that when two variables refer to the same |List| | 5744 Note that when two variables refer to the same |List| |
5713 and you lock one of them, the |List| will also be | 5745 and you lock one of them, the |List| will also be |
5714 locked when used through the other variable. Example: | 5746 locked when used through the other variable. |
5715 > | 5747 Example: > |
5716 :let l = [0, 1, 2, 3] | 5748 :let l = [0, 1, 2, 3] |
5717 :let cl = l | 5749 :let cl = l |
5718 :lockvar l | 5750 :lockvar l |
5719 :let cl[1] = 99 " won't work! | 5751 :let cl[1] = 99 " won't work! |
5720 < You may want to make a copy of a list to avoid this. | 5752 < You may want to make a copy of a list to avoid this. |