VI(1)

๐Ÿ“ฆ
version 1.81.6 ยท 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

okay bestie, gather round ๐Ÿ’– this is VI(1), straight outta the General Commands Manual, and we're about to make a screen editor make sense. no cap, this page is iconic for a reason.


๐ŸŒธ NAME ๐ŸŒธ

ex, vi, view โ€” text editors. that's the whole vibe. three names, one legendary program ๐Ÿ’…


โœจ SYNOPSIS โœจ

ex [-eRrSsv] [-c cmd] [-t tag] [-w size] [file ...]
vi [-elRrSv] [-c cmd] [-t tag] [-w size] [file ...]
view [-eRrSv] [-c cmd] [-t tag] [-w size] [file ...]

๐ŸŽ€ LICENSE ๐ŸŽ€

The vi program is freely redistributable, bestie. You are welcome to copy, modify and share it with others under the conditions listed in the LICENSE file. And listen โ€” if any company (not individual! ๐Ÿ‘€ companies stay in their lane) finds vi sufficiently useful that you would have purchased it, or if any company wishes to redistribute it, contributions to the authors would be appreciated. it's giving "tip your server" energy fr fr ๐Ÿซถ


๐Ÿ’– DESCRIPTION ๐Ÿ’–

Vi is a screen oriented text editor. Ex is a lineโ€oriented text editor. Ex and vi are different interfaces to the same program, and it is possible to switch back and forth during an edit session. View is the equivalent of using the -R (readโ€only) option of vi. so yeah, three doors, same room ๐Ÿ”ฅ

This manual page is the one provided with the nex/nvi versions of the ex/vi text editors. Nex/nvi are intended as bugโ€forโ€bug compatible replacements for the original Fourth Berkeley Software Distribution (4BSD) ex and vi programs. For the rest of this manual page, nex/nvi is used only when it's necessary to distinguish it from the historic implementations of ex/vi. no cap, they really said "we'll copy the bugs too" ๐Ÿ˜ญ that's commitment.

This manual page is intended for users already familiar with ex/vi. Anyone else should almost certainly read a good tutorial on the editor before this manual page. If you're in an unfamiliar environment, and you absolutely have to get work done immediately, read the section after the options description, entitled โ€œFast Startupโ€. It's probably enough to get you going. (spoiler: it's right down there, keep scrolling bestie ๐Ÿ‘‡)

The following options are available:

  • -c โ€” Execute cmd immediately after starting the edit session. Particularly useful for initial positioning in the file, however cmd is not limited to positioning commands. This is the POSIX 1003.2 interface for the historic โ€œ+cmdโ€ syntax. Nex/nvi supports both the old and new syntax. glow-up of an option, honestly โœจ
  • -e โ€” Start editing in ex mode, as if the command name were ex.
  • -l โ€” Start editing with the lisp and showmatch options set.
  • -R โ€” Start editing in readโ€only mode, as if the command name was view, or the readonly option was set. hands off the file, we're just looking ๐Ÿ‘€
  • -r โ€” Recover the specified files, or, if no files are specified, list the files that could be recovered. If no recoverable files by the specified name exist, the file is edited as if the -r option had not been specified. your "omg my laptop died mid-essay" bestie ๐Ÿซถ
  • -S โ€” Run with the secure edit option set, disallowing all access to external programs. no outside friends, we're staying in tonight ๐Ÿšซ
  • -s โ€” Enter batch mode; applicable only to ex edit sessions. Batch mode is useful when running ex scripts. Prompts, informative messages and other user oriented message are turned off, and no startup files or environmental variables are read. This is the POSIX 1003.2 interface for the historic โ€œ-โ€ argument. Nex/nvi supports both the old and new syntax.
  • -t โ€” Start editing at the specified tag. (See ctags(1)). jump straight to the spot, main character entrance energy ๐Ÿ’…
  • -w โ€” Set the initial window size to the specified number of lines.
  • -v โ€” Start editing in vi mode, as if the command name was vi or view.
okay so quick tea: the -F option (which prevented ex/vi from making a full backup of the target file) has been removed and is no longer available. she's gone, don't look for her ๐Ÿ’€

Command input for ex/vi is read from the standard input. In the vi interface, it is an error if standard input is not a terminal. In the ex interface, if standard input is not a terminal, ex will read commands from it regardless, however, the session will be a batch mode session, exactly as if the -s option had been specified.

Ex/vi exits 0 on success, and greater than 0 if an error occurs.


๐ŸŒˆ FAST STARTUP ๐ŸŒˆ

This section will tell you the minimum amount that you need to do simple editing tasks using vi. If you've never used any screen editor before, you're likely to have problems even with this simple introduction. In that case you should find someone that already knows vi and have them walk you through this section. (fr fr, grab a friend, it's a two-player level ๐Ÿซถ)

Vi is a screen editor. This means that it takes up almost the entire screen, displaying part of the file on each screen line, except for the last line of the screen. The last line of the screen is used for you to give commands to vi, and for vi to give information to you. so the bottom line is literally the group chat ๐Ÿ“ฑ

The other fact that you need to understand is that vi is a modeful editor, i.e. you are either entering text or you are executing commands, and you have to be in the right mode to do one or the other. You will be in command mode when you first start editing a file. There are commands that switch you into input mode. There is only one key that takes you out of input mode, and that is the <escape> key. (Key names are written using lessโ€than and greaterโ€than signs, e.g. <escape> means the โ€œescapeโ€ key, usually labeled โ€œescโ€ on your terminal's keyboard.) If you're ever confused as to which mode you're in, keep entering the <escape> key until vi beeps at you. (Generally, vi will beep at you if you try and do something that's not allowed. It will also display error messages.) the beep is just vi saying "bestie no" ๐Ÿ˜ญ

To start editing a file, enter the command โ€œvi file_name<carriageโ€return>โ€. The command you should enter as soon as you start editing is โ€œ:set verbose showmode<carriageโ€return>โ€. This will make the editor give you verbose error messages and display the current mode at the bottom of the screen. trust, turn this on first, it's the vibe check โญ

The commands to move around the file are:

  • h โ€” Move the cursor left one character.
  • j โ€” Move the cursor down one line.
  • k โ€” Move the cursor up one line.
  • l โ€” Move the cursor right one character.
  • <cursorโ€arrows> โ€” The cursor arrow keys should work, too.
  • /text<carriageโ€return> โ€” Search for the string โ€œtextโ€ in the file, and move the cursor to its first character.

The commands to enter new text are:

  • a โ€” Append new text, after the cursor.
  • i โ€” Insert new text, before the cursor.
  • o โ€” Open a new line below the line the cursor is on, and start entering text.
  • O โ€” Open a new line above the line the cursor is on, and start entering text.
  • <escape> โ€” Once you've entered input mode using the one of the a, i, O or o commands, use <escape> to quit entering text and return to command mode. this is THE exit key, don't forget her ๐Ÿšช

The commands to copy text are:

  • yy โ€” Copy the line the cursor is on.
  • p โ€” Append the copied line after the line the cursor is on.

The commands to delete text are:

  • dd โ€” Delete the line the cursor is on.
  • x โ€” Delete the character the cursor is on.

The commands to write the file are:

  • :w<carriageโ€return> โ€” Write the file back to the file with the name that you originally used as an argument on the vi command line.
  • :w file_name<carriageโ€return> โ€” Write the file back to the file with the name โ€œfile_nameโ€.

The commands to quit editing and exit the editor are:

  • :q<carriageโ€return> โ€” Quit editing and leave vi (if you've modified the file, but not saved your changes, vi will refuse to quit). she's protective like that ๐Ÿฅบ
  • :q!<carriageโ€return> โ€” Quit, discarding any modifications that you may have made. the exclamation point is doing SO much heavy lifting here ๐Ÿ’€
One final caution. Unusual characters can take up more than one column on the screen, and long lines can take up more than a single screen line. The above commands work on โ€œphysicalโ€ characters and lines, i.e. they affect the entire line no matter how many screen lines it takes up and the entire character no matter how many screen columns it takes up.

๐Ÿ’– VI COMMANDS ๐Ÿ’–

okay so this section is literally the command mode menu of the vi editor. every entry below has a tag line thatโ€™s a usage synopsis for the command character. no cap. ๐Ÿ’…

tag line = usage synopsis for the command character, iykyk.
  • [count] <controlโ€A> โ€” search forward count times for the current word. ๐Ÿ”
  • [count] <controlโ€B> โ€” page backwards count screens. ๐Ÿ“œ
  • [count] <controlโ€D> โ€” scroll forward count lines.
  • [count] <controlโ€E> โ€” scroll forward count lines, leaving the current line and column as is, if possible.
  • [count] <controlโ€F> โ€” page forward count screens. โœจ
  • <controlโ€G> โ€” display the file information. ๐Ÿ‘€
  • <controlโ€H>, [count] h โ€” move the cursor back count characters in the current line.
  • [count] <controlโ€J>, [count] <controlโ€N>, [count] j โ€” move the cursor down count lines without changing the current column.
  • <controlโ€L>, <controlโ€R> โ€” repaint the screen. ๐ŸŽจ
  • [count] <controlโ€M>, [count] + โ€” move the cursor down count lines to the first nonblank character of that line.
  • [count] <controlโ€P>, [count] k โ€” move the cursor up count lines, without changing the current column.
  • <controlโ€T> โ€” return to the most recent tag context.
  • <controlโ€U> โ€” scroll backwards count lines.
  • <controlโ€W> โ€” switch to the next lower screen in the window, or, to the first screen if there are no lower screens in the window.
  • <controlโ€Y> โ€” scroll backwards count lines, leaving the current line and column as is, if possible.
  • <controlโ€Z> โ€” suspend the current editor session. ๐Ÿ˜ด
  • <escape> โ€” execute ex commands or cancel partial commands.
  • <controlโ€]> โ€” push a tag reference onto the tag stack.
  • <controlโ€^> โ€” switch to the most recently edited file.
  • [count] <space>, [count] l โ€” move the cursor forward count characters without changing the current line.
  • [count] ! motion shellโ€argument(s) โ€” replace text with results from a shell command. ๐Ÿš
  • [count] # #|+|- โ€” increment or decrement the cursor number.
  • [count] $ โ€” move the cursor to the end of a line.
  • % โ€” move to the matching character. itโ€™s giving matchy-matchy. ๐Ÿ’…
  • & โ€” repeat the previous substitution command on the current line.
  • '<character>, `<character> โ€” return to a context marked by the character <character>.
  • [count] ( โ€” back up count sentences.
  • [count] ) โ€” move forward count sentences.
  • [count] , โ€” reverse find character count times.
  • [count] - โ€” move to first nonblank of the previous line, count times.
  • [count] . โ€” repeat the last vi command that modified text. ngl, iconic.
  • /RE<carriageโ€return>, /RE/ [offset]<carriageโ€return>, ?RE<carriageโ€return>, ?RE? [offset]<carriageโ€return>, N, n โ€” search forward or backward for a regular expression. ๐Ÿ”Ž
  • 0 โ€” move to the first character in the current line.
  • : โ€” execute an ex command.
  • [count] ; โ€” repeat the last character find count times.
  • [count] < motion, [count] > motion โ€” shift lines left or right.
  • @ buffer โ€” execute a named buffer.
  • [count] A โ€” enter input mode, appending the text after the end of the line.
  • [count] B โ€” move backwards count bigwords.
  • [buffer] [count] C โ€” change text from the current position to the endโ€ofโ€line.
  • [buffer] D โ€” delete text from the current position to the endโ€ofโ€line.
  • [count] E โ€” move forward count endโ€ofโ€bigwords.
  • [count] F <character> โ€” search count times backward through the current line for <character>.
  • [count] G โ€” move to line count, or the last line of the file if count not specified.
  • [count] H โ€” move to the screen line count - 1 lines below the top of the screen.
  • [count] I โ€” enter input mode, inserting the text at the beginning of the line.
  • [count] J โ€” join lines. the way that just merges the vibe. ๐Ÿซถ
  • [count] L โ€” move to the screen line count - 1 lines above the bottom of the screen.
  • M โ€” move to the screen line in the middle of the screen.
  • [count] O โ€” enter input mode, appending text in a new line above the current line.
  • [buffer] P โ€” insert text from a buffer.
  • Q โ€” exit vi (or visual) mode and switch to ex mode.
  • [count] R โ€” enter input mode, replacing the characters in the current line.
  • [buffer] [count] S โ€” substitute count lines.
  • [count] T <character> โ€” search backwards, count times, through the current line for the character after the specified <character>.
  • U โ€” restore the current line to its state before the cursor last moved to it.
  • [count] W โ€” move forward count bigwords.
  • [buffer] [count] X โ€” delete count characters before the cursor.
  • [buffer] [count] Y โ€” copy (or โ€œyankโ€) count lines into the specified buffer.
  • ZZ โ€” write the file and exit vi. main character exit. ๐Ÿ‘‘
  • [count] [[ โ€” back up count section boundaries.
  • [count] ]] โ€” move forward count section boundaries.
  • ^ โ€” move to first nonblank character on the current line.
  • [count] _ โ€” move down count - 1 lines, to the first nonblank character.
  • [count] a โ€” enter input mode, appending the text after the cursor.
  • [count] b โ€” move backwards count words.
  • [buffer] [count] c motion โ€” change a region of text.
  • [buffer] [count] d motion โ€” delete a region of text.
  • [count] e โ€” move forward count endโ€ofโ€words.
  • [count] f<character> โ€” search forward, count times, through the rest of the current line for <character>.
  • [count] i โ€” enter input mode, inserting the text before the cursor.
  • m <character> โ€” save the current context (line and column) as <character>.
  • [count] o โ€” enter input mode, appending text in a new line under the current line.
  • [buffer] p โ€” append text from a buffer.
  • [count] r <character> โ€” replace count characters.
  • [buffer] [count] s โ€” substitute count characters in the current line starting with the current character.
  • [count] t <character> โ€” search forward, count times, through the current line for the character immediately before <character>.
  • u โ€” undo the last change made to the file. fr fr, the save button of vibes. ๐Ÿ˜ญ
  • [count] w โ€” move forward count words.
  • [buffer] [count] x โ€” delete count characters.
  • [buffer] [count] y motion โ€” copy (or โ€œyankโ€) a text region specified by the count and motion into a buffer.
  • [count1] z [count2] -|.|+|^|<carriageโ€return> โ€” redraw, optionally repositioning and resizing the screen.
  • [count] { โ€” move backward count paragraphs.
  • [count] | โ€” move to a specific column position on the current line.
  • [count] } โ€” move forward count paragraphs.
  • [count] ~ โ€” reverse the case of the next count character(s), if the tildeop option is unset.
  • [count] ~ motion โ€” reverse the case of the characters in a text region specified by the count and motion, if the tildeop option is set.
  • <interrupt> โ€” interrupt the current operation. โœ‹

๐Ÿฆ‹ VI TEXT INPUT COMMANDS ๐Ÿฆ‹

okay bestie, now weโ€™re in text input mode โ€” the part where you actually type. hereโ€™s the menu. ๐Ÿ’–

  • <nul> โ€” replay the previous input.
  • <controlโ€D> โ€” erase to the previous shiftwidth column boundary.
  • ^<controlโ€D> โ€” erase all of the autoindent characters, and reset the autoindent level.
  • 0<controlโ€D> โ€” erase all of the autoindent characters.
  • <controlโ€T> โ€” insert sufficient <tab> and <space> characters to move forward to the next shiftwidth column boundary.
  • <erase>, <controlโ€H> โ€” erase the last character.
  • <literal next> โ€” quote the next character.
  • <escape> โ€” resolve all text input into the file, and return to command mode.
  • <line erase> โ€” erase the current line.
  • <controlโ€W>, <word erase> โ€” erase the last word. The definition of word is dependent on the altwerase and ttywerase options.
  • <controlโ€X>[0-9A-Fa-f]+ โ€” insert a character with the specified hexadecimal value into the text.
  • <interrupt> โ€” interrupt text input mode, returning to command mode. ๐Ÿ›‘

โœจ EX COMMANDS โœจ

okay so bestie, this next section is literally the ex editor command library ๐Ÿ‘‘ the following section describes the commands available in the ex editor. In each entry below, the tag line is a usage synopsis for the command. No cap, read the synopsis like a little recipe. ๐Ÿงš


  • <endโ€ofโ€file> โ€” Scroll the screen. ๐Ÿ“œ
  • ! argument(s)
  • [range]! argument(s) โ€” Execute a shell command, or filter lines through a shell command. ๐Ÿš
  • " โ€” A comment. ๐Ÿ’ฌ
  • [range] nu[mber] [count] [flags]
  • [range] # [count] [flags] โ€” Display the selected lines, each preceded with its line number. ๐Ÿ”ข
  • @ buffer
  • * buffer โ€” Execute a buffer. โšก
  • [line] a[ppend][!] โ€” The input text is appended after the specified line. ๐Ÿ“
  • [range] c[hange][!] [count] โ€” The input text replaces the specified range. ๐Ÿ”
  • cs[cope] add | find | help | kill | reset โ€” Execute a Cscope command. ๐Ÿ”
  • [range] d[elete] [buffer] [count] [flags] โ€” Delete the lines from the file. ๐Ÿ—‘๏ธ
  • di[splay] b[uffers] | c[onnections] | s[creens] | t[ags] โ€” Display buffers, Cscope connections, screens or tags. ๐Ÿ“‹
  • [Ee][dit][!] [+cmd] [file]
  • [Ee]x[!] [+cmd] [file] โ€” Edit a different file. ๐Ÿ“‚
  • exu[sage] [command] โ€” Display usage for an ex command. โ„น๏ธ
  • f[ile] [file] โ€” Display and optionally change the file name. ๐Ÿ“›
  • [Ff]g [name] โ€” Vi mode only. Foreground the specified screen. ๐Ÿ–ฅ๏ธ
  • [range] g[lobal] /pattern/ [commands]
  • [range] v /pattern/ [commands] โ€” Apply commands to lines matching (or not matching) a pattern. ๐ŸŽฏ
  • he[lp] โ€” Display a help message. ๐Ÿ†˜
  • [line] i[nsert][!] โ€” The input text is inserted before the specified line. โฌ†๏ธ
  • [range] j[oin][!] [count] [flags] โ€” Join lines of text together. ๐Ÿ”—
  • [range] l[ist] [count] [flags] โ€” Display the lines unambiguously. ๐Ÿ“ƒ
  • map[!] [lhs rhs] โ€” Define or display maps (for vi only). ๐Ÿ—บ๏ธ
  • [line] ma[rk] <character>
  • [line] k <character> โ€” Mark the line with the mark <character>. ๐Ÿ“
  • [range] m[ove] line โ€” Move the specified lines after the target line. ๐Ÿšš
  • mk[exrc][!] file โ€” Write the abbreviations, editor options and maps to the specified file. ๐Ÿ’พ
  • [Nn][ext][!] [file ...] โ€” Edit the next file from the argument list. โญ๏ธ
  • [line] o[pen] /pattern/ [flags] โ€” Enter open mode. ๐Ÿšช
  • pre[serve] โ€” Save the file in a form that can later be recovered using the ex -r option. ๐Ÿ›Ÿ
  • [Pp]rev[ious][!] โ€” Edit the previous file from the argument list. โฎ๏ธ
  • [range] p[rint] [count] [flags] โ€” Display the specified lines. ๐Ÿ–จ๏ธ
  • [line] pu[t] [buffer] โ€” Append buffer contents to the current line. ๐Ÿ“Ž
  • q[uit][!] โ€” End the editing session. ๐Ÿ‘‹
  • [line] r[ead][!] [file] โ€” Read a file. ๐Ÿ“–
  • rec[over] file โ€” Recover file if it was previously saved. โ™ป๏ธ
  • res[ize] [+|-]size โ€” Vi mode only. Grow or shrink the current screen. ๐Ÿ“
  • rew[ind][!] โ€” Rewind the argument list. โช
  • se[t] [option[=[value]] ...] [nooption ...] [option? ...] [all] โ€” Display or set editor options. โš™๏ธ
  • sh[ell] โ€” Run a shell program. ๐Ÿš
  • so[urce] file โ€” Read and execute ex commands from a file. ๐Ÿ“œ
  • [range] s[ubstitute] [/pattern/replace/] [options] [count] [flags]
  • [range] & [options] [count] [flags]
  • [range] ~ [options] [count] [flags] โ€” Make substitutions. ๐Ÿ”„
  • su[spend][!]
  • st[op][!]
  • <suspend> โ€” Suspend the edit session. โธ๏ธ
  • [Tt]a[g][!] tagstring โ€” Edit the file containing the specified tag. ๐Ÿท๏ธ
  • tagn[ext][!] โ€” Edit the file containing the next context for the current tag. โฉ
  • tagp[op][!] [file | number] โ€” Pop to the specified tag in the tags stack. ๐Ÿ“ค
  • tagp[rev][!] โ€” Edit the file containing the previous context for the current tag. โช
  • unm[ap][!] lhs โ€” Unmap a mapped string. ๐Ÿ”“
  • ve[rsion] โ€” Display the version of the ex/vi editor. ๐Ÿ“ฆ
  • [line] vi[sual] [type] [count] [flags] โ€” Ex mode only. Enter vi. ๐Ÿšช
  • [Vi]i[sual][!] [+cmd] [file] โ€” Vi mode only. Edit a new file. ๐Ÿ†•
  • viu[sage] [command] โ€” Display usage for a vi command. โ„น๏ธ
  • [range] w[rite][!] [>>] [file]
  • [range] w[rite] [!] [file]
  • [range] wn[!] [>>] [file]
  • [range] wq[!] [>>] [file] โ€” Write the file. ๐Ÿ’พ
  • [range] x[it][!] [file] โ€” Write the file if it has been modified. ๐Ÿ’พ
  • [range] ya[nk] [buffer] [count] โ€” Copy the specified lines to a buffer. ๐Ÿ“‹
  • [line] z [type] [count] [flags] โ€” Adjust the window. ๐ŸชŸ

โœจ SET OPTIONS โœจ

okay bestie, this is the big one โ€” there are a ton of options you can set (or unset) to change how the editor acts, and this section is gonna walk you through every single one, plus their abbreviations and their default values. buckle up ๐Ÿ’–

So how do you read these? In each entry, the first part of the tag line is the full name of the option, and then comes any equivalent abbreviations. The part sitting in square brackets [] is the default value of that option. And heads up: most of these are boolean, meaning they're either on or off, and they don't have a value attached to them at all. simple like that โœจ

Also, options apply to both ex and vi modes, unless it says otherwise. You can give multiple options in one set or unset, separated by spaces or tabs. And if you want spaces or tabs inside a string option (like tags or filec), just precede each one with a backslash. but bestie, plot twist: there's no way to get a backslash itself into an option. that's just how it is ๐Ÿ˜ญ


  • altwerase [off] โ€” Vi only. Select an alternate word erase algorithm. โœจ
  • autoindent, ai [off] โ€” Automatically indent new lines. ๐Ÿซถ
  • autoprint, ap [off] โ€” Ex only. Display the current line automatically. ๐Ÿ‘‘
  • autowrite, aw [off] โ€” Write modified files automatically when changing files. ๐Ÿ’…
  • backup [""] โ€” Backup files before they are overwritten. ๐ŸŽ€
  • beautify, bf [off] โ€” Discard control characters. ๐Ÿงš
  • cdpath [environment variable CDPATH, or current directory] โ€” The directory paths used as path prefixes for the cd command. ๐ŸŒธ
  • cedit [no default] โ€” Set the character to edit the colon command-line history. โญ
  • columns, co [80] โ€” Set the number of columns in the screen. ๐Ÿ’œ
  • comment [off] โ€” Vi only. Skip leading comments in shell, C and C++ language files. ๐ŸŒˆ
  • directory, dir [environment variable TMPDIR, or /tmp] โ€” The directory where temporary files are created. ๐Ÿ“
  • edcompatible, ed [off] โ€” Remember the values of the โ€œcโ€ and โ€œgโ€ suffices to the substitute commands, instead of initializing them as unset for each new command. ๐Ÿ”ฅ
  • errorbells, eb [off] โ€” Ex only. Announce error messages with a bell. ๐Ÿ””
  • exrc, ex [off] โ€” Read the startup files in the local directory. ๐Ÿ’–
  • extended [off] โ€” Regular expressions are extended (i.e. egrep(1)-style) expressions. โœจ
  • filec [no default] โ€” Set the character to perform file path completion on the colon command line. ๐ŸŽ€
  • flash [on] โ€” Flash the screen instead of beeping the keyboard on error. โšก
  • hardtabs, ht [8] โ€” Set the spacing between hardware tab settings. ๐Ÿฆ‹
  • iclower [off] โ€” Makes all Regular Expressions case-insensitive, as long as an upper-case letter does not appear in the search string. ๐Ÿ’ซ
  • ignorecase, ic [off] โ€” Ignore case differences in regular expressions. ๐Ÿ™ˆ
  • keytime [6] โ€” The 10th's of a second ex/vi waits for a subsequent key to complete a key mapping. โณ
  • leftright [off] โ€” Vi only. Do left-right scrolling. ๐ŸŒŠ
  • lines, li [24] โ€” Vi only. Set the number of lines in the screen. ๐Ÿ“
  • lisp [off] โ€” Vi only. Modify various search commands and options to work with Lisp. This option is not yet implemented. ๐Ÿ’€
  • list [off] โ€” Display lines in an unambiguous fashion. ๐Ÿ‘€
  • lock [on] โ€” Attempt to get an exclusive lock on any file being edited, read or written. ๐Ÿ”’
  • magic [on] โ€” Treat certain characters specially in regular expressions. ๐Ÿช„
  • matchtime [7] โ€” Vi only. The 10th's of a second ex/vi pauses on the matching character when the showmatch option is set. โฑ๏ธ
  • mesg [on] โ€” Permit messages from other users. ๐Ÿ’Œ
  • modelines, modeline [off] โ€” Read the first and last few lines of each file for ex commands. This option will never be implemented. ๐Ÿ˜ญ
  • noprint [""] โ€” Characters that are never handled as printable characters. ๐Ÿšซ
  • number, nu [off] โ€” Precede each line displayed with its current line number. ๐Ÿ”ข
  • octal [off] โ€” Display unknown characters as octal numbers, instead of the default hexadecimal. ๐Ÿ™
  • open [on] โ€” Ex only. If this option is not set, the open and visual commands are disallowed. ๐Ÿšช
  • optimize, opt [on] โ€” Vi only. Optimize text throughput to dumb terminals. This option is not yet implemented. ๐Ÿ’€
  • paragraphs, para [IPLPPPQPP LIpplpipbp] โ€” Vi only. Define additional paragraph boundaries for the { and } commands. ๐Ÿ“
  • path [] โ€” Define additional directories to search for files being edited. ๐Ÿ—บ๏ธ
  • print [""] โ€” Characters that are always handled as printable characters. ๐Ÿ–จ๏ธ
  • prompt [on] โ€” Ex only. Display a command prompt. ๐Ÿ’ฌ
  • readonly, ro [off] โ€” Mark the file and session as read-only. ๐Ÿ”
  • recdir [/var/tmp/vi.recover] โ€” The directory where recovery files are stored. ๐Ÿฉน
  • redraw, re [off] โ€” Vi only. Simulate an intelligent terminal on a dumb one. This option is not yet implemented. ๐Ÿ’€
  • remap [on] โ€” Remap keys until resolved. ๐Ÿ”
  • report [5] โ€” Set the number of lines about which the editor reports changes or yanks. ๐Ÿ“ข
  • ruler [off] โ€” Vi only. Display a row/column ruler on the colon command line. ๐Ÿ“
  • scroll, scr [window / 2] โ€” Set the number of lines scrolled. ๐Ÿ“œ
  • searchincr [off] โ€” Makes the / and ? commands incremental. ๐Ÿ”
  • sections, sect [NHSHH HUnhsh] โ€” Vi only. Define additional section boundaries for the [[ and ]] commands. ๐Ÿ—‚๏ธ
  • secure [off] โ€” Turns off all access to external programs. ๐Ÿ›ก๏ธ
  • shell, sh [environment variable SHELL, or /bin/sh] โ€” Select the shell used by the editor. ๐Ÿš
  • shellmeta โ€” Set the meta characters checked to determine if file name expansion is necessary. Default is:
[~{[*?$`'"\]
  • shiftwidth, sw [8] โ€” Set the autoindent and shift command indentation width. โžก๏ธ
  • showmatch, sm [off] โ€” Vi only. Note matching โ€œ{โ€ and โ€œ(โ€ for โ€œ}โ€ and โ€œ)โ€ characters. ๐Ÿงฉ
  • showmode, smd [off] โ€” Vi only. Display the current editor mode and a โ€œmodifiedโ€ flag. ๐Ÿท๏ธ
  • sidescroll [16] โ€” Vi only. Set the amount a left-right scroll will shift. โ†”๏ธ
  • slowopen, slow [off] โ€” Delay display updating during text input. This option is not yet implemented. ๐Ÿ’€
  • sourceany [off] โ€” Read startup files not owned by the current user. This option will never be implemented. ๐Ÿ˜ญ
  • tabstop, ts [8] โ€” This option sets tab widths for the editor display. ๐Ÿ“Š
  • taglength, tl [0] โ€” Set the number of significant characters in tag names. ๐Ÿท๏ธ
  • tags, tag [tags /var/db/libc.tags /sys/kern/tags] โ€” Set the list of tags files. ๐Ÿ“š
  • term, ttytype, tty [environment variable TERM] โ€” Set the terminal type. ๐Ÿ–ฅ๏ธ
  • terse [off] โ€” This option has historically made editor messages less verbose. It has no effect in this implementation. ๐Ÿคท
  • tildeop [off] โ€” Modify the ~ command to take an associated motion. ใ€ฐ๏ธ
  • timeout, to [on] โ€” Time out on keys which may be mapped. โŒ›
  • ttywerase [off] โ€” Vi only. Select an alternate erase algorithm. โœจ
  • verbose [off] โ€” Vi only. Display an error message for every error. ๐Ÿ“ฃ
  • w300 [no default] โ€” Vi only. Set the window size if the baud rate is less than 1200 baud. ๐Ÿข
  • w1200 [no default] โ€” Vi only. Set the window size if the baud rate is equal to 1200 baud. ๐Ÿšถ
  • w9600 [no default] โ€” Vi only. Set the window size if the baud rate is greater than 1200 baud. ๐ŸŽ๏ธ
  • warn [on] โ€” Ex only. This option causes a warning message to the terminal if the file has been modified, since it was last written, before a ! command. โš ๏ธ
  • window, w, wi [environment variable LINES] โ€” Set the window size for the screen. ๐ŸชŸ
  • windowname [off] โ€” Change the icon/window name to the current file name even if it can't be restored on editor exit. ๐Ÿ–ผ๏ธ
  • wraplen, wl [0] โ€” Vi only. Break lines automatically, the specified number of columns from the left-hand margin. If both the wraplen and wrapmargin edit options are set, the wrapmargin value is used. ๐Ÿ“
  • wrapmargin, wm [0] โ€” Vi only. Break lines automatically, the specified number of columns from the right-hand margin. If both the wraplen and wrapmargin edit options are set, the wrapmargin value is used. ๐Ÿ“
  • wrapscan, ws [on] โ€” Set searches to wrap around the end or beginning of the file. ๐Ÿ”„
  • writeany, wa [off] โ€” Turn off file-overwriting checks. ๐Ÿšจ

๐ŸŒ ENVIRONMENT VARIABLES ๐ŸŒ

bestie these are the environment variables that ex/vi actually looks at, no cap ๐Ÿซถ

  • COLUMNS โ€” The number of columns on the screen. This value overrides any system or terminal specific values. If the COLUMNS environmental variable is not set when ex/vi runs, or the columns option is explicitly reset by the user, ex/vi enters the value into the environment. ๐Ÿ“
  • EXINIT โ€” A list of ex startup commands, read if the variable NEXINIT is not set. โš™๏ธ
  • HOME โ€” The user's home directory, used as the initial directory path for the startup โ€œ$HOME/.nexrcโ€ and โ€œ$HOME/.exrcโ€ files. This value is also used as the default directory for the vi cd command. ๐Ÿ 
  • LINES โ€” The number of rows on the screen. This value overrides any system or terminal specific values. If the LINES environmental variable is not set when ex/vi runs, or the lines option is explicitly reset by the user, ex/vi enters the value into the environment. ๐Ÿ“
  • NEXINIT โ€” A list of ex startup commands. โœจ
  • SHELL โ€” The user's shell of choice (see also the shell option). ๐Ÿš
  • TERM โ€” The user's terminal type. The default is the type โ€œunknownโ€. If the TERM environmental variable is not set when ex/vi runs, or the term option is explicitly reset by the user, ex/vi enters the value into the environment. ๐Ÿ–ฅ๏ธ
  • TMPDIR โ€” The location used to stored temporary files (see also the directory edit option). ๐Ÿ—‚๏ธ

โœจ ASYNCHRONOUS EVENTS โœจ

okay so bestie, sometimes the world just interrupts you mid-edit and vi has to deal with it, no cap. Here's the tea on every signal the editor pays attention to ๐Ÿซถ

๐Ÿšจ SIGALRM

Vi/ex uses this signal for periodic backups of file modifications and to display "busy" messages when operations are likely to take a long time.

so basically: it's the little alarm clock that quietly saves your butt in the background and pops up the "busy" vibe when something's gonna take a sec ๐Ÿ’–

๐Ÿšจ SIGHUP

๐Ÿšจ SIGTERM

If the current buffer has changed since it was last written in its entirety, the editor attempts to save the modified file so it can be later recovered. See the vi/ex Reference manual section entitled "Recovery" for more information.

iykyk: if you haven't saved the whole buffer since your last edit, vi frantically tries to stash your changes so you can recover them later. iconic behavior honestly ๐Ÿ˜ญ๐Ÿ’…

๐Ÿšจ SIGINT

When an interrupt occurs, the current operation is halted, and the editor returns to the command level. If interrupted during text input, the text already input is resolved into the file as if the text input had been normally terminated.

Ctrl-C energy ๐Ÿ’€ the thing you were doing just stops and you're back at command level. and if you were typing text? whatever you'd already typed gets committed into the file like you'd ended it properly. no data lost, we love to see it โœจ

๐Ÿšจ SIGWINCH

The screen is resized. See the vi/ex Reference manual section entitled "Sizing the Screen" for more information.

drag that terminal window bigger, bestie โ€” vi notices and reshapes itself ๐ŸŒธ

๐Ÿšจ SIGCONT

๐Ÿšจ SIGQUIT

๐Ÿšจ SIGTSTP

Vi/ex ignores these signals.

yeah, vi is giving unbothered. main character energy, it simply does not react to these ones ๐Ÿ‘‘

๐Ÿ“ FILES ๐Ÿ“

here's the whole friend group of paths vi cares about ๐ŸŽ€

  • /bin/sh โ€” the default user shell.
  • /etc/vi.exrc โ€” system-wide vi startup file.
  • /tmp โ€” temporary file directory.
  • /var/tmp/vi.recover โ€” the default recovery file directory.
  • $HOME/.nexrc โ€” 1st choice for user's home directory startup file.
  • $HOME/.exrc โ€” 2nd choice for user's home directory startup file.
  • .nexrc โ€” 1st choice for local directory startup file.
  • .exrc โ€” 2nd choice for local directory startup file.
lowkey the home-dir ones go first, then the local-dir ones, and within each pair the .nexrc is the favorite child ๐Ÿฅ‡

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

the extended universe, bestie โ€” go read these when you're obsessed and want more ๐Ÿ“š

  • ctags(1), more(1), curses(3), dbopen(3)
  • The "Vi Quick Reference" card.
  • "An Introduction to Display Editing with Vi", found in the "UNIX User's Manual Supplementary Documents" section of both the 4.3BSD and 4.4BSD manual sets. This document is the closest thing available to an introduction to the vi screen editor.
  • "Ex Reference Manual (Version 3.7)", found in the "UNIX User's Manual Supplementary Documents" section of both the 4.3BSD and 4.4BSD manual sets. This document is the final reference for the ex editor, as distributed in most historic 4BSD and System V systems.
  • "Edit: A tutorial", found in the "UNIX User's Manual Supplementary Documents" section of the 4.3BSD manual set. This document is an introduction to a simple version of the ex screen editor.
  • "Ex/Vi Reference Manual", found in the "UNIX User's Manual Supplementary Documents" section of the 4.4BSD manual set. This document is the final reference for the nex/nvi text editors, as distributed in 4.4BSD and 4.4BSD-Lite.
  • Roff source for all of these documents is distributed with nex/nvi in the nvi/USD.doc directory of the nex/nvi source code.
  • The files "autowrite", "input", "quoting" and "structures" found in the nvi/docs/internals directory of the nex/nvi source code.
the internals docs are the deep lore, fr fr ๐Ÿงš if you wanna know how the machine actually works, that's where you go ๐Ÿ’œ

๐Ÿ“œ HISTORY ๐Ÿ“œ

The nex/nvi replacements for the ex/vi editor first appeared in 4.4BSD.

glow-up origin story โœจ 4.4BSD was the debut, periodt.

๐Ÿ“ STANDARDS ๐Ÿ“

Nex/nvi is close to IEEE Std1003.2 ("POSIX"). That document differs from historical ex/vi practice in several places; there are changes to be made on both sides.

so like... they're almost matching ๐Ÿ’… not a full slay on either side yet โ€” POSIX and old-school ex/vi each gotta bend a little. changes coming on both ends, no cap.

and that's a wrap on the whole page, bestie!! ๐ŸŽ€ this one comes to you from the 3rd Berkeley Distribution, tagged 15Q15, living its life as VI(1) ๐Ÿ’– go forth and edit, you absolute icon ๐Ÿ‘‘

๐Ÿ“ฆ where this page comes from