- usr_52.txt* For Vim version 9.0. Last change: 2022 Jun 04
VIM USER MANUAL - by Bram Moolenaar
Write larger plugins
When plugins do more than simple things, they tend to grow big. This file
explains how to make sure they still load fast and how to split them up in
smaller parts.
|52.1| Export and import
|52.2| Autoloading
|52.3| Autoloading without import/export
|52.4| Other mechanisms to use
|52.5| Using a Vim9 script from legacy script
Next chapter: |usr_90.txt| Installing Vim
Previous chapter: |usr_51.txt| Create a plugin
Table of contents: |usr_toc.txt|
==============================================================================
Vim9 script was designed to make it easier to write large Vim scripts. It
looks more like other script languages, especially Typescript. Also,
functions are compiled into instructions that can be executed quickly. This
makes Vim9 script a lot faster, up to a 100 times.
The basic idea is that a script file has items that are private, only used
inside the script file, and items that are exported, which can be used by
scripts that import them. That makes very clear what is defined where.
Let's start with an example, a script that exports one function and has one
private function: >
vim9script
export def GetMessage(count: string): string
var nr = str2nr(count)
var result =