Lines Matching refs:script

9 Vim9 script commands and expressions.			*Vim9* *vim9*
12 features in Vim9 script.
17 1. What is Vim9 script? |Vim9-script|
28 1. What is Vim9 script? *Vim9-script*
32 Vim script has been growing over time, while preserving backwards
37 The main goal of Vim9 script is to drastically improve performance. This is
50 The Vim9 script syntax and semantics are used in:
52 - a script file where the first command is `vim9script`
56 When using `:function` in a Vim9 script file the legacy syntax is used, with
60 Vim9 script and legacy Vim script can be mixed. There is no requirement to
65 Execute {cmd} using Vim9 script syntax and semantics.
66 Useful when typing a command and in a legacy script or
70 Execute {cmd} using legacy script syntax and semantics. Only
71 useful in a Vim9 script or a :def function.
77 2. Differences from legacy Vim script *vim9-differences*
84 script and `:def` functions; details are below:
99 - Variables and functions are script-local by default.
117 In legacy Vim script comments start with double quote. In Vim9 script
128 In Vi # is a command to list text with numbers. In Vim9 script you can use
141 In legacy Vim script # is also used for the alternate file name. In Vim9
142 script you need to use %% instead. Instead of ## use %%% (stands for all
156 - when the `:defcompile` command is encountered in the script after the
224 Functions and variables are script-local by default ~
226 When using `:function` or `:def` to specify a new function at the script level
227 in a Vim9 script, the function is local to the script, as if "s:" was
229 variable the "g:" prefix must be used. For functions in an autoload script
231 def ThisFunction() # script-local
232 def s:ThisFunction() # script-local
238 In a `:def` function it is not possible to define a script-local function. It
244 - in the script scope, possibly imported
249 Since a script-local function reference can be used without "s:" the name must
251 script "s:funcref" could be used, because it could not be referred to with
252 "funcref". In Vim9 script it can, therefore "s:Funcref" must be used to avoid
260 found in the script, either defined there or imported. Global functions and
264 Vim9 script script-local functions are defined once when the script is sourced
273 Reloading a Vim9 script clears functions and variables by default ~
275 When loading a legacy Vim script a second time nothing is removed, the
278 When loading a Vim9 script a second time all existing script-local functions
301 Variables can be local to a script, function or code block: >
358 In Vim9 script `:let` cannot be used. An existing variable is assigned to
370 or imported variables and functions in the same script file.
373 Global variables must be prefixed with "g:", also at the script level. >
517 In legacy script there can be confusion between using "->" for a method call
522 To avoid these problems Vim9 script uses a different syntax for a lambda,
542 In legacy script a lambda could be called with any number of extra arguments,
543 there was no way to warn for not using them. In Vim9 script the number of
654 Like with legacy script '"\ ' is used. This is also needed when line
689 file "_cb: Func})" and exit. To avoid this kind of mistake in Vim9 script
722 Vim9 script enforces proper use of white space. This is no longer allowed: >
777 literals is considered a much more useful syntax. In Vim9 script the {} form
813 In legacy script, when an error is encountered, Vim continues to execute
815 CTRL-C to stop it. In Vim9 script execution of commands stops at the first
824 Legacy Vim script has some tricks to make a for loop over a list handle
825 deleting items at the current or previous item. In Vim9 script it just uses
827 Example legacy script: >
838 In compiled Vim9 script you get:
848 Some values are different from legacy Vim script:
849 value legacy Vim script Vim9 script ~
901 In Vim9 script one can use "true" for v:true, "false" for v:false and "null"
903 used, not "v:false" and "v:true" like in legacy script. "v:none" is not
910 In legacy script this results in the character 0xc3 (an illegal byte), in Vim9
911 script this results in the string 'á'.
917 In legacy script "++var" and "--var" would be silently accepted and have no
918 effect. This is an error in Vim9 script.
943 Some Ex commands can be confused with assignments in Vim9 script: >
1027 Vim9 script: https://github.com/lacygoill/wiki/blob/master/vim/vim9.md
1073 script-local functions cannot be deleted or redefined
1074 later in Vim9 script. They can only be removed by
1075 reloading the same script.
1082 Vim9 script: https://github.com/lacygoill/wiki/blob/master/vim/vim9.md
1084 If the script the function is defined in is Vim9 script, then script-local
1086 before the function is compiled. If the script the function is defined in is
1087 legacy script, then script-local variables must be accessed with the "s:"
1091 :defc[ompile] Compile functions defined in the current script that
1099 can prepend "s:" to find script-local functions.
1131 Or a script variable can be used: >
1251 Variables declared in Vim9 script or in a `:def` function have a type, either
1306 For script-local variables in Vim9 script the type is checked, also when the
1312 In legacy Vim script, where a number was expected, a string would be
1318 In Vim9 script this has been made stricter. In most places it works just as
1326 not change. This will give an error in Vim9 script: >
1350 A Vim9 script can be written to be imported. This means that everything in
1351 the script is local, unless exported. Those exported items, and only those
1352 items, can then be imported in another script.
1362 It tells Vim to interpret the script in its own namespace, instead of the
1367 be available as `g:myvar` from any other script and function.
1369 The variables at the file level are very much like the script-local "s:"
1370 variables in legacy Vim script, but the "s:" is omitted. And they cannot be
1373 In Vim9 script the global "g:" namespace can still be used as before. And the
1381 The original value of 'cpoptions' is restored at the end of the script, while
1382 flags added or removed in the script are also added to or removed from the
1386 There is one way to use both legacy and Vim9 syntax in one script file: >
1389 " legacy script commands go here
1393 # Vim9 script commands go here
1394 This allows for writing a script that takes advantage of the Vim9 script
1404 the Vim9 script syntax has been fully implemented.
1422 `:export` can only be used in Vim9 script, at the script level.
1427 The exported items can be imported individually in another Vim9 script: >
1443 script file to avoid confusion. Also avoid command names, because the name
1446 `:import` can also be used in legacy Vim script. The imported items still
1447 become script-local, even when the "s:" prefix is not given.
1450 at the script level and only imported once.
1452 The script name after `import` can be:
1454 location of the script file itself. This is useful to split up a large
1463 Once a vim9 script file has been imported, the result is cached and used the
1464 next time the same script is imported. It will not be read again.
1466 The `import` commands are executed when encountered. If that script (directly
1467 or indirectly) imports the current script, then items defined after the
1472 Import in an autoload script ~
1478 an autoload script. >
1483 2. In the autoload script do the actual work. You can import items from
1502 When compiling a `:def` function and a function in an autoload script is
1503 encountered, the script is not loaded until the `:def` function is called.
1506 Import in legacy Vim script ~
1508 If an `import` statement is used in legacy Vim script, the script-local "s:"
1517 Most of Vim9 script can be created without this functionality, and since
1568 Plugin writers have asked for much faster Vim script. Investigations have
1582 "function" which clashes with legacy Vim script.
1610 We can also remove clutter, mainly things that were done to make Vim script
1631 Script writers have complained that the Vim script syntax is unexpectedly
1634 the well-known parts of legacy Vim script.
1637 gaining popularity and has similarities with Vim script. It also has a
1640 legacy Vim script is dynamically typed and a lot of existing functionality
1642 faster execution, we need to have this mix in Vim9 script.
1657 goes against legacy Vim script and often leads to mistakes. For that reason
1674 Legacy Vim script uses `:let` for every assignment, while in Vim9 declarations
1683 both immutable. This was also used in legacy Vim script and the meaning is
1691 Since legacy and Vim9 script will be mixed and global variables will be
1764 A problem of legacy Vim script is that by default all functions and variables
1765 are global. It is possible to make them script-local, but then they are not
1769 In Vim9 script a mechanism very similar to the JavaScript import and export
1772 - Instead of making everything global by default, everything is script-local,
1774 - When importing a script the symbols that are imported are explicitly listed,
1776 - The mechanism allows for writing a big, long script with a very clear API:
1782 - The Vim-specific use of "s:" to make things script-local can be dropped.
1784 When sourcing a Vim9 script from a legacy script, only the items defined
1786 - All the exported items become available as script-local items. This makes
1790 - Completely disallow sourcing a Vim9 script, require using `:import`. That
1793 Note that you can also use `:import` in legacy Vim script, see above.
1808 execute the script and compile the functions. This means the script has to be
1809 parsed twice, which is slower, and some conditions at the script level, such
1813 It would be possible to compile all the functions at the end of the script.
1826 and concentrate on Vim script.
1834 the tool into Vim script. For that to be possible without too much
1847 The support of classes in Vim9 script is a "minimal common functionality" of