Software Update: Vim 9.0

Spread the love

Version 9.0 of Vi IMproved, or Vim, has been released. This universal editor was once developed by Bram Moolenaar for the Commodore Amiga, but is now also available for Unix, Linux, macOS, OS/2, DOS and Windows. Vim is not actively developed and usually there are a few years between the different versions. The release notes for this release can be found below.

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.

A secondary goal is to avoid Vim-specific constructs and get closer to commonly used programming languages, such as JavaScript, TypeScript and Java.

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 callassignments are done without pay attention and expressions are evaluated without eval† This makes a Vim9 script look a lot more like most programming languages.

Splitting up a large script into 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.

Version number 9.0
Release status Final
Operating systems Windows 7, Linux, BSD, DOS, macOS, Solaris, UNIX, Windows Server 2008, Windows Server 2012, Windows 8, Windows 10, Windows Server 2016, Windows Server 2019, Windows 11
Website vim
License type Freeware
You might also like