Mercurial > vim
comparison runtime/doc/vim9.txt @ 24569:e3ec2ec8841a
Update runtime files
Commit: https://github.com/vim/vim/commit/4c295027a426986566cd7a76c47a6d3a529727e7
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 2 17:19:11 2021 +0200
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 02 May 2021 17:30:05 +0200 |
parents | 3bfec39ce31c |
children | e69e7133c9cf |
comparison
equal
deleted
inserted
replaced
24568:3671ff322103 | 24569:e3ec2ec8841a |
---|---|
1 *vim9.txt* For Vim version 8.2. Last change: 2021 Apr 11 | 1 *vim9.txt* For Vim version 8.2. Last change: 2021 Apr 28 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
155 - a function that is compiled calls the function or uses it as a function | 155 - a function that is compiled calls the function or uses it as a function |
156 reference | 156 reference |
157 *E1091* | 157 *E1091* |
158 If compilation fails it is not tried again on the next call, instead this | 158 If compilation fails it is not tried again on the next call, instead this |
159 error is given: "E1091: Function is not compiled: {name}". | 159 error is given: "E1091: Function is not compiled: {name}". |
160 Compilation will fail when encountering a user command that has not been | |
161 created yet. In this case you can call `execute()` to invoke it at runtime. > | |
162 def MyFunc() | |
163 execute('DefinedLater') | |
164 enddef | |
160 | 165 |
161 `:def` has no options like `:function` does: "range", "abort", "dict" or | 166 `:def` has no options like `:function` does: "range", "abort", "dict" or |
162 "closure". A `:def` function always aborts on an error (unless `:silent!` was | 167 "closure". A `:def` function always aborts on an error (unless `:silent!` was |
163 used for the command or inside a `:try` block), does not get a range passed | 168 used for the command or inside a `:try` block), does not get a range passed |
164 cannot be a "dict" function, and can always be a closure. | 169 cannot be a "dict" function, and can always be a closure. |
603 4] | 608 4] |
604 < This does not work: > | 609 < This does not work: > |
605 echo [1, 2] | 610 echo [1, 2] |
606 [3, 4] | 611 [3, 4] |
607 | 612 |
613 | |
614 White space ~ | |
615 | |
616 Vim9 script enforces proper use of white space. This is no longer allowed: > | |
617 var name=234 # Error! | |
618 var name= 234 # Error! | |
619 var name =234 # Error! | |
620 There must be white space before and after the "=": > | |
621 var name = 234 # OK | |
622 White space must also be put before the # that starts a comment after a | |
623 command: > | |
624 var name = 234# Error! | |
625 var name = 234 # OK | |
626 | |
627 White space is required around most operators. | |
628 | |
629 White space is required in a sublist (list slice) around the ":", except at | |
630 the start and end: > | |
631 otherlist = mylist[v : count] # v:count has a different meaning | |
632 otherlist = mylist[:] # make a copy of the List | |
633 otherlist = mylist[v :] | |
634 otherlist = mylist[: v] | |
635 | |
636 White space is not allowed: | |
637 - Between a function name and the "(": > | |
638 Func (arg) # Error! | |
639 Func | |
640 \ (arg) # Error! | |
641 Func | |
642 (arg) # Error! | |
643 Func(arg) # OK | |
644 Func( | |
645 arg) # OK | |
646 Func( | |
647 arg # OK | |
648 ) | |
649 | |
650 | |
608 No curly braces expansion ~ | 651 No curly braces expansion ~ |
609 | 652 |
610 |curly-braces-names| cannot be used. | 653 |curly-braces-names| cannot be used. |
611 | 654 |
612 | 655 |
652 | 695 |
653 | 696 |
654 Comparators ~ | 697 Comparators ~ |
655 | 698 |
656 The 'ignorecase' option is not used for comparators that use strings. | 699 The 'ignorecase' option is not used for comparators that use strings. |
700 | |
701 | |
702 Abort after error ~ | |
703 | |
704 In legacy script, when an error is encountered, Vim continues to execute | |
705 following lines. This can lead to a long sequence of errors and need to type | |
706 CTRL-C to stop it. In Vim9 script execution of commands stops at the first | |
707 error. Example: > | |
708 vim9script | |
709 var x = does-not-exist | |
710 echo 'not executed' | |
657 | 711 |
658 | 712 |
659 For loop ~ | 713 For loop ~ |
660 | 714 |
661 Legacy Vim script has some tricks to make a for loop over a list handle | 715 Legacy Vim script has some tricks to make a for loop over a list handle |
675 In compiled Vim9 script you get: | 729 In compiled Vim9 script you get: |
676 1 | 730 1 |
677 3 | 731 3 |
678 Generally, you should not change the list that is iterated over. Make a copy | 732 Generally, you should not change the list that is iterated over. Make a copy |
679 first if needed. | 733 first if needed. |
680 | |
681 | |
682 White space ~ | |
683 | |
684 Vim9 script enforces proper use of white space. This is no longer allowed: > | |
685 var name=234 # Error! | |
686 var name= 234 # Error! | |
687 var name =234 # Error! | |
688 There must be white space before and after the "=": > | |
689 var name = 234 # OK | |
690 White space must also be put before the # that starts a comment after a | |
691 command: > | |
692 var name = 234# Error! | |
693 var name = 234 # OK | |
694 | |
695 White space is required around most operators. | |
696 | |
697 White space is required in a sublist (list slice) around the ":", except at | |
698 the start and end: > | |
699 otherlist = mylist[v : count] # v:count has a different meaning | |
700 otherlist = mylist[:] # make a copy of the List | |
701 otherlist = mylist[v :] | |
702 otherlist = mylist[: v] | |
703 | |
704 White space is not allowed: | |
705 - Between a function name and the "(": > | |
706 Func (arg) # Error! | |
707 Func | |
708 \ (arg) # Error! | |
709 Func | |
710 (arg) # Error! | |
711 Func(arg) # OK | |
712 Func( | |
713 arg) # OK | |
714 Func( | |
715 arg # OK | |
716 ) | |
717 | 734 |
718 | 735 |
719 Conditions and expressions ~ | 736 Conditions and expressions ~ |
720 | 737 |
721 Conditions and expressions are mostly working like they do in other languages. | 738 Conditions and expressions are mostly working like they do in other languages. |