If I run e.g. :var a = 1 from the command line I end up in E1124: "var" cannot be used in legacy vimscript. Running on MacVim 9.0.1276.

Is it normal behavior?

2 Answers 2


To use the vim9 script syntax your script must include as the first command vim9script.


var a = 1

On the command line to run vim9 script command you have to prefix them with :vim9

:vim9 g:a = 1

This is because the commandline runs :legacy-mode by default unless :vim9cmd is used.

  • Is there any way to change the default behavior?
    – Barzi2001
    Commented Feb 24, 2023 at 6:47
  • @Barzi2001 Not currently.
    – dza
    Commented Feb 24, 2023 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.