Note: This gist is now part of VimBits plugin.
As a Vim user, you might prefer the new vim9script over the legacy script, and wish to use it in the command line. While there's no direct option to switch the command line to parse vim9script, you can execute vim9script commands by simply prepending each command with vim9
.
However, remember that execution occurs in the global context, not the script-local context. This means you need to declare variables with the g:
prefix, like g:foo = 'bar'
.
Common commands such as visual mode select ('<,'>
), shell commands (!
), substitution (s//
), and global (g//
) work as expected, even with vim9
prepended.