-
Notifications
You must be signed in to change notification settings - Fork 19
A small vi/ex terminal text editor (neatvi rewrite)
License
Notifications
You must be signed in to change notification settings
kyx0r/nextvi
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Latest commit | ||||
Repository files navigation
Nextvi(1) General Commands Manual Nextvi(1)
NAME
Nextvi - A small vi/ex terminal text editor
SYNOPSIS
vi [-emsv] [file ...]
DESCRIPTION
Nextvi is a modern clone of the command-line text editor vi(1),
initially developed by Bill Joy in 1976 for Unix-based systems.
Nextvi builds upon many standard features from vi(1) including
unique modal interface that allows users to switch between normal,
insert, and command modes, for efficient text manipulation.
Additional enhancements include an unrestricted macro system,
syntax highlighting, keymaps, bidirectional UTF-8 support, and
numerous other features. Nextvi remains highly efficient, portable,
and hackable, ensuring its continued relevance and high quality
for years to come.
OPTIONS
-e Enter Ex mode on startup
-m Disable initial file read message
-s Enter raw Ex mode on startup
-v Enter visual mode on startup (Default)
MANPAGE NOTATION
<x> A closure where x represents character literal
[x] A closure where x represents optional argument
{x} A closure where x represents required argument
"x" A closure where x represents a string
<^X> Represents a ctrl key X
# Represents a positive number in a closure
* Represents any character(s) in a closure
< > Separates alternatives in a closure
x-y Range from x to y
VI NORMAL
[#]j Move # lines down
[#]k Move # lines up
[#]+
[#]<^M>
[#]<Enter>
Move # lines down, cursor after indent
[#]- Move # lines up, cursor after indent
[#]h Move # columns left
[#]l Move # columns right
[#]f{arg} Move to arg character found forward # times
[#]F{arg} Move to arg character found backward # times
[#]t{arg} Move until arg character found forward # times
[#]T{arg} Move until arg character found backward # times
[#], Repeat last <f F t T> move backward # times
[#]; Repeat last <f F t T> move forward # times
[#]E Move to end of word # times, skip punctuation
[#]e Move to end of word # times
[#]B Move to start of word backward # times, skip punctuation
[#]b Move to start of word backward # times
[#]W Move to start of word forward # times, skip punctuation
[#]w Move to start of word forward # times
vw Toggle line only mode for <E e B b W w>
[#]( Move to next sentence boundary down # times
[#]) Move to next sentence boundary up # times
[#]{ Move to next <{> section down # times
[#]} Move to next <{> section up # times
[#][ Move to next <Newline> section down # times
[#]] Move to next <Newline> section up # times
^ Move to start of line after indent
0 Move to start of line
$ Move to end of line
[#]| Goto # col
[#]<Space> Move # characters forward, multiline
[#]<^H>
[#]<Backspace>
Move # characters backward, multiline
% Move to closest <] ) }><[ ( {> pair
{#}% Move to # percent line number
'{a-z ` ' [] *}
Move to a line mark
`{a-z ` ' [] *}
Move to a line mark with cursor position
gg Goto first line in buffer
[#]G Move to last line in buffer or # line
H Move to highest line on a screen
L Move to lowest line on a screen
M Move to middle line on a screen
z. Center screen at cursor
z<^M>
z<Enter>
Center screen at top row
z- Center screen at bottom row
[#]<^E> Scroll down 1 or # lines, retain # and cursor position
[#]<^Y> Scroll up 1 or # lines, retain # and cursor position
[#]<^D> Scroll down half a screen size. If [#], set scroll to #
lines
[#]<^U> Scroll up half a screen size. If [#], set scroll to # lines
<^B> Scroll up full screen size
<^F> Scroll down full screen size
# Show global and relative line numbers
2# Toggle show global line numbers permanently
4# Toggle show relative line numbers after indent permanently
8# Toggle show relative line numbers permanently
V Toggle show hidden characters:<Space Tab Newline>
<^C> Toggle show line motion numbers for <l h e b E B w W>
{1-5}<^C> Switch to line motion number mode #
<^V> Loop through line motion number modes
[#]<^R> Redo # times
[#]u Undo # times
<^I>
<Tab>
Open file path from cursor to end of line
<^K> Write current buffer to file. Force write on 2nd attempt
[#]<^W>{arg} Unindent arg region # times
[#]<{arg} Indent left arg region # times
[#]>{arg} Indent right arg region # times
"{arg}{arg1} Operate on arg register according to arg1 motion
R Print registers and their contents
[#]&{arg} Execute arg register macro in non-blocking mode # times
[#]@{arg} Execute arg register macro in blocking mode # times
[#]@@
[#]&&
Execute a last executed register macro # times
[#]. Repeat last normal command # times
[#]v. Repeat last normal command moving down across # lines
[#]Q Enter ex mode. # retains current character offset
: Enter ex prompt
[#]!{arg} Enter pipe ex prompt based on # or arg region
vv Enter ex prompt with the last line from history buffer b-1
[#]vr Enter %s/ ex prompt. Insert # words from cursor
[#]vt[#arg] Enter .,.+0s/ ex prompt. Insert # of lines from cursor.
Insert #arg words from cursor
[#]v/ Enter xkwd ex prompt to set search keyword. Insert # words
from cursor
v; Enter ! ex prompt
[#]vi Enter %s/ ex prompt. Contains regex for changing spaces to
tabs. # modifies tab width
[#]vI Enter %s/ ex prompt. Contains regex for changing tabs to
spaces. # modifies tab width
vo Remove trailing white spaces and <\r> line endings
<^G> Print buffer status infos
1<^G> Enable permanent status bar row
2<^G> Disable permanent status bar row
ga Print character info
1ga Enable permanent character info bar row
2ga Disable permanent character info bar row
[#]gw Hard word wrap a line to # col limit. Default: 80
[#]gq Hard word wrap a buffer to # col limit. Default: 80
[#]g~{arg} Switch character case for arg region # times
[#]gu{arg} Switch arg region to lowercase # times
[#]gU{arg} Switch arg region to uppercase # times
[#]~ Switch character case # times forward
i Enter insert mode
I Enter insert mode at start of line after indent
A Enter insert mode at end of line
a Enter insert mode 1 character forward
[#]s Enter insert mode and delete # characters
S Enter insert mode and delete all characters
o Enter insert mode and create a new line down
O Enter insert mode and create a new line up
[#]c{arg} Enter insert mode and delete arg region # times
C Enter insert mode and delete from cursor to end of line
[#]d{arg} Delete arg region # times
D Delete from cursor to end of line
[#]x Delete # characters from cursor forward
[#]X Delete # characters from cursor backward
di{arg} Delete inside arg pairs <( ) ">
ci{arg} Change inside arg pairs <( ) ">
[#]r{arg} Replace # characters with arg from cursor forward
[#]K Split a line # times
[#]J Join # lines
vj Toggle space padding when joining lines
[#]y{arg} Yank arg region # times
[#]Y Yank # lines
[#]p Paste default register # times
[#]P Paste default register below current line or behind cursor
position # times
m{a-z ` ' [] *}
Set buffer local line mark
<^T> Set global line mark 0. Global marks are always valid
{0 2 4 6 8}<^T>
Set a global line mark #
{1 3 5 7 9}<^T>
Switch to a global line mark #
[#]<^7>{0-9}
[#]<^_>{0-9}
[#]<^/>{0-9}
Show buffer list and switch based on # or 0-9 index when
prompted
<^^>
<^6>
Swap to previous buffer
[#]<^N> Swap to next buffer, # changes direction [forward backward]
\ Swap to /fm/ buffer b-2
{#}\ Swap from /fm/ buffer b-2 and backfill directory listing
vb Recurse into b-1 history buffer. Insert current line into
ex prompt on exit
z1 Set alternative keymap to Farsi keymap
z2 Set alternative keymap to Russian keymap
ze Switch to English keymap
zf Switch to alternative keymap
zL Set td ex option to 2
zl Set td ex option to 1
zr Set td ex option to -1
zR Set td ex option to -2
[#]/ Regex search, move down 1 or # matches
[#]? Regex search, move up 1 or # matches
[#]n
[#]N
Repeat regex search, move [down up] 1 or # matches
<^A> Regex search 1 word from cursor, no center, wraparound move
[up down]
* Regex search, no center, wraparound move [up down]
{#}*
{#}<^A> Regex search, set keyword to # words from cursor
<^]> Filesystem regex search forward based on directory listing
in b-2. Sets global line mark 0 for <^P> fallback
{#}<^]> Filesystem regex search forward, set keyword to # words
from cursor
[#]<^P> Filesystem regex search backward
<^Z> Suspend vi
<^L> Force redraw whole screen and update terminal dimensions
Z{*} Exit and clean terminal, force quit in an & macro
Zz Exit and submit history command, force quit in an & macro
ZZ Exit and write unsaved changes to a file
VI REGIONS
Regions are vi normal commands that define [h v]range for vi motions.
Commands described with the word "move" define a region.
j + <^M> <Enter> - k h l f F t T , ; B E b e W w ( ) { } [ ] ^ 0 $
<Space> <^H> <Backspace> % ' ` G H L M / ? n N <^A>
All regions
VI MOTIONS
Motions are vi normal commands that run in a [h v]range.
Commands described with the word "region" consume a region.
Motions can be prefixed or suffixed by [#].
<^W> > < ! c d y " g~ gu gU
All motions
" Special motions that consume a motion
dd yy cc g~~ guu gUU >> << <^W><^W> !!
Special motions that can use [#] as number of lines
Examples:
3d/int Delete text until 3rd instance of "int" keyword
3dw Delete 3 words (prefix [#])
d3w Delete 3 words (suffix [#])
"ayl Yank a character into <a> register
"Ayw Append a word to <a> register
VI/EX INSERT
<^H>
<Backspace>
Delete a character, reset ex mode when empty
<^U> Delete util <^X> mark or everything
<^W> Delete a word
<^T> Increase indent
<^D> Decrease indent
<^]> Select paste register from 0-9 registers in a loop
<^\>{arg} Select paste register arg. <^\> selects default register
<^P> Paste a register
<^X> Mark autocomplete and <^U> starting position. <^X> resets
the mark
<^G> Index current buffer for autocomplete
<^Y> Reset all indexed autocomplete data
<^R> Loop through autocomplete options backward
<^N> Loop through autocomplete options forward
<^B> Print autocomplete options when in vi insert
<^B> Recurse into b-1 history buffer when in ex prompt. Insert
current line into ex prompt on exit
<^A> Loop through lines in a history buffer b-1
<^Z> Suspend vi/ex
<^L> Redraw screen in vi mode, clean terminal in ex
<^O> Switch between vi and ex modes recursively
<^E> Switch to english keymap
<^F> Switch to alternative keymap
<^V>{arg} Read a literal character arg
<^K>{arg} Read a digraph sequence arg
<^C>
<ESC>
Exit insert mode in vi, reset in ex
<^M>
<Enter>
Insert <Newline> in vi, submit command in ex
EX
Ex is a powerful line editor for Unix systems, initially developed
by Bill Joy in 1976. This essential tool serves as the backbone
of vi, enabling it to execute commands, macros and even transform
into a purely command-line interface (CLI) when desired.
EX PARSING
Parsing follows the structure:
[<sep>][range][pad][cmd][<pad>][args]
Ex commands are initiated and separated by <:> prefix. Fields
can be padded by <Space> or <Tab>. There can only be one pad
in between [cmd] and [args]. To avoid ambiguity in scripts, it
is recommended to always use a pad between [cmd] and [args].
Examples:
:evi.c
Evaluates to ":e vi.c"
:eabc
Evaluates to ":ea bc" not ":e abc"
:e vi.c
Edit " vi.c". <pad> is required
EX ESCAPES
Special characters in [args] will become regular when escaped
with <\>.
( ^ ] -
Specials in regex "[]" expression
( ) { } + * ? ^ $ [ ] | \ . \< \>
Specials in regex
% ! : Specials in ex
EX EXPANSION
<%> in [args] substitutes current buffer pathname or any buffer
pathname when followed by a corresponding buffer number.
"%#" substitutes last swapped buffer pathname.
Example: print pathname for buffer 69
:!echo "%69"
Every ex command is be able to receive stdout from an external
program via a special expansion character <!>.
If closing <!> was not specified, the end of the line becomes
a terminator.
Example: substitute "int" with the value of $RANDOM
:%s/int/!printf "%s" $RANDOM!
Example: insert output of ls shell command
:& i!ls
Example: insert output of ls more efficiently
:;c !ls!<^V><ESC>
EX RANGES
Some ex commands can be prefixed with ranges.
[range] implements vertical and horizontal ranges.
[vrange] implements vertical range and horizontal position.
[pad][%][, ;][pad][. $ ' > <][- + * / %][0-9]
All ranges structure
{> <}[kwd][> <]
Search range structure
'{<mark>}
Mark range structure
pad <Space> or <Tab>
% Range from first to last line
, Vertical range separator
; Horizontal range separator
. Current position
$ Last line of a buffer or end of line
' Begin mark range
> Begin search range forward
< Begin search range backward
- Subtract following number
+ Add following number
* Multiply by the following number
/ Divide by the following number
% Modulo by the following number
0-9 Number or position
Examples:
:1,5p Print lines 1,5
:.-5,.+5p
Print 5 lines around current position
:>int>p
Print first occurrence of "int"
:<int<p
Print first occurrence of "int" in reverse
:.,>int>p
Print until "int" is found
:<int<,.p
Print until "int" is found in reverse
:> Search using previously set search keyword
:'d,'ap
Print lines from mark <d> to mark <a>
:%p Print all lines in a buffer
:$p Print last line in a buffer
:$*50/100+1
Goto 50% of the file
:;50 Goto character offset 50
:10;50 Goto line 10 character offset 50
:10;.+5
Goto line 10 +5 character offset
:'a;'a Goto line mark <a> offset mark <a>
:;$ Goto end of line
:5;>int>
Search for "int" on line 5
:.;<int<
Search for "int" in reverse on the current line
:;>int>+3;>>p
Print text enclosed by "int" on the current line
EX COMMANDS
[vrange]f{> <}[kwd]
Ranged search
Example: no range given, current line only
:f>int
Example: reverse
:f<int
Example: range given
:10,100f>int
[vrange]f+{> <}[kwd]
Incrementing ranged search
Equivalent to the :f command, except subsequent commands within
range move to the next match just like vi normal [#]n or [#]N
commands.
b[#] Print buffers or switch to a buffer
There are two temporary buffers which are separate from
the main buffers.
b-1 = /hist/ ex history buffer
b-2 = /fm/ directory listing buffer
Example: switch to the 5th buffer
:b5
Example: switch to the b-1 buffer
:b-1
Example: switch to the b-2 buffer
:b-2
bp[path]
Set current buffer path
bs[*] Set current buffer saved
Argument resets undo/redo history
[range]p
Print line(s) from a buffer
Example: utilize character offset ranges
:1,10;5;5p
Example: interleaved character offset ranges
:1;5,10;5p
Example: print current line from offset 5 to 10
:.;5;10p
[#]ea[kwd]
Open file based on filename substring
Requires directory listing in b-2 backfilled prior.
Example: backfill b-2 using :fd
:fd
Example: backfill b-2 using find
:b-2:%!find .
If kwd matches more than one filename, a list of matches
and a fuzzy find prompt will be shown. If the number of matches
is less than 10, match can be picked using numbers 0-9.
<^C> or <ESC> to abort.
<^M> or <Enter> to input a number larger than 9.
Prefix is a number selected ahead of time.
Example: print entire listing
:ea
Example: open filename containing "v"
:ea v
Example: open path at index 15
:15ea
[#]ea![kwd]
Forced version of ea
[vrange]i[str]
Enter ex insert mode before specified position
str specifies initial input into the insertion buffer.
Example: insert "hello" in vi/ex
:i hello<^M><ESC>
Example: insert "hello" in vi/ex trimming <Newline>
:i hello<^M><^M><Backspace>
Example: discard changes in vi/ex
:i hello<^M><^C>
Example: immediately insert "hello"
:i hello<^V><ESC>
Example: insert "hello" in raw ex mode
i hello<^M>.<^M>
[vrange]a[str]
Enter ex insert mode after specified position
[range]c[str]
Enter ex change mode
In combination with seq and lim ex options, this command is
optimal for modifying very long lines.
Max insertion buffer is ~1.33GB on a 32 bit build.
Max addressable line is 2.0GB on a 32 bit build.
Example: replace current line with "hello"
:c hello<^M><ESC>
Example: replace lines 1-5 with "hello"
:1,5c hello<^M><ESC>
Example: insert "hello" at current character offset
:;c hello<^M><ESC>
Example: insert "hello" at end of line
:;$c hello<^M><ESC>
Example: insert "hello" at line 5 and end of line
:5;$c hello<^M><ESC>
Example: delete 5 characters from current position
:;.;+5c<^M><ESC>
[vrange]d
Delete line(s)
e[path]
Open a file at a path
No argument opens "unnamed" buffer.
Files larger than 2.0GB are truncated on a 32 bit build.
Line breaking happens until the first null terminator or EOF.
e![path]
Force open a file at a path
No argument re-reads the current buffer from the filesystem.
[vrange]g{<*>}[kwd]{<*>}{cmd}
Global command
Execute an ex command on a range of lines that matches an
enclosed regex.
No range evaluates to % range or . range when nested.
Example: remove all empty lines
:g/^$/d
Example: print lines matching previously set search keyword
:g//p
Multiple ex commands can be chained in one global command.
To chain commands, the ex separator <:> must be escaped once.
Example: print and append lines matching "int" to register <a>
:g/int/p\:ya A
It is possible to nest global commands inside of global commands.
The first global command will not be executed on lines that
were changed by a nested global command.
Example: nested global command
Append "has a semicolon" to all lines that contain "int" and
end with <;>.
:g/int/g/;$/& A has a semicolon
Example: extract/print data enclosed in "()"
:g/\(.+\)/;0;>\(.+\)>\:.;.+1k a\:grp 2\:;>\)*(\))>\:
grp\:k s\:.;'a;'sp
[vrange]g!{<*>}[kwd]{<*>}{cmd}
Inverted global command
[range]=[<0-3 *>][*]
Print range numbers
Argument 0-3 selects a specific number.
Any or any extra argument circumvents buffer range check.
No argument prints all range numbers.
Example: print current character offset only
:;= 2
Example: print value of mark <a>
:'a=
Example: calculate 75 - 100
:1,75-100=1p
[vrange]k{<mark>}
Set a line mark
Valid marks: <a-z> <`> <'> <[> <]> <*>
The character offset is set to the current position.
&{macro}
Global non-blocking macro
Execute raw vi/ex input sequence.
A non-blocking macro shall not wait for input when the end of
the sequence is reached. A non-blocking macro executing other
macros will always reach a terminating point.
Example: execute vi insert statement
:& ihello
Example: execute :hello
:& \:hello<^V><^M>
Example: execute vi "ci(int" macro
:& ci(int
Example: nest blocking macro inside non-blocking
:& \:@ \\:blocking<^V><^M>i continue in non-blocking
Example: enable permanent vi line numbers
:& 2#
@{macro}
Global blocking macro
Execute raw vi/ex input sequence.
A blocking macro shall wait for input when the end of the sequence
is reached. A blocking macro executing other macros may cause
input congestion.
Example: execute vi insert statement
:@ ihello
Example: insert "hello" into <:> vi prompt
:@ \:hello
Example: execute vi "ci(int" macro
:@ ci(int
Example: execute "ci(int" exiting insert mode
:@ ci(int<^V><^C>
Example: execute "ci)INT" as a follow-up
:@ ci(int<^V><^C>ci)INT
Example: execute vi "dw" command after user exits insert
:@i:@dw
[#0 <$>][,{#1 <$>}][,{#2 <$>}]?{cmd}
While loop conditional
Repeat cmd #0 times or infinite with <$>.
While loop is broken once cmd returns an error or count exceeded.
If while fails with error, #1 and #2 specify a range of the separated
ex commands to skip that follow next in chain.
No prefix creates a conditional with all # parameters set to 1.
Example: attempt to join every line in file using arbitrary count
:10000? & J
Example: undo everything
:$? u
Example: repeat chain of ex commands 10 times
:10? 1p\:5p\:10p
Example: calculate directory only if :cd succeeded
:? cd /blah:fd
Example: print a line only if it contains "int" at offset 5
:? ;5;>^int>:p
Example: allow :led while branching only :p command
:led:1,2? ;5;>^int>:led:p
Example: branch multiple commands
:led:1,2,3? ;5;>^int>:led:&i2 not branched:p:p
Example: edit vi.c only if it exists
:? \![ -f ./vi.c ]:e ./vi.c:mpt
[range]pu[<reg>][*][\!{cmd}]
Paste or pipe a register
Example: paste <a> at line 1 character offset 5
:1;5pu a
Example: copy default register to X11 clipboard
:pu \!xclip -selection clipboard
Example: copy register <a> to X11 clipboard
:pu a \!xclip -selection clipboard
[range]r[path]
[range]r\![cmd]
Read a file or a pipe
Range is computed on a target.
No range evaluates to % range.
No argument evaluates to current buffer path.
Example: read a file
:r vi.c
Example: pipe in all data
:r \!ls
Example: pipe in only lines 3,5
:3,5r \!ls
[range]w[path]
[range]w\![cmd]
Write a file or a pipe
No range evaluates to % range.
No argument evaluates to current buffer path.
Example: write a file
:w vi.c
Example: pipe out all data into less
:w \!less
Example: pipe out only first 10 lines
:1,10w \!less
[range]w![path]
Force write to a file
q Exit
q! Force quit
wq
x
Write and exit
wq!
x!
Force write and quit
u Undo
rd Redo
[vrange]s{<*>}[kwd]{<*>}{str}[<*>][<g>]
Substitute
Find and replace text in a range of lines that matches an
enclosed regex with an enclosed replacement string.
Example: global replacement
:%s/term1/term2/g
Example: replace matching previously set search keyword
:%s//term2/g
Substitution backreference inserts the text of matched group
specified by \x where x is group number.
Example: substitution backreference
this is an example text for subs and has int or void
:%s/(int)|(void)/pre0円after
this is an example text for subs and has preintafter or void
:%s/(int)|(void)/pre2円after/g
this is an example text for subs and has prepreafterafter or prevoidafter
[range]ya[<reg>][*]
Yank a range
Register value range is 1-255.
Any extra argument appends to the register.
Example: append to register <1>
:ya 1x
Example: yank into <a> using ranges
:1,5;5;5ya a
ya![<reg>]
Free a register
[range]![cmd]
Run an external program
When a range is specified, the buffer's data is piped to an external
program. The resulting stdout is then piped back into the buffer,
replacing the contents of the original range.
Example: infamously sort a buffer
:%!sort
Example: use sed to replace "int" with "uint"
:%!sed -e 's/int/uint/g'
Example: pipe in result of ls command without replace
:;$+1!ls
Example: capitalize word at current position using tr
:;.;>\\>>!tr '[\:lower\:]' '[\:upper\:]'
ft[filetype]
Set a filetype
No argument prints the current file type.
Reloads the highlight ft, which makes it possible to reset dynamic
highlights created by options like "hlw".
cm[keymap]
Set a keymap
No argument prints the current keymap name.
cm![keymap]
Set an alternative keymap
fd[path]
Set a secondary directory
Recalculates directory listing in b-2 buffer.
No argument implies current directory.
fp[path]
Set a directory path for :fd command
cd[path]
Set a working directory
Currently open buffers' file paths will be automatically adjusted
to reflect a newly set working directory.
inc[regex]
Include regex for :fd calculation
No argument disables the filter.
Example: include only files in submodule directory that end with .c
:inc submodule.*\.c$
Example: exclude .git and submodule folders
:inc (^(?\:(?\!^\.git|^submodule).)+[^/]+$)
reg Print registers and their contents
bx[#] Set max number of buffers allowed
Buffers will be deallocated if the number specified is lower
than the number of buffers currently in use.
No argument will reset to the default value of 10.
ac[regex]
Set autocomplete filter regex
No argument resets to the default word filter regex as defined
in led.c.
Example: autocomplete using whole lines from a buffer
:ac .+
uc Toggle multibyte utf-8 decoding
This command is particularly useful when editing files with
mixed encodings, binary files, or when the terminal does not
support UTF-8 or lacks the necessary fonts to display UTF-8
characters. It's often paired with :ph command to achieve
hex editor-like functionality.
uz Toggle zero width placeholders
Use only if you need to hide zero width characters.
ub Toggle combining multicodepoint placeholders
Use only if your terminal can render multicodepoint utf-8 (emojis).
ph[#clow] [#chigh] [#width] [#blen][*char]
Redefine placeholders
This command replaces placeholders defined in conf.c
and subsequent :ph commands expand the list of placeholders.
Example: render 8 bit ascii (Extended ASCII) as <~>
:ph 128 255 1 1~
Example: flawless ISO/IEC 8859-1 (latin-1) support
:uc:ph 128 160 1 1~
Example: render control byte 03 as "^C"
:ph 3 3 2 1^C
Example: reset to default as in conf.c
:ph
Example: disable default placeholders in conf.c
:ph:ph0
EX OPTIONS
Ex options are ex commands designed to alter global variables.
Values hold a signed integer. Values may represent a character.
Default value is specified in val=* as part of an argument notation.
No argument inverts the current value, unless stated otherwise.
ai[val=1]
Indent new lines
This is a max indent length multiplier: val * 128
ic[val=1]
Ignore case in regular expressions
ish[val=0]
Interactive shell
Run every <!> command through an interactive shell.
The shell will source the .rc file before command execution.
This makes it possible to use predefined functions, aliases
and ENV variables from the .rc file.
Precondition 1:
The .rc filename is shell specific, such as .bashrc in Bash
and .zshrc in Zsh.
Precondition 2:
The environment variable $SHELL determines the default
shell, otherwise it defaults to /bin/sh.
Precondition 3:
There must be no stdout output created by .rc file
for <!> commands to return expected results.
grp[val=0]
Regex search group
Defines a target search group for any regex search operation.
This becomes necessary when the result of regex search is to
be based on some group rather than default match group.
The value of grp must be divisible by 2.
Example: ignore spaces at the start of the line
:grp 2:%f+>^[ ]+(.+):grp
hl[val=1]
Highlight text based on rules defined in conf.c
hlr[val=0]
Highlight text in reverse direction
hll[val=0]
Highlight current line based on filetype hl
hlp[val=0]
Highlight "[]" "()" "{}" pairs based on filetype hl
hlw[val=0]
Highlight current word based on filetype hl
led[val=1]
Enable all terminal output
vis[val=0]
Control startup flags
Example: disable :e message in ex mode
:vis 12
Example: disable :e message in vi mode
:vis 8
Example: enable raw ex mode
:vis 6
Example: disable raw ex mode
:vis 4
mpt[val=0]
Control vi prompts
When set to 0 after an ex command is called from vi, disables
the "[any key to continue]" prompt.
If mpt is negative, the prompt will remain disabled.
order[val=1]
Reorder characters based on rules defined in conf.c
shape[val=1]
Perform Arabic script letter shaping
pac[val=0]
Print autocomplete suggestions on the fly
tbs[val=8]
Number of spaces used to represent a tab
td[val=1]
Current text direction context
This option accepts four meaningful values:
2 Exclusively left-to-right
1 Follow dctxs[] (in conf.c), defaulting to left-to-right
-1 Follow dctxs[], defaulting to right-to-left
-2 Exclusively right-to-left
pr[val=0]
Print register
Set a special register using a character or a number.
Once the register is set, all data passed into ex_print will
be stored in the register.
If the register is uppercase, <Newline> characters are added
to match the exact output that was printed.
Print register contents cannot be displayed with R or :reg command
when register is assigned (self-referential problem).
Example: paste current buffer list exactly like from :b command
:pr A:ya! A: b:pu A
Example: store a line printed with :p
:pr A:ya! A:p
sep[val=:]
Ex separator
Set Ex command separator character.
Changing default <:> separator will break some built-in commands/macros.
Example: set separator to <|>
:sep |
Example: disable separator
:sep 0
lim[val=-1]
Line length render limit
Set render cutoff length for non cursor lines in vi and all
lines in ex mode.
Improves redraw performance when editing a file containing one
or many long lines (1MB+ per line).
Example: reasonable value
:lim 5000
Example: render only the cursor line
:lim 0
Example: disable the limit
:lim -1
seq[val=1]
Control Undo/Redo
When seq is 0, multiple distinct operations undo/redo in a
single step.
To optimize memory usage under heavy workloads, undo/redo
tracking can be disabled by setting seq to a negative value.
Example: test undo/redo operations in a single step
:&ocontrol test:seq 0:&a step1:&a step2:&a step3:seq
Example: completely disable undo/redo
:seq -1
[hscroll]left[val=0]
Control horizontal scroll
No argument sets the value to 0.
hscroll computes the value using: xcols / 2 * hscroll
EXINIT ENV VAR
EXINIT defines a sequence of vi/ex commands to be performed
at startup. Consequently, this is the primary way for scripting
and customizing Nextvi outside of C.
Many standard text processing utils such as grep, awk, sed
can be replaced by Nextvi with EXINIT in mind.
Examples:
export EXINIT="$(printf '%b' 'e ./vi.c:& i\x7\x3:bx 1:bx')"
Index vi.c for autocomplete
export EXINIT='b-1:r ./vi.c:b-1'
Load vi.c into a history buffer
export EXINIT="$(printf '%b' 'e:& io{\n}\x16\x3kA\x3:& 1G:& 2"aY')"
Setup @ macro in register <a>
@a macro creates <{> and closing <}> below the cursor leaving
cursor in insert mode in between the braces.
export EXINIT='td 2:order 0:lim 5000'
Set ex options for optimal long line performance
REGEX
Pikevm is a fast non backtracking NFA simulation regex engine
developed for Nextvi. It ensures regular expressions are evaluated
in constant space and O(n + k) time complexity where <n> is
the input string length and <k> represents the regex's structural
complexity (e.g., state transitions or alternations). While
this does not guarantee strict O(n) linear runtime performance,
it ensures computational and memory resources are distributed
linearly and evenly across the input, with <k> directly influencing
the constant factor. This principle is similar to the concept
utilized in radix sort algorithms.
Pikevm's syntax is akin to regexp(7) from Plan 9.
Disregard manpage notation in this section.
. Match any single char
[N-M] Match a set of alternate ranges N to M
{N,M} Match N to M times
() Grouping
(?:) Non capture grouping
* Repeated zero or more times
+ Repeated one or more times
| Union, alternative branch
? One or zero matches greedy
?? One or zero matches lazy
^ Assert start of line
$ Assert end of line
\< Assert start of word
\> Assert end of word
(?=) Assert positive lookahead
(?!) Assert negative lookahead
(?>) Assert positive lookbehind
(?<) Assert negative lookbehind
(?#) Lookbehind offset in bytes
Lookaround expressions enable the creation of regular expressions
that would be impossible to construct without them. They can
be used anywhere within a regex, though some considerations
must be taken into account.
Aspect 1:
Lookarounds contain a full regex, but should use non-capturing
groups to avoid incorrect results and performance issues.
Aspect 2:
Lookarounds can have nested lookarounds.
Aspect 3:
Static lookarounds like (?=^word) are optimized, bypassing
the regex engine.
Aspect 4:
Lookarounds are best suited for asserting near the end of a
complex pattern, where the engine has already narrowed down
potential matches.
Aspect 5:
Lookbehind without offset rescans entire string. Offset begins
scanning from current position minus specified value.
SPECIAL MARKS
* Position of previous ex command
[ First line of previous change
] Last line of previous change
' Position of previous line region
` Position of previous line region
SPECIAL REGISTERS
/ Previous search keyword
: Previous ex command
0 Previous value of default register (atomic)
Atomic means the operation did not include a <Newline>.
1-9 Previous value(s) of default register (nonatomic)
CODE MAP
+--------------+----------------------+
| 521 vi.h | definitions/aux |
| 537 kmap.h | keymap translation |
+--------------+----------------------+
| 307 conf.c | hl/ft/td config |
| 345 term.c | low level IO |
| 413 ren.c | positioning/syntax |
| 578 lbuf.c | file/line buffer |
| 613 uc.c | UTF-8 support |
| 683 led.c | insert mode/output |
| 731 regex.c | pikevm |
| 1435 ex.c | ex options/commands |
| 1864 vi.c | normal mode/general |
| 6969 total | wc -l *.c|sort |
+--------------+----------------------+
COMPILING
export CC='g++ -x c'
Set compiler, g++ example
export CFLAGS='-s'
Set CFLAGS, strip example
./cbuild.sh
Build once
./cbuild.sh build
Build
./cbuild.sh debug
Build with symbols, static analysis, dynamic analysis, and no
optimizations
./cbuild.sh pgobuild
PGO build can lead to a significant performance boost on some
application specific tasks
./cbuild.sh install
Install vi to $DESTDIR$PREFIX/bin
./cbuild.sh fetch
Merge commits from upstream repository
./cbuild.sh bench
Performance bench test 2000 word deletions on vi.c
PHILOSOPHY
In most text editors, flexibility is a minor or irrelevant design
goal. Nextvi is designed to be flexible where the editor adapts
to the user needs. This flexibility is achieved by heavily chaining
basic commands and allowing them to create new ones with completely
different functionality. Command reuse keeps the editor small
without infringing on your freedom to quickly get a good grasp
on the code. If you want to customize anything, you should be
able to do it using only core commands or a mix with some specific
C code for more difficult tasks. Simple and flexible design
allows for straight forward solutions to any problem long term
and filters bad inconsistent ideas.
"All software sucks, but some do more than others."
- Kyryl Melekhin
SEE ALSO
New functionality can be obtained through optional patches provided
in the patches branch. If you have a meaningful contribution
and would love to be made public the patch can be submitted
via email or github pull request.
https://github.com/kyx0r/nextvi/tree/patches
Scripts used to generate this manual are located in the manual
branch.
https://github.com/kyx0r/nextvi/tree/manual
Original Neatvi repository
https://github.com/aligrudi/neatvi
Posix vi(1)
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html
Posix ex(1)
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html
NFA regular expressions by Russ Cox
https://swtch.com/~rsc/regexp/regexp1.html
Plan 9 regexp(7)
https://man.cat-v.org/p9p/7/regexp
AUTHORS
Nextvi was written by Kyryl Melekhin <k.melekhin@gmail.com>. It is based
on neatvi(1), which was written by Ali Gholami Rudi <ali@rudi.ir>. This
manual page was inspired by nepeta <nepeta@canaglie.net>
Linux 6.17.1 October 21, 2025 Linux 6.17.1
About
A small vi/ex terminal text editor (neatvi rewrite)
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published