Versie 9.0 van Vi IMproved, oftewel Vim, is uitgekomen. Deze universele editor is ooit door Bram Moolenaar voor de Commodore Amiga ontwikkeld, maar is tegenwoordig ook voor Unix, Linux, macOS, OS/2, DOS en Windows beschikbaar. Vim wordt niet actief ontwikkeld en meestal zitten er een paar jaar tussen de verschillende versies. De releasenotes voor deze uitgave kunnen hieronder worden gevonden.
Vim 9.0 released
After many years of gradual improvement Vim now takes a big step with a major release. Besides many small additions the spotlight is on a new incarnation of the Vim script language: Vim9 script.
The previous release was version 8.2 in December 2019. Since the latest source code is always available on GitHub, many have already picked up later patch versions (there are more than 5000 of them!). Therefore the changes have already been tried out by many users. On top of that bugs have been fixed, security issues have been addressed, and many tests have been added. Code coverage has been dramatically increased. This version is more reliable than any before.Why Vim9 Script
A new script language, what is that needed for? Vim script has been growing over time, while preserving backwards compatibility. That means bad choices from the past often can't be changed and compatibility with Vi restricts possible solutions. Execution is quite slow, each line is parsed every time it is executed.
The main goal of Vim9 script is to drastically improve performance. This is accomplished by compiling commands into instructions that can be efficiently executed. An increase in execution speed of 10 to 100 times can be expected.
The performance improvements can only be achieved by not being 100% backwards compatible. For example, making function arguments available by creating an "a:" dictionary involves quite a lot of overhead. In a Vim9 function this dictionary is not available. Other differences are more subtle, such as how errors are handled.
For those with a large collection of legacy scripts: Not to worry! They will keep working as before. There are no plans to drop support for legacy script. No drama like with the deprecation of Python 2.Interesting Features
To profit from the speedup a function must be defined with def. The argument and return types must be specified. This is not only to make execution faster, it also helps uncovering mistakes early, when the function is compiled into byte code. Variables are declared with var and also have a type, either explicitly or inferred from the assigned value.
Line continuation does not require using a backslash, the mechanism that is used in legacy script, which is a bit weird and was required to keep it backwards compatible. Function calls do not require call, assignments are done without let and expressions are evaluated without eval. This makes a Vim9 script look a lot more like most programming languages.
Splitting up a large script in small pieces has been made a lot simpler. In one script export is used to make specific functions and variables available to other scripts. The rest is local to the script. Then import is used where the exported items are to be used. Combined with an autoload mechanism this makes a flexible and powerful way to implement large plugins.
Comments now start with #. The previous double quote syntax, which comes from the good old Vi, interferes with how strings are used. The use of # is known from many other languages, such as Python and shell scripts.
Otherwise most things work the same way. Users who have written Vim script will find it easy to switch over. Unexpected differences usually lead to an error message with a hint how to do make the line work in Vim9 script. Details about Vim9 script and rationale for the choices can be found here or with :help vim9 in Vim.
Otherwise, many improvements were made not related to Vim9 script. You can find a list here or with :help new-9 in Vim.