VIS(1) | General Commands Manual | VIS(1) |
vis
— a highly
efficient text editor
vis |
[-v ]
[+ command]
[-- ] [files ...] |
vis
is a highly efficient screen-oriented
text editor combining the strengths of both vi(m)
and sam
. This manual page is intended for users
already familiar with
vi
/sam
. Anyone else should
almost certainly read a good tutorial on either editor before this manual
page. The following options are available:
-v
+
command--
The special file -
instructs
vis
to read from standard input in which case
:wq
will write to standard output, thereby enabling
usage as an interactive filter.
If standard input is redirected and all input is consumed,
vis
will open /dev/tty to
gather further commands. Failure to do so results in program
termination.
vis
uses selections as core editing
primitives. A selection is a non-empty, directed range with two endpoints
called
cursor
and
anchor.
A selection can be anchored in which case the anchor remains fixed while
only the position of the cursor is adjusted. For non-anchored selections
both endpoints are updated. A singleton selection covers one character on
which both cursor and anchor reside. There always exists a primary selection
which remains visible (i.e. changes to its position will adjust the
viewport).
vis
employs the same
modal
editing approach as vi
. It supports a
‘normal’, ‘operator pending’,
‘insert’, ‘replace’ and ‘visual’
(in both line and character wise variants) mode. The visual block and ex
modes are deliberately not implemented, instead vis
has built in support for multiple selections and an
interactive variant of the structural regular expression
based command language of sam
.
In normal mode all selections are non-anchored and reduced to a single character.
vis
uses an undo tree to keep track of
text revisions. The u
(undo) and
⟨C-r
⟩ (redo) commands can be used to
traverse the tree along the main branch. g+
and
g-
traverse the history in chronological order. The
:earlier
and :later
commands
provide means to restore the text to an arbitrary state.
A mark associates a symbolic name to a set of selections. A stored
selection becomes invalid when its delimiting boundaries change in the
underlying buffer. If said changes are later undone the mark becomes valid
again. m
sets a mark, M
restores it. For example,
'
am
sets the mark a while
'
aM
restores it. Use of m
or M
without specifying a mark uses the default mark.
Available marks are:
No marks across files are supported. Marks are not preserved over editing sessions.
A per window, fixed sized file local jump list exists which stores marks (i.e. set of selections).
Registers are named lists of text. Uninitialized register slots default to the empty string. Available registers are:
""
"a
–"z
"A
–"Z
"*
, "+
"0
"1
–"9
"&
x
or
y
command"/
":
"_
"#
If no explicit register is specified the default register is used.
The general purpose registers
"a
–"z
can
be used to record macros. Use one of
"A
–"Z
to
append to an existing macro. q
starts a recording,
@
plays it back. @@
refers
to the most recently recorded macro. @:
repeats the
last :
-command. @/
is
equivalent to n
in normal mode. These operations
always use the first register slot.
vis
always assumes the input file to be
UTF-8 encoded with \n
line endings. If you wish to
edit files with legacy encodings or non-Unix line endings, use
iconv(1) and dos2unix(1) to convert them
as needed. ⟨Tab
⟩ can optionally be
expanded to a configurable number of spaces (see
SET OPTIONS).
The mouse is currently not used at all.
vis
supports an interactive variant of the
structural regular expression based command language introduced by
sam(1).
vis
currently defers regular expression
matching to the underlying C library. It uses what POSIX refers to as
“Extended Regular Expressions” as described in
regex(7). The anchors ^
and
$
match the beginning / end of the range they are
applied to. Additionally \n
and
\t
may be used to refer to newlines and tabs,
respectively. The .
atom matches any character
except newline. The empty regular expression stands for the last complete
expression encountered.
An address identifies a substring (or range) in a file. In the
following “character n” means the null
string after the n-th character in the file, with 1
the first character in the file. “Line
n” means the n-th match,
starting at the beginning of the file, of the regular expression
“.*\n?
”.
All windows always have at least one current substring
which is the default address. In sam this is referred to as
dot. In
vis
multiple “dots” (or selections)
can exist at the same time.
#
n#0
is the beginning of the file./
regexp/
?
regexp?
/
) or beginning
(?
) of the file. The search does not wrap around
when hitting the end (start) of the file.0
+
and -
below.$
.
'
mIn the following, a1 and a2 are addresses.
+
a2-
a2,
a20
is substituted. If a2 is
missing, $
is substituted.;
a2,
a2
but with a2 evaluated at the end of, and range set
to, a1.The operators +
and
-
are high precedence, while
,
and ;
are low
precedence.
In both +
and -
forms, if a2 is a line or character address with a
missing number, the number defaults to 1. If a1 is
missing, .
is substituted. If both
a1 and a2 are present and
distinguishable, +
may be elided.
a2 may be a regular expression; if it is delimited by
?
characters, the effect of the
+
or -
is reversed. The
%
sign is an alias for ,
and
hence 0,$
. It is an error for a compound address to
represent a malformed substring.
In the following, text demarcated by slashes represents text
delimited by any printable ASCII character except alphanumerics. Any number
of trailing delimiters may be elided, with multiple elisions then
representing null strings, but the first delimiter must always be present.
In any delimited text, newline may not appear literally;
\n
and \t
may be typed for
newline and tab; \/
quotes the delimiter, here
/
. An ampersand &
and
\
n, where
n is a digit (1–9) are replaced by the
corresponding register. Backslash is otherwise interpreted literally.
Most commands may be prefixed with an address to indicate their
range of operation. If a command takes an address and none is supplied, a
default address is used. In normal mode this equates to the character the
selection is currently over. If only one selection exists
x
and y
default to the whole
file 0,$
. In normal mode the write commands
w
and wq
always apply to the
whole file. Commands are executed once for every selection. In visual mode
the commands are applied to every selection as if an implicit
x
command, matching the existing selections, was
present.
In the description, “range” is used to represent whatever address is supplied.
Many commands create new selections as a side effect when issued from a visual mode. If so, it is always to the “result” of the change: the new text for an insertion, the empty string for a deletion, the command output of a filter etc. If after a successful command execution no selections remain, the editor will switch to normal mode, otherwise it remains in visual mode. This allows interactive refinements of ranges.
p
e
[!
]
[file name]r
file namew
[!
]
[file name]0,$
) to the named
external file.wq
[!
]
[file name]w
, but close file afterwards.If the file name argument is absent from any of these, the current
file name is used. e
always sets the file name,
w
will do so if the file has no name. Forcing the
e
command with !
will
discard any unsaved changes. Forcing w
will
overwrite the file on disk even if it has been externally modified since
loading it. Write commands with a non-default addresses and no file name are
destructive and need always to be forced.
<
shell command>
shell command|
shell command!
shell commandcd
directory$HOME
is used.In any of <
,
>
, |
, or
!
, if the shell command is omitted, the last shell
command (of any type) is substituted. Unless the file being edited is
unnamed, all these external commands can refer to its absolute path and file
name through the vis_filepath
and
vis_filename
environment variables.
x/
regexp/
[command]The
"1
–"9
and "&
registers are updated with the
(sub) expression matches of the pattern.
y/
regexp/
[command]x
, but run the command for each substring
that lies before, between, or after the matches that would be generated by
x
. There is no default behavior. Null substrings
potentially occur before every character in the range.X/
regexp/
commandY/
regexp/
commandX
, but for files that do not match the
regular expression, and the expression is required.g
[count][/regexp/]
commandv
[count][/regexp/]
commandg
) or does not contain
(v
) a match for the expression, run command on the
range.
The count specifier has the following format, where n and m are integers denoting the ranges.
,
m1
is substituted. If m
is missing, ∞
is substituted. Negative
values are interpreted relative to the last range.%
nThese may be nested arbitrarily deeply. An empty command in an
x
or y
defaults to
p
. X
,
Y
, g
and
v
do not have defaults.
Commands may be grouped by enclosing them in curly braces. Semantically, the opening brace is like a command: it takes an (optional) address and runs each sub-command on the range. Commands within the braces are executed sequentially, but changes made by one command are not visible to other commands.
When a command makes a number of changes to a file, as in
x/
re/
c/
text/
,
the addresses of all changes are computed based on the initial state. If the
changes are non-overlapping, they are applied in the specified order.
Conflicting changes are rejected.
Braces may be nested arbitrarily.
In the following sections angle brackets are used to denote
special keys. The prefixes C-
,
S-
, and M-
are used to refer
to the ⟨Ctrl⟩, ⟨Shift⟩ and ⟨Alt⟩
modifiers, respectively.
All active key bindings can be listed at runtime using the
:help
command.
Operators perform a certain operation on a text range indicated by either a motion, a text object or an existing selection.
When used in normal mode, the following operators wait for a motion, putting vis into operator pending mode.
c
d
<
>
y
When used in normal mode, the following actions take effect immediately.
Motions take an initial file position and transform it to a destination file position, thereby defining a range.
0
b
B
$
e
E
F
⟨char⟩f
⟨char⟩^
g0
g$
ge
gE
gg
G
gj
gk
gh
gl
gH
gL
g_
gm
g|
h
H
j
k
l
L
%
}
)
N
n
[{
]}
[(
])
{
(
;
,
#
*
T
⟨char⟩t
⟨char⟩?
pattern/
patternw
W
Text objects take an initial file position and transform it to a
range where the former does not necessarily have to be contained in the
latter. All of the following text objects are implemented in an inner
variant (prefixed with i
) where the surrounding
white space or delimiting characters are not part of the resulting range and
a normal variant (prefixed with a
) where they
are.
w
W
s
p
[, ], (, ), {, },
<, >, ", ', `
Further available text objects include:
vis
supports multiple selections with
immediate visual feedback. There always exists one primary selection located
within the current view port. Additional selections can be created as
needed. If more than one selection exists, the primary one is styled
differently.
To manipulate selections use in normal mode:
C-k
⟩C-M-k
⟩C-j
⟩C-M-j
⟩C-p
⟩C-n
⟩C-u
⟩C-d
⟩C-c
⟩C-l
⟩Tab
⟩Escape
⟩The visual modes were enhanced to recognize:
I
A
Tab
⟩S-Tab
⟩C-a
⟩C-n
⟩C-x
⟩C-p
⟩C-u
⟩
⟨C-k
⟩C-d
⟩
⟨C-j
⟩C-c
⟩C-l
⟩+
-
_
o
Escape
⟩In insert and replace mode:
S-Tab
⟩Selections can be manipulated using set operations. The first
operand is the currently active selections while the second can be specified
as a mark. For example,
'
a|
produces the union of the mark a and the current
selection. Use of set operations without specifying a mark use the default
mark as the first operand.
Any unique prefix can be used to abbreviate a command.
A file must be opened in at least one window. If the last window
displaying a certain file is closed all unsaved changes are discarded.
Windows are equally sized and can be displayed in rows (horizontally) or in
columns (vertically). The ⟨C-w
⟩
h
, ⟨C-w
⟩
j
, ⟨C-w
⟩
k
and ⟨C-w
⟩
l
key mappings can be used to switch between
windows.
:new
:vnew
:open
[!
]
[file name]:split
[file name]:vsplit
[file name]:q
[!
]
[exit code]:qall
[!
]
[exit code]Commands taking a file name will invoke the vis-open(1) utility, if given a file pattern or directory.
vis
supports global as well as window
local run time key mappings which are always evaluated recursively.
:map
[!
]
mode lhs
rhs:map-window
[!
]
mode lhs
rhs:unmap
mode lhs:unmap-window
mode lhsIn the above mode refers to one of
‘normal
’,
‘insert
’,
‘replace
’,
‘visual
’,
‘visual-line
’ or
‘operator-pending
’;
lhs refers to the key to map and
rhs is a key action or alias. An existing mapping may
be overridden by forcing the map command by specifying
!
.
Because key mappings are always recursive, doing something like:
:map! normal j 2j
will not work because it would enter an endless loop. Instead,
vis
uses pseudo keys referred to as key actions
which can be used to invoke a set of available editor functions.
:help
lists all currently active key bindings as
well as all available symbolic keys.
In order to facilitate usage of non-latin keyboard layouts,
vis
allows one to map locale specific keys to their
latin equivalents by means of the
:langmap
locale-keys latin-keyscommand. As an example, the following maps the movement keys in Russian layout:
:langmap
ролд hjkl
If the key sequences have not the same length, the remainder of the longer sequence will be discarded.
The defined mappings take effect in all non-input modes, i.e. everywhere except in insert and replace mode.
If count is suffixed by either of d (days), h (hours), m (minutes) or s (seconds) it is interpreted as an offset from the current system time and the closest available text state is restored.
There are a small number of options that may be set (or unset) to
change the editor's behavior using the :set
command.
This section describes the options, their abbreviations and their default
values. Boolean options can be toggled by appending ! to
the option name.
In each entry below, the first part of the tag line is the full name of the option, followed by any equivalent abbreviations. The part in square brackets is the default value of the option.
shell
[“/bin/sh”]SHELL
and shell field of password database
/etc/passwdescdelay
[50]Escape
⟩ key.tabwidth
,
tw
[8]expandtab
is enabled.autoindent
,
ai
[off
]expandtab
,
et
[off
]Tab
⟩ should be expanded to
tabwidth
spaces.number
,
nu
[off
]relativenumbers
,
rnu
[off
]cursorline
,
cul
[off
]colorcolumn
,
cc
[0]horizon
[32768]theme
[“default-16” or “default-256”]syntax
[auto
]showtabs
[off
]shownewlines
[off
]showspaces
[off
]showeof
[on
]savemethod
[auto]loadmethod
[auto]layout
[“v” or “h”]ignorecase
,
ic
[off
]wrapcolumn
,
wc
[0]breakat
,
brk
[“”]The command and search prompt as opened by
:
, /
, or
?
is implemented as a single line height window,
displaying a regular file whose editing starts in insert mode.
⟨Escape
⟩ switches to normal mode, a
second ⟨Escape
⟩ cancels the prompt.
⟨Up
⟩ enlarges the window, giving
access to the command history. ⟨C-v
⟩
⟨Enter
⟩ inserts a literal new line
thus enabling multiline commands.
⟨Enter
⟩ executes the visual selection
if present, or else everything in the region spawned by the selection
position and the delimiting prompt symbols at the start of adjacent
lines.
vis
uses Lua for configuration and
scripting purposes. During startup visrc.lua (see
the FILES section) is sourced which can be
used to set personal configuration options. As an example the following will
enable the display of line numbers:
vis:command('set
number')
VIS_PATH
HOME
cd
command if no
argument is given.TERM
SHELL
!
, >
,
<
and |
.XDG_CONFIG_HOME
SIGSTOP
SIGCONT
SIGBUS
SIGHUP
SIGTERM
SIGINT
SIGWINCH
Upon startup vis
will source the first
visrc.lua configuration file found from these
locations. All actively used paths can be listed at runtime using the
:help
command.
vis
binary (on systems where
/proc/self/exe is available).XDG_CONFIG_HOME
refers to
$HOME/.config if unset.When creating a new visrc.lua be sure to copy the structure from here.
The vis
utility exits 0 on success,
and >0 if an error occurs.
Use vis
as an interactive filter.
$ { echo Pick your number; seq 1 10;
} | vis - > choice
Use the vis-open(1) based file browser to list all C language source files:
:e *.c
Spawn background process and pipe range to its standard input:
:> { plumber <&3
3<&- & } 3<&0 1>&- 2>&-
sam(1), vi(1), vis-clipboard(1), vis-complete(1), vis-digraph(1), vis-menu(1), vis-open(1)
A Tutorial for the Sam Command Language by Rob Pike
The Text Editor sam by Rob Pike
Structural Regular Expressions by Rob Pike
vi - screen-oriented (visual) display editor IEEE Std 1003.1 (“POSIX.1”)
vis
does not strive to be
IEEE Std 1003.1 (“POSIX.1”)
compatible, but shares obvious similarities with the
vi
utility.
vis
is written by Marc
André Tanner ⟨mat at brain-dump.org⟩
On some systems there already exists a vis
binary, thus causing a name conflict.
January 14, 2017 | Vis 0.9 |