7

I've finally made the decision to learn vimscript. I don't hate reading manual and really like the built-in help files, so I am starting with usr_41.txt and plan to read eval.txt afterwards.

Now as I run through the usr_41.txt, I notice it frequently mentions the newly released vim9script, which, as I understand, is the new-generation vimscript that should be used. But the vim9.txt seems mostly focusing on its difference from the legacy script, so usr_41.txt and eval.txt are still must reads before it.

My problem is the freely mixed introductions of legacy and vim9script in usr_41.txt and eval.txt make them really hard to read and remember. My limited brain just can't handle the idiosyncratic differences between them.

Now I wonder if I should learn vim9script in the first place. Maybe I should ignore it first and learn the legacy script until understanding most of it and then relearn vim9scirpt? Or should I ignore the legacy version wherever there's a discrepancy?

What's your opinion about learning vimscript at this time? What's your recommended way to master it?

ps: I know this question might be off-topic or heavily opinion-based, but 1. I'm not asking for resources but questions about the built-in help files; 2. I really need this help, comments are also much appreciated even if this question might get closed.

2
  • 4
    vimscript won't be deprecated due to the amount of resources using it. It is still relevant and will stay relevant for many years. If you're planning to publish plugins for the vim and neovim ecosystem, then vimscript is the only option now. It is a good idea to get comfortable reading and to some extent, writing vimscript. Both languages are very similar, so once you understand vimscript, it is easy to read :h vim9 and understand the differences. As for usr_41, read the version for vim 8.2 (github.com/vim/vim/blob/…)
    – r_31415
    Jul 17, 2022 at 16:26
  • 1
    @r_31415 Thank you very much. The linked version is really all I need.
    – Masquue
    Jul 17, 2022 at 17:32

1 Answer 1

6

The main point of vim9script is to allow Vim plug-ins to access better performance for operations that are typically too slow to perform in the traditional vimscript and historically have required plug-ins to require use of external languages such as Python, Ruby, etc.

Note that NeoVim solved this issue differently, by promoting Lua to a first class language.

In all cases, the regular vimscript is still available (and, in many ways, necessary.) vim9script is in some ways an addition, that requires tagging files with a special identifier to indicate that vim9script is in use. But the regular commands typed in the Ex command-line (after pressing :) are still regular vimscript and are likely to continue to be regular vimscript.

Therefore, learning the regular old vimscript is not a bad idea, since it's still applicable for simple plug-ins that don't have stringent performance requirements and it's likely to stick around forever.

The documentation is great as a reference, but it doesn't necessarily serve well as a step-by-step tutorial, teaching concepts in the order you'll need them. For that, my recommendation is to use “Learn Vimscript the Hard Way” as a start to learn about the language, and then proceed from there.

It's true that vim9script changes some language concepts from the old vimscript, to fix some quirks and corner cases. But, in my opinion, the best way to learn about those is to understand why those can be a problem in the old vimscript and then understand what the vim9script solution does. So, again, starting with learning the old vimscript is not a bad idea.

Finally, vim9script is only available in very recent versions of Vim, and depending on whether you want to ship plug-ins that are accessible to a wide range of users, you might encounter many who are using the Vim binary that came with their O.S. (be it MacOS or Linux), so you're likely to find a fair share of Vim 8.2, 8.1 and even 8.0, that will have no access to vim9script (vim9script features were available to some extent on later versions of Vim 8.2, but still.) So from that standpoint too, you might be better off for another while authoring traditional vimscript code, which is likely to be more portable to existing environments than vim9script which will have limited availability at this point.

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.