logo

tested on openbsd 7.8

vi(1)

to use macros:

to edit multiple files: vi file1 file2, then :n[ext], :prev to switch, and :ar[gs] to list them all, then to alternate between two buffers press ^^ (ctrl + shift + 6) or use :e# command.

to open one more file :e[dit] file.

to open in a split :E[dit] file, then ^w to switch between windows, and to set the window height to 20 lines :res[ize] 20.

to scroll current line to the top z<enter>, to the center z., and to the bottom of screen z-. scroll lines with ^y and ^e as usual.

to search for the "expression" and place the next occurrence of it to the center of screen: /expression/z..

to undo and redo: press u to undo previous edit, then press . (dot) to undo, to redo press u again.

to increment a number: place cursor at the first digit and press ## or #+, to decrement press #-.

to redraw the screen press ^l.

to mark a line press mm, move to another line, then to delete from the current to the marked line with d'm, or to yank y'm.

to break lines at column 72 in insert and append modes:

:set wraplen=72

to format a paragraph with goal line length 72, allow indented paragraphs:

:?^$?,//!fmt -pw 72

sort lines in a paragraph (in command mode):

!}sort

to remove trailing spaces:

:%s/[[:space:]]\{1,\}/

to edit command-history:

:set cedit=\

(to get <tab> press ^v then tab)

to read help:

:help

to edit unicode install nvi2:

# pkg_add nvi--iconv
quirks-7.147 signed on 2026-03-08T15:26:56Z
nvi-2.2.1-iconv: ok
#

see also