66
77THIS IS STILL UNDER DEVELOPMENT - ANYTHING CAN BREAK - ANYTHING CAN CHANGE
88
9- Vim9 script commands and expressions. *Vim9*
9+ Vim9 script commands and expressions. *Vim9* *vim9*
1010
1111Most expression help is in | eval.txt | . This file is about the new syntax and
1212features in Vim9 script.
@@ -113,11 +113,12 @@ In Vi # is a command to list text with numbers. In Vim9 script you can use
113113
114114 To improve readability there must be a space between a command and the #
115115that starts a comment: >
116- var = value # comment
117- var = value# error!
116+ var name = value # comment
117+ var name = value# error!
118118
119- In legacy script # is also used for the alternate file name. In Vim9 script
120- you need to use %% instead. Instead of ## use %%% (stands for all arguments).
119+ In legacy Vim script # is also used for the alternate file name. In Vim9
120+ script you need to use %% instead. Instead of ## use %%% (stands for all
121+ arguments).
121122
122123
123124Vim9 functions ~
@@ -209,13 +210,13 @@ if you are developing a plugin and want to try a new version. If you renamed
209210something you don't have to worry about the old name still hanging around.
210211
211212If you do want to keep items, use: >
212- vimscript noclear
213+ vim9script noclear
213214
214215 You want to use this in scripts that use a `finish ` command to bail out at
215216some point when loaded again. E.g. when a buffer local option is set: >
216- vimscript noclear
217+ vim9script noclear
217218 setlocal completefunc=SomeFunc
218- if exists('*SomeFunc') | finish | endif
219+ if exists('*g: SomeFunc') | finish | endif
219220 def g:SomeFunc()
220221 ....
221222
@@ -385,9 +386,13 @@ No line break is allowed in the arguments of a lambda up to and including the
385386 This does not work: >
386387 filter(list, (k, v)
387388 => v > 0)
388- This also does not work:
389+ This also does not work: >
389390 filter(list, (k,
390391 v) => v > 0)
392+ But you can use a backslash to concatenate the lines before parsing: >
393+ filter(list, (k,
394+ \ v)
395+ \ => v > 0)
391396
392397 Additionally, a lambda can contain statements in {}: >
393398 var Lambda = (arg) => {
@@ -404,8 +409,8 @@ wrap it in parenthesis: >
404409Automatic line continuation ~
405410
406411In many cases it is obvious that an expression continues on the next line. In
407- those cases there is no need to prefix the line with a backslash
408- | line-continuation | . For example, when a list spans multiple lines: >
412+ those cases there is no need to prefix the line with a backslash (see
413+ | line-continuation | ) . For example, when a list spans multiple lines: >
409414 var mylist = [
410415 'one',
411416 'two',
@@ -442,6 +447,12 @@ before it: >
442447 var result = MyDict
443448 .member
444449
450+ For commands that have an argument that is a list of commands, the | character
451+ at the start of the line indicates line continuation: >
452+ autocmd BufNewFile *.match if condition
453+ | echo 'match'
454+ | endif
455+
445456< *E1050*
446457To make it possible for the operator at the start of the line to be
447458recognized, it is required to put a colon before a range. This will add
@@ -941,7 +952,7 @@ that you don't do that.
941952
942953
943954Namespace ~
944- *:vim9script* *: vim9*
955+ *vim9-namespace *
945956To recognize a file that can be imported the `vim9script ` statement must
946957appear as the first statement in the file. It tells Vim to interpret the
947958script in its own namespace, instead of the global namespace. If a file
0 commit comments