Vis: Vim Improved, on Steroids
──────────────────────────────────────────────────────────────────────

Ok it's a clickbait. But hey, you might as well keep reading now!

I've been using vis[0] as my main editor for a few years now, and
decided to make this post to bring attention onto it.
But first, let's have some context.

Vim
===

I've been using Vim for a very long time (prior to may 2013, according
to git). During this time, I went through most of the phases of a good
Vim fanboy:

- ^C^C^C^Cquit^Mend^Mexit^M*reboot*
- Using normal mode just for HJKL
- Use HJKL in Every. Single. Application.
- Join the crusades against Emacs
- Changing my .vimrc every 5 second
- Read the Arabesque blog[1] a 1000 times
- Have 34792492 plugins, with 5 different plugin managers
- Have 0 plugin because THIS IS TRUE VIM
- rm ~/.vimrc because THIS IS TRUE VIM
- Play vimgolf all day
- …

But after some time of being a happy little Vim user, I fell into the
Plan9 trap.

Acme, Sam, Wily!

Three editors centered around the mouse, just as I conviced myself that
I didn't need a mouse, and that keyboard-centric interfaces are the
future, a cute little thing named Glenda[2] brought me down her rabbit
hole...

I used Vim for so long at this point that I didn't see myself changing
editor, but it still got me curious: what is so powerful about these
editors, that so many people praise them ?

I've read many papers, blogs, whatched videos to learn about Acme and
Sam and their strength. That's where I learnt about Sam's Structural
Regular Expressions:

https://doc.cat-v.org/bell_labs/structural_regexps/se.pdf

I kept reading about Sam, and it made me realize Vim's greatest
weakness:

It deals with lines of text.

This does not seem like a big deal, but it makes a huge difference!
Imagine the following code:

       int foo = 0;
       foo = random() % 16;
       if (foo > 7) {
               foo = do_stuff(foo)
       }
       return foo;

Now assume we want to change a few things:

0. rename "foo" to "bar"
1. remove the useless "= 0"
2. add the missing ; on line 4

How would we do these with Vim commands ?

0. :%s/foo/bar/g
1. :1s/ = 0// (or "ggt=dt;")
2. :4s/$/;/ (or "4GA;<ESC>")

Do you notice the pattern ? Even though Vim has :change, :delete and
:append/:insert commands, we used :substitute for all of them!  Think
about it the next time you use Vim. The substitute command is used 90%
of the time when using commands.

Here's how you'd do it with Sam now:

0. x/foo/ c/bar/
1. 1x/ = 0/ d
2. 4x/$/ a/;/

The x command eXtracts the selected text and runs a command on it, for
each selection separately. This is a very powerful concept, as it lets
you manipulate the text as a whole, rather than only interacting with
it one line at a time. The sam language has even more powerful features
which are described in its tutorial:

http://doc.cat-v.org/bell_labs/sam_lang_tutorial/sam_tut.pdf

Unfortunately for me, and even though Sam has a very powerful command
language, navigating the file is done exclusively with the mouse. And
I could just not give up on the muscle memory I built over all these
years of using Vim.


So what were my options ? Going back to Vim, after seing the greener
side of the grass ? Give up on Vim, and the power of modal editing ?

Vis
===

There was a third option of course: Vis !

When I first found about it, vis was a small project seeking to provide
"90% of the features of Vim, in 10% of the code". This was immediately
appealing to me, and I immediately tried it. It had rough edges, and I
missed a few features, but it was clean and fast.

Then the project became more mature, and a new feature appeared: The
Sam language was implemented into it. I was thrilled!

Vis combines the strength of both Vim and Sam into what I believe is
the ultimate text editor. Selections (or DOT) benefits from Vim "visual"
mode, allowing one to edit different portions of the file at the same
time, with multiple cursors.

And to put the icing on the cake, you can write plugins for it using
Lua.

Whether you're a plan9 fan looking for a good Sam implementation, or an
avid Vim user, I urge you to try it, and embrace the other side of the
text editing that you're going to learn.

Acme
====

Of course, I could not end this post without talking about Acme[3],
which I believe is the next step of editing evolution. I'm however too
scared to really commit to it, and buy a 3 buttons mouse for this sole
purpose (but I know I will, someday).

However, there is a middleground: Edit[4]! This project has not been
updated in a long time, but looks like a marvelous concept that I would
like to explore in the future.

Maybe the next (last?) step is Vim + Sam + Acme ?
--
~wgs

[0]: https://github.com/martanne/vis
[1]: https://blog.sanctum.geek.nz/category/vim
[2]: http://glenda.cat-v.org
[3]: http://acme.cat-v.org
[4]: https://c9x.me/edit

20230707.0115