In the world of terminal editors, Vim provides unmatched speed through modal editing, while tools like sed and awk provide unmatched text manipulation through regular expressions.
But what if you could perfectly combine the two?
Enter Vis.
Vis is a modern, highly efficient text editor that takes the modal editing interface of Vim (including its exact keybindings) and fuses it with the revolutionary “Structural Regular Expression” engine created by Rob Pike for the legendary Plan 9 sam editor.
Why Vis is Revolutionary
If you are a Vim user, you know how frustrating it is to perform complex, multi-line edits. Vim operates heavily on single lines. If you want to find a block of text, filter out certain lines within that block, and then append a semicolon to whatever is left, you usually have to write a complex macro.
Vis solves this using Structural Regular Expressions. Instead of regular expressions just matching strings, Vis uses them to select regions of text.
You can chain commands together to say: “Find all functions, extract only the ones containing the word ‘foo’, and then select the last word of those functions.” Once selected, you drop into Insert Mode, and you edit all of those selections simultaneously with multiple cursors.
Installation
Vis is lightweight and written in C with a built-in Lua extension system.
Debian/Ubuntu:
sudo apt update
sudo apt install vis
macOS:
brew install vis
Launch the editor simply by typing vis filename.txt.
Vim Muscle Memory
If you know Vim, you are already 90% proficient in Vis.
- You start in Normal mode.
h,j,k,lmove the cursor.ienters Insert mode.dddeletes a line.yyyanks (copies) a line.:wsaves the file, and:qquits.
You can use Vis exactly like Vim, and you will enjoy a very fast, extremely minimal editor. But the true power unlocks when you press x.
Structural Regular Expressions
In Vis, the x command is used to select text that matches a regular expression.
Imagine you have a file containing a massive list of IP addresses and server names, and you want to select every single IP address in the file simultaneously.
- In Normal mode, type
x(this opens the command prompt at the bottom). - Type your regex for an IP address:
/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ - Hit Enter.
Instantly, Vis places a multiple-cursor selection on every single IP address in the file. If you press c (change), all the IP addresses disappear, you drop into Insert mode, and you can type a new replacement for all of them at once.
Chaining Commands
The magic of structural regex is chaining.
You can use y (the opposite of x) to exclude text from a selection.
For example, to select all lines containing “Warning”, but exclude the ones that contain “Ignored”, you would type:
x/.*Warning.*/ y/.*Ignored.*/
Vis processes this left to right. First, it selects all lines with “Warning”. Then, from that pool of selections, it un-selects anything containing “Ignored”. You are left with exactly the cursors you need.
The Lua API
Just like Neovim, Vis has completely embraced Lua as its extension language.
By editing your ~/.config/vis/visrc.lua file, you can write incredibly powerful scripts to manipulate text, map new keys, and interact with the editor’s core engine, all without the bloat of older scripting languages.
Conclusion
Vis is not for the faint of heart. It is designed for absolute power users who process logs, refactor massive codebases, and dream in regular expressions.
By combining the muscle-memory perfection of Vim’s modal editing with the unparalleled text-selection power of Plan 9, Vis is truly a hidden gem in the Linux editor ecosystem. If you are ready to take your text manipulation skills to the ultimate level, give Vis a try.
Discussion
Loading comments...