Vis editor tutorial
Those notes are meant for those who already know vi/vim.
What's vis
Vis is a modal editor inspired by both vi(m) and sam. Basically it's vi with ex
replaced by sam regexes.
Objective of this article
Vis doesn't have a proper tutorial, to learn it you have to read its help and
manpage. There is a video demonstration on ascii I find it quite inconvienant,
I prefer to learn by pratice.
It is recommanded to download this gmi file, so you can open it in vis.
Basic sam regexes
So that, you don't mess the rest of the file select with visual mode examples.
Substitution
To do a subsitution type :x/patern_to_replace/ c/replacement/<Enter>
Try it out by replacing thee by the in the following text :
thee best time to see thee flowers is in thee spring.
Now let's decompose what we just did :
- the first command x, select text in a regex
- Then with c we changed the selected text
Those two commands are independant try to do this :
- :x/the/<Enter>
- :c/thee<Enter>
As you might have noticed, when executing the x command you switched to visual
mode.
So there is a third way to substitute text :
- :x/thee/<Enter>
- While in visual mode press c
- type the and then press <Escape>
Append/Insert text
- you can insert text with the following command : i/text/
- and this command to append text: a/text/
add the missing letters in the next line (example : x/ext/ i/t/)
this text, is missin a few letter
Warning : if you want to do the same with vi command you have to first press
<Escape> to get back to insert mode, you'll have a cursor placed at the beginning
of every selection.
Deletion
The d command is used for deleting selection.
Delete every comma in the following line:
This, text, as, a, lot, of, commas.