comparison runtime/doc/vim9.txt @ 26769:30972227ac8d v8.2.3913

patch 8.2.3913: help for expressions does not mention Vim9 syntax Commit: https://github.com/vim/vim/commit/5da36052a4bb0f3a9747ec3a8ab9d85e058e39fa Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 27 15:39:57 2021 +0000 patch 8.2.3913: help for expressions does not mention Vim9 syntax Problem: Help for expressions does not mention Vim9 syntax. Solution: Add the rules for Vim9 to the expression help. Rename functions to match the help.
author Bram Moolenaar <Bram@vim.org>
date Mon, 27 Dec 2021 16:45:03 +0100
parents ddaea8dcaff5
children be85735650f7
comparison
equal deleted inserted replaced
26768:cdea9da4aeb3 26769:30972227ac8d
1 *vim9.txt* For Vim version 8.2. Last change: 2021 Dec 26 1 *vim9.txt* For Vim version 8.2. Last change: 2021 Dec 27
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
79 echo "hello" # comment 79 echo "hello" # comment
80 - Using a backslash for line continuation is hardly ever needed: > 80 - Using a backslash for line continuation is hardly ever needed: >
81 echo "hello " 81 echo "hello "
82 .. yourName 82 .. yourName
83 .. ", how are you?" 83 .. ", how are you?"
84 - White space is required in many places. 84 - White space is required in many places to improve readability.
85 - Assign values without `:let`, declare variables with `:var`: > 85 - Assign values without `:let`, declare variables with `:var`: >
86 var count = 0 86 var count = 0
87 count += 3 87 count += 3
88 - Constants can be declared with `:final` and `:const`: > 88 - Constants can be declared with `:final` and `:const`: >
89 final matches = [] # add matches 89 final matches = [] # add matches
92 - Variables and functions are script-local by default. 92 - Variables and functions are script-local by default.
93 - Functions are declared with argument types and return type: > 93 - Functions are declared with argument types and return type: >
94 def CallMe(count: number, message: string): bool 94 def CallMe(count: number, message: string): bool
95 - Call functions without `:call`: > 95 - Call functions without `:call`: >
96 writefile(['done'], 'file.txt') 96 writefile(['done'], 'file.txt')
97 - You cannot use `:xit`, `:t`, `:k`, `:append`, `:change`, `:insert`, `:open`, 97 - You cannot use old Ex commands `:xit`, `:t`, `:k`, `:append`, `:change`,
98 and `:s` or `:d` with only flags. 98 `:insert`, `:open`, and `:s` or `:d` with only flags.
99 - You cannot use curly-braces names. 99 - You cannot use curly-braces names.
100 - A range before a command must be prefixed with a colon: > 100 - A range before a command must be prefixed with a colon: >
101 :%s/this/that 101 :%s/this/that
102 - Executing a register with "@r" does not work, you can prepend a colon or use 102 - Executing a register with "@r" does not work, you can prepend a colon or use
103 `:exe`: > 103 `:exe`: >
351 any, etc.). This matters especially when using the "any" type, the value will 351 any, etc.). This matters especially when using the "any" type, the value will
352 default to the number zero. 352 default to the number zero.
353 353
354 In Vim9 script `:let` cannot be used. An existing variable is assigned to 354 In Vim9 script `:let` cannot be used. An existing variable is assigned to
355 without any command. The same for global, window, tab, buffer and Vim 355 without any command. The same for global, window, tab, buffer and Vim
356 variables, because they are not really declared. They can also be deleted 356 variables, because they are not really declared. Those can also be deleted
357 with `:unlet`. 357 with `:unlet`.
358 358
359 `:lockvar` does not work on local variables. Use `:const` and `:final` 359 `:lockvar` does not work on local variables. Use `:const` and `:final`
360 instead. 360 instead.
361 361
595 key: value 595 key: value
596 })->method() 596 })->method()
597 597
598 598
599 Automatic line continuation ~ 599 Automatic line continuation ~
600 600 *vim9-line-continuation*
601 In many cases it is obvious that an expression continues on the next line. In 601 In many cases it is obvious that an expression continues on the next line. In
602 those cases there is no need to prefix the line with a backslash (see 602 those cases there is no need to prefix the line with a backslash (see
603 |line-continuation|). For example, when a list spans multiple lines: > 603 |line-continuation|). For example, when a list spans multiple lines: >
604 var mylist = [ 604 var mylist = [
605 'one', 605 'one',
773 773
774 |curly-braces-names| cannot be used. 774 |curly-braces-names| cannot be used.
775 775
776 776
777 Dictionary literals ~ 777 Dictionary literals ~
778 778 *vim9-literal-dict*
779 Traditionally Vim has supported dictionary literals with a {} syntax: > 779 Traditionally Vim has supported dictionary literals with a {} syntax: >
780 let dict = {'key': value} 780 let dict = {'key': value}
781 781
782 Later it became clear that using a simple text key is very common, thus 782 Later it became clear that using a simple text key is very common, thus
783 literal dictionaries were introduced in a backwards compatible way: > 783 literal dictionaries were introduced in a backwards compatible way: >
863 Generally, you should not change the list that is iterated over. Make a copy 863 Generally, you should not change the list that is iterated over. Make a copy
864 first if needed. 864 first if needed.
865 865
866 866
867 Conditions and expressions ~ 867 Conditions and expressions ~
868 868 *vim9-boolean*
869 Conditions and expressions are mostly working like they do in other languages. 869 Conditions and expressions are mostly working like they do in other languages.
870 Some values are different from legacy Vim script: 870 Some values are different from legacy Vim script:
871 value legacy Vim script Vim9 script ~ 871 value legacy Vim script Vim9 script ~
872 0 falsy falsy 872 0 falsy falsy
873 1 truthy truthy 873 1 truthy truthy
915 When using "`.."` for string concatenation arguments of simple types are 915 When using "`.."` for string concatenation arguments of simple types are
916 always converted to string: > 916 always converted to string: >
917 'hello ' .. 123 == 'hello 123' 917 'hello ' .. 123 == 'hello 123'
918 'hello ' .. v:true == 'hello true' 918 'hello ' .. v:true == 'hello true'
919 919
920 Simple types are string, float, special and bool. For other types |string()| 920 Simple types are Number, Float, Special and Bool. For other types |string()|
921 can be used. 921 should be used.
922 *false* *true* *null* 922 *false* *true* *null*
923 In Vim9 script one can use "true" for v:true, "false" for v:false and "null" 923 In Vim9 script one can use "true" for v:true, "false" for v:false and "null"
924 for v:null. When converting a boolean to a string "false" and "true" are 924 for v:null. When converting a boolean to a string "false" and "true" are
925 used, not "v:false" and "v:true" like in legacy script. "v:none" is not 925 used, not "v:false" and "v:true" like in legacy script. "v:none" is not
926 changed, it is only used in JSON and has no equivalent in other languages. 926 changed, it is only used in JSON and has no equivalent in other languages.