Mercurial > vim
comparison runtime/doc/eval.txt @ 75:388f285bda1b
updated for version 7.0031
author | vimboss |
---|---|
date | Wed, 05 Jan 2005 22:16:17 +0000 |
parents | a97c6902ecd9 |
children | e918d3e340a4 |
comparison
equal
deleted
inserted
replaced
74:1154524da1cd | 75:388f285bda1b |
---|---|
1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 04 | 1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 05 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
2772 string({expr}) Return {expr} converted to a String. | 2772 string({expr}) Return {expr} converted to a String. |
2773 {expr} type result ~ | 2773 {expr} type result ~ |
2774 String identical | 2774 String identical |
2775 Number decimal representation | 2775 Number decimal representation |
2776 Funcref name of the function | 2776 Funcref name of the function |
2777 List "[item, item]" form | |
2777 | 2778 |
2778 *strlen()* | 2779 *strlen()* |
2779 strlen({expr}) The result is a Number, which is the length of the String | 2780 strlen({expr}) The result is a Number, which is the length of the String |
2780 {expr} in bytes. If you want to count the number of | 2781 {expr} in bytes. If you want to count the number of |
2781 multi-byte characters use something like this: > | 2782 multi-byte characters use something like this: > |
3617 *E170* *E585* *E588* | 3618 *E170* *E585* *E588* |
3618 :endw[hile] Repeat the commands between ":while" and ":endwhile", | 3619 :endw[hile] Repeat the commands between ":while" and ":endwhile", |
3619 as long as {expr1} evaluates to non-zero. | 3620 as long as {expr1} evaluates to non-zero. |
3620 When an error is detected from a command inside the | 3621 When an error is detected from a command inside the |
3621 loop, execution continues after the "endwhile". | 3622 loop, execution continues after the "endwhile". |
3622 | 3623 Example: > |
3624 :let lnum = 1 | |
3625 :while lnum <= line("$") | |
3626 :call FixLine(lnum) | |
3627 :let lnum = lnum + 1 | |
3628 :endwhile | |
3629 < | |
3623 NOTE: The ":append" and ":insert" commands don't work | 3630 NOTE: The ":append" and ":insert" commands don't work |
3624 properly inside a ":while" loop. | 3631 properly inside a :while" and ":for" loop. |
3625 | 3632 |
3633 :for {var} in {list} *:for* | |
3634 :endfo[r] *:endfo* *:endfor* | |
3635 Repeat the commands between ":for" and ":endfor" for | |
3636 each item in {list}. {var} is set to the value of the | |
3637 item. | |
3638 When an error is detected from a command inside the | |
3639 loop, execution continues after the "endfor". | |
3640 A copy of {list} is made, so that it cannot change | |
3641 while executing the commands. Example (an inefficient | |
3642 way to make a list empty): > | |
3643 :for a in mylist | |
3644 :call remove(mylist, 0) | |
3645 :endfor | |
3646 < Note that the type of each list item should be | |
3647 identical to avoid errors for the type of {var} | |
3648 changing. Unlet the variable at the end of the loop | |
3649 to allow multiple item types. | |
3650 | |
3651 :for {var} in {string} | |
3652 :endfo[r] Like ":for" above, but use each character in {string} | |
3653 as a list item. | |
3654 Composing characters are used as separate characters. | |
3655 A Number is first converted to a String. | |
3656 | |
3657 :for [{var1}, {var2}, ...] in {listlist} | |
3658 :endfo[r] | |
3659 Like ":for" above, but each item in {listlist} must be | |
3660 a list, of which each item is assigned to {var1}, | |
3661 {var2}, etc. Example: > | |
3662 :for [lnum, col] in [[1, 3], [2, 5], [3, 8]] | |
3663 :echo getline(lnum)[col] | |
3664 :endfor | |
3665 < | |
3626 *:continue* *:con* *E586* | 3666 *:continue* *:con* *E586* |
3627 :con[tinue] When used inside a ":while", jumps back to the | 3667 :con[tinue] When used inside a ":while" or ":for" loop, jumps back |
3628 ":while". If it is used after a |:try| inside the | 3668 to the start of the loop. |
3629 ":while" but before the matching |:finally| (if | 3669 If it is used after a |:try| inside the loop but |
3630 present), the commands following the ":finally" up to | 3670 before the matching |:finally| (if present), the |
3631 the matching |:endtry| are executed first. This | 3671 commands following the ":finally" up to the matching |
3632 process applies to all nested ":try"s inside the | 3672 |:endtry| are executed first. This process applies to |
3633 ":while". The outermost ":endtry" then jumps back to | 3673 all nested ":try"s inside the loop. The outermost |
3634 the ":while". | 3674 ":endtry" then jumps back to the start of the loop. |
3635 | 3675 |
3636 *:break* *:brea* *E587* | 3676 *:break* *:brea* *E587* |
3637 :brea[k] When used inside a ":while", skips to the command | 3677 :brea[k] When used inside a ":while" or ":for" loop, skips to |
3638 after the matching ":endwhile". If it is used after | 3678 the command after the matching ":endwhile" or |
3639 a |:try| inside the ":while" but before the matching | 3679 ":endfor". |
3640 |:finally| (if present), the commands following the | 3680 If it is used after a |:try| inside the loop but |
3641 ":finally" up to the matching |:endtry| are executed | 3681 before the matching |:finally| (if present), the |
3642 first. This process applies to all nested ":try"s | 3682 commands following the ":finally" up to the matching |
3643 inside the ":while". The outermost ":endtry" then | 3683 |:endtry| are executed first. This process applies to |
3644 jumps to the command after the ":endwhile". | 3684 all nested ":try"s inside the loop. The outermost |
3685 ":endtry" then jumps to the command after the loop. | |
3645 | 3686 |
3646 :try *:try* *:endt* *:endtry* *E600* *E601* *E602* | 3687 :try *:try* *:endt* *:endtry* *E600* *E601* *E602* |
3647 :endt[ry] Change the error handling for the commands between | 3688 :endt[ry] Change the error handling for the commands between |
3648 ":try" and ":endtry" including everything being | 3689 ":try" and ":endtry" including everything being |
3649 executed across ":source" commands, function calls, | 3690 executed across ":source" commands, function calls, |