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:

:%s/\(ssr#\)oldnumber/\1newnumber/gc

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: vim regexp plan9 vis

comments


Convert RHEL-7 to CentOS

St 02 května 2018

I have tried to suggest update of Migration Guide for RHEL7→CentOS7 migration, but apparently after CentOS was bought by Red Hat, there is not enough desire to document such migration, ehm ehm. So, just recording this for posteriority:

URLBASE=http://mirror.centos.org/centos/7/os/x86_64/Packages
cd …

Category: computer Tagged: linux

comments

Read More

Harry Potter and The Jabber Spam

Pá 13 ledna 2017

After many many years of happy using XMPP we were finally awarded with the respect of spammers and suddenly some of us (especially those who have their JID in their email signature) are getting a lot of spim.

Fortunately, the world of Jabber is not so defenceless, thanks to XEP-0016 …

Category: computer Tagged: xmpp

comments

Read More

Firefox OS post-mortem

So 26 září 2015

So, it happened. My Flame stopped working, it just doesn’t react to anything (power off switch, power cable), and of course being a weird unknown China-only thing, no local repair shop would touch it. I probably could ask somebody at Mozilla for another one, but I already knew I …

Category: computer Tagged: firefoxOS review

comments

Read More

On bibshare

Čt 04 září 2014

(this is originally a comment on the post about “scientific Markdown”)

In my previous life I was using heavily TeX and BibTeX for writing a scholarly articles when working on my PhD in sociology. When doing a large BibTeX database of bibliopgraphy there is a certain moment when one needs …

Category: computer Tagged: TeX BibTeX bibliography metadata

comments

Read More
Page 1 of 4

Next »