The Vis Editor
Vim/Vim Classic/Neovim provide indispensable improvements over Vi, but they
are also massive, and one could spend years finding new features and
adjustments in
:help.
Vis is an editor that is very capable yet the entire user interface can be
summarized in about 1000 lines.
Switching from Vim
| vim → vis | ||
|---|---|---|
| Search for text (must be valid regular expression) |
/
main(
|
/
main\(
|
| Search-and-replace is implemented using structured regular expressions |
:
%s/xyz/XYZ/
|
:
x/xyz/ c/XYZ/
|
| Default key bindings do not define line-oriented yank |
Y
or
yy
|
0Y
|
| Read output from external shell commands |
:
r!command
|
:
< command
|
| Add comment to beinning of each line of a paragraph |
C-v
⇵
I
#
Esc
|
v
⇵
:x/^/
i
#
|
Word Wrap
Unlike Vim,
=
is used to wrap text. Edit
config.def.h
or create a wrapper script to change the formatting rules
#!/bin/sh exec /usr/bin/fmt -w ${FMT_W:=80} "$@"
Digraphs
A dedicated utility
vis-digraph(1)
is used to insert special characters.
As with Vim, it is accessible using
C-k
in insert mode. With no argument this utility prints a list with human
readable descriptions, which makes finding the right character easy.
Structured Regular Expressions
from the Differences from Sam wiki page:
-
Select every line that is not a comment, and select
set
-
Capitalize every instance of
i
:y/[\t]--.+/ x/set / :x/[A-Za-z]+/ g/^i$/ c/I/
To see how capable these changes are, try sanitizing a YouTube transcript, which has hours/minutes/seconds mixed in at the beginning of each line
00:5555 secondsthe quick brown fox 01:041 minute, 4 secondsjumped over 02:002 minutesthe lazy dog
Commands
:x/.+ (second|minute)[s]/ o 5<Right> :c/ /
Result
00:55 the quick brown fox 01:04 jumped over 02:00 the lazy dog
My visrc
~/.config/vis/visrc.lua
require('vis') require('plugins/filetype-settings') vis.events.subscribe(vis.events.INIT, function() -- vis:command('set theme zenburn') -- vis:command('set theme base16-nord') vis:command('set theme base16-solarized-light') end) vis.events.subscribe(vis.events.WIN_OPEN, function(win) vis:command('set number') vis:command('set tabwidth 4') vis:command('set showtab on') end) settings = { python = {"set expandtab on"}, ruby = {"set expandtab on", "set tabwidth 2"}, } -- F7 in normal mode spellcheck = require('plugins/spellcheck') spellcheck.default_lang = "en_US"
References
Vis Editor
– CoSin 2017
vis(1)
Vis Editor and Lua API documentation
A visrc.lua config
The vi family