9

So my question is simple. Is it a good idea to learn vim scripting just to create vim or we should adopt some other more accepted languages to that.

For example This link opens a YouTube videos which shows How to use Python to create vim plugins.

Vim scripts are not entirely useful unless one intends to create some vim plugins. So is there any particular thing that can not be done unless vim scripts are used only ?

  • 2
    Note that many people use vimscript to configure (very thoroughly) their Vim, without creating or distributing any plugins. – VanLaser Nov 26 '15 at 11:23
10

My plugins are 99% in VimL. The reason is that VimL is available where vim is installed. It's much more complicated with other languages -- for instance, it's rare I have Python installed on the windows boxes where I use Vim.

Of course VimL is cumbersome, it's missing many cool features, but at least, it's easier to have something portable.

The 1% not in VimL is when I need to interact with external API which offer python bindings.

BTW, almost everything you learn regarding VimL can be used interactively when you play with commands like :substitute. Most mappings or macros don't need python either.

  • 1
    I actually don't find VimL that cumbersome. Of course, I agree it lacks cool features and functionality of higher level languages like python, but after working with it for some time, I find VimL quite pleasant to work with. I think the reputation for VimL is worse than it needs be. – Karl Yngve Lervåg Nov 26 '15 at 10:21
  • Well. I must admit that many progresses have been made since vim5.x (when I started using it). But there still are corner cases where we have to do complex things. See for instance map() that expects strings or (the unrelated) :map. I often have to play with/around string evaluation to come to my ends like generating mappings or processing list of function calls, ... – Luc Hermitte Nov 26 '15 at 12:34
  • Writing vim plugins in another language doesn't free you from learning VimL anyhow, because the bindings to python/ruby/etc. are pretty limited and you inevitably end up execing snippets of VimL anyway. It lets you write your core logic in a language that you might be able to work a lot more efficiently in, but you still pretty much need to learn VimL. – hobbs Nov 27 '15 at 4:51
10

If you intend to write plugins you definitively should read the nice article "Writing Vim Plugins", by Steve Losh; not only for deciding if you will stick with VimL or not, but for the best practice advices.

It also contains a small discussion about Scripting Vim with Other Languages:

First, using another language will requires your plugin’s users to use a version of Vim compiled with support for that version. In this day and age it’s usually not a problem, but if you want your plugin to run everywhere then it’s not an option.

Using another language adds overhead. You need to not only learn Vimscript but also the interface between Vim and the language. For small plugins this can add more complexity to the project than it saves, but for larger plugins it can pay for itself. It’s up to you to decide whether it’s worth it.

Finally, using another language does not entirely insulate you from the eccentricities of Vimscript. You still need to learn how to do most things in Vimscript — using another language simply lets you wrap most of this up more neatly than you otherwise could.

My experience is that even when a non-VimL plugin is better, I end up switching to a pure VimL alternative later, mainly because of portability. Vim runs on virtually any system (even ugly and old legacy systems), and the overhead of setting up the dependencies or temporary disabling that plugin is not worth (especially if you keep forgetting that you disabled it and trying to use its mappings/commands).

Even when it is easier to setup the dependencies you can hit some problems (e.g.: some python-based plugins doesn't works 100% when they are sourced from shared folders on Virtual Machines). That is why the few plugins I wrote use VimL only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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