Mercurial > vim
diff runtime/doc/eval.txt @ 2908:fd09a9c8468e
Updated runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 19 Jun 2011 05:09:16 +0200 |
parents | 69e0783ed0ef |
children | f2de38a019a2 |
line wrap: on
line diff
--- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.3. Last change: 2011 May 17 +*eval.txt* For Vim version 7.3. Last change: 2011 Jun 19 VIM REFERENCE MANUAL by Bram Moolenaar @@ -721,7 +721,8 @@ if it evaluates to true. *expr-<#* *expr-<=#* *expr-=~#* *expr-!~#* *expr-==?* *expr-!=?* *expr->?* *expr->=?* *expr-<?* *expr-<=?* *expr-=~?* *expr-!~?* - *expr-is* + *expr-is* *expr-isnot* *expr-is#* *expr-isnot#* + *expr-is?* *expr-isnot?* use 'ignorecase' match case ignore case ~ equal == ==# ==? not equal != !=# !=? @@ -731,8 +732,8 @@ smaller than < <# <? smaller than or equal <= <=# <=? regexp matches =~ =~# =~? regexp doesn't match !~ !~# !~? -same instance is -different instance isnot +same instance is is# is? +different instance isnot isnot# isnot? Examples: "abc" ==# "Abc" evaluates to 0 @@ -753,12 +754,14 @@ recursively. Ignoring case means case i A |Funcref| can only be compared with a |Funcref| and only "equal" and "not equal" can be used. Case is never ignored. -When using "is" or "isnot" with a |List| this checks if the expressions are -referring to the same |List| instance. A copy of a |List| is different from -the original |List|. When using "is" without a |List| it is equivalent to -using "equal", using "isnot" equivalent to using "not equal". Except that a -different type means the values are different. "4 == '4'" is true, "4 is '4'" -is false. +When using "is" or "isnot" with a |List| or a |Dictionary| this checks if the +expressions are referring to the same |List| or |Dictionary| instance. A copy +of a |List| is different from the original |List|. When using "is" without +a |List| or a |Dictionary| it is equivalent to using "equal", using "isnot" +equivalent to using "not equal". Except that a different type means the +values are different: "4 == '4'" is true, "4 is '4'" is false and "0 is []" is +false and not a error. "is#"/"isnot#" and "is?"/"isnot?" can be used to match +and ignore case. When comparing a String with a Number, the String is converted to a Number, and the comparison is done on Numbers. This means that "0 == 'x'" is TRUE, @@ -1293,7 +1296,7 @@ v:beval_winnr The number of the window, *v:char* *char-variable* v:char Argument for evaluating 'formatexpr' and used for the typed character when using <expr> in an abbreviation |:map-<expr>|. - It is also used by the |InsertPreChar| event. + It is also used by the |InsertCharPre| event. *v:charconvert_from* *charconvert_from-variable* v:charconvert_from @@ -1943,7 +1946,7 @@ strridx( {haystack}, {needle} [, {start} Number last index of {needle} in {haystack} strtrans( {expr}) String translate string to make it printable strwidth( {expr}) Number display cell length of the String {expr} -submatch( {nr}) String specific match in ":substitute" +submatch( {nr}) String specific match in ":s" or substitute() substitute( {expr}, {pat}, {sub}, {flags}) String all {pat} in {expr} replaced with {sub} synID( {lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col} @@ -5557,9 +5560,11 @@ strwidth({expr}) *strwidth()* Also see |strlen()|, |strdisplaywidth()| and |strchars()|. submatch({nr}) *submatch()* - Only for an expression in a |:substitute| command. Returns - the {nr}'th submatch of the matched text. When {nr} is 0 - the whole matched text is returned. + Only for an expression in a |:substitute| command or + substitute() function. + Returns the {nr}'th submatch of the matched text. When {nr} + is 0 the whole matched text is returned. + Also see |sub-replace-expression|. Example: > :s/\d\+/\=submatch(0) + 1/ < This finds the first number in the line and adds one to it. @@ -5567,27 +5572,32 @@ submatch({nr}) *submatch()* substitute({expr}, {pat}, {sub}, {flags}) *substitute()* The result is a String, which is a copy of {expr}, in which - the first match of {pat} is replaced with {sub}. This works - like the ":substitute" command (without any flags). But the - matching with {pat} is always done like the 'magic' option is - set and 'cpoptions' is empty (to make scripts portable). - 'ignorecase' is still relevant. 'smartcase' is not used. - See |string-match| for how {pat} is used. - And a "~" in {sub} is not replaced with the previous {sub}. + the first match of {pat} is replaced with {sub}. + When {flags} is "g", all matches of {pat} in {expr} are + replaced. Otherwise {flags} should be "". + + This works like the ":substitute" command (without any flags). + But the matching with {pat} is always done like the 'magic' + option is set and 'cpoptions' is empty (to make scripts + portable). 'ignorecase' is still relevant. 'smartcase' is + not used. See |string-match| for how {pat} is used. + + A "~" in {sub} is not replaced with the previous {sub}. Note that some codes in {sub} have a special meaning |sub-replace-special|. For example, to replace something with "\n" (two characters), use "\\\\n" or '\\n'. + When {pat} does not match in {expr}, {expr} is returned unmodified. - When {flags} is "g", all matches of {pat} in {expr} are - replaced. Otherwise {flags} should be "". + Example: > :let &path = substitute(&path, ",\\=[^,]*$", "", "") < This removes the last component of the 'path' option. > :echo substitute("testing", ".*", "\\U\\0", "") < results in "TESTING". - The {sub} argument can start with \=, just like with - |:substitute|. Example: > + + When {sub} starts with "\=", the remainder is interpreted as + an expression. See |sub-replace-expression|. Example: > :echo substitute(s, '%\(\x\x\)', \ '\=nr2char("0x" . submatch(1))', 'g') @@ -6226,7 +6236,6 @@ netbeans_enabled Compiled with support f netbeans_intg Compiled with support for |netbeans|. ole Compiled with OLE automation support for Win32. os2 OS/2 version of Vim. -osfiletype Compiled with support for osfiletypes |+osfiletype| path_extra Compiled with up/downwards search in 'path' and 'tags' perl Compiled with Perl interface. persistent_undo Compiled with support for persistent undo history.