Introducing Vim9 Script: A High‑Performance Scripting Language for Vim
Vim9 Script, the new major version of Vim's scripting language, brings dramatic performance gains, modern syntax, and features like typed functions, module imports, and class‑like structures while maintaining compatibility with existing Vim scripts.
After years of gradual improvement, Vim now releases an important version, taking a big step forward. In addition to many small incremental improvements, the focus of this version is a new change to the Vim script language: Vim9 Script.
The previous version was 8.2 released in December 2019. Because the latest source code is always available on GitHub, many users have already installed later patch versions (over 5000), and these changes have been tried by many users. Based on 8.2, many bugs have been fixed, security issues resolved, and code coverage greatly increased. This version is more reliable than any previous version.
Vim9 Script
Vim's script has evolved over time while retaining backward compatibility. This means past design choices cannot be changed, and compatibility with Vi limits possible solutions. Consequently execution speed is quite slow, as each line is parsed on every execution.
The main goal of Vim9 Script is to dramatically improve performance. This is achieved by compiling commands into efficiently executable instructions, with expected speed gains of 10 to 100 times.
A secondary goal is to avoid Vim‑specific structures, making it closer to common programming languages such as JavaScript, TypeScript, and Java.
Performance improvements can only be achieved without 100% backward compatibility. For example, creating an “a:” dictionary to make function arguments available incurs considerable overhead; in Vim9 functions this dictionary is no longer available.
Developers with large amounts of traditional scripts need not worry; those scripts can still be used as before. There are no plans to drop support for traditional scripts, and the changes will not be as drastic as Python 2 to Python 3.
Interesting Features
To benefit from acceleration, a function must be defined with def , specifying parameter and return types. This not only speeds execution but also helps catch errors early when the function is compiled to bytecode. Variables need to be declared with var , which also has a type, either explicit or inferred from the assigned value.
Line continuation no longer requires a backslash, which was used in traditional scripts.
Function calls do not need call , assignments do not need let , and expression evaluation does not need eval . This makes Vim9 Script look more like most programming languages.
Splitting a large script into smaller pieces is now easier. Within a script, export is used to make specific functions and variables available to other scripts, and import is used where those exported items are needed. Combined with the autoload mechanism, this provides a flexible and powerful way to implement large plugins.
Comments now start with # . The previous double‑quote syntax came from ancient Vi and interfered with string usage. In many other languages, such as Python and shell scripts, the meaning of # is well known.
Future Work
One of the plans for Vim9 Script is to add classes. Although classes can be simulated with dictionaries, that is far from ideal. Most programmers are familiar with classes, and they should be added to Vim9 Script; the keyword has already been reserved.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.