On Structured Regular Expressions and neovim (and vis)

Út 03 března 2020

(meant as an extended comment on neovim’s bug #8457: “Support sam/vim Structured Regular Expressions?”)

This is not a comprehensive review of vis or even just its comparison with vim. I would like to just describe my small moment of epiphany when working on some document with vis.

There is my large to-do list (actually maintained with VimOutliner, so that’s another problem) with all my work tasks. There is a couple of bugs which I am fixing with one large submit request. Unfortunately, it was a really huge request (basically rebasing of Python package for old SLE distribution to the latest 2.7.* version), and I haven’t managed to make the submission right on the first attempt. Or even on the second one. Or even … You get the picture. So, I have to update the number of the submit request multiple times.

The solution with the regular vim (or neovim, or any other vi-like editor) is something I can do in my dreams:


When thinking about this, it surprise how ridiculous this is. I really don’t to “search for the line which contains this particular pattern from it and replace it with this new pattern”. And of course, this is just very simple example, substitute command can get a way more complicated.

When doing the same with vis the command was slightly different (and not the only one possible), but it seems to me much more logical:

:x/ssr#oldnumber/ x/\d+/ c/newnumber/

Couple of comments on this. Yes, these all three commands are on one command line just separated with space. Vis, not being kept down by the compatibility with vi uses more normal regular expression engine (libtre, which implements POSIX Extended REs with some enhancements like approximate matches).

More on the higher level. I have intentionally used this very simple example to show that even in this level it makes more sense to me (more complicated examples are available). “Select broadly what you want, pinpoint on what exactly you want to change, and do it” makes much more sense, than (subconscious) translating my real task into the world of lines and matching them.

My suspicion is that with the rising complexity of the task, complexity of the vim substitute command rises exponentially, whereas the commands with vis rises just linearly. However, I would have to work on this more.

Category: computer Tagged: neovim regexp plan9 vis

Page 1 of 1