VI(1)
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 inexmode, as if the command name wereex.-lโ Start editing with thelispandshowmatchoptions set.-Rโ Start editing in readโonly mode, as if the command name wasview, or thereadonlyoption 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-roption had not been specified. your "omg my laptop died mid-essay" bestie ๐ซถ-Sโ Run with thesecureedit option set, disallowing all access to external programs. no outside friends, we're staying in tonight ๐ซ-sโ Enter batch mode; applicable only toexedit sessions. Batch mode is useful when runningexscripts. 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. (Seectags(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 invimode, as if the command name wasviorview.
okay so quick tea: the-Foption (which preventedex/vifrom 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 thea,i,Oorocommands, 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 thevicommand 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 leavevi(if you've modified the file, but not saved your changes,viwill 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 forwardcounttimes for the current word. ๐[count] <controlโB>โ page backwardscountscreens. ๐[count] <controlโD>โ scroll forwardcountlines.[count] <controlโE>โ scroll forwardcountlines, leaving the current line and column as is, if possible.[count] <controlโF>โ page forwardcountscreens. โจ<controlโG>โ display the file information. ๐<controlโH>,[count] hโ move the cursor backcountcharacters in the current line.[count] <controlโJ>,[count] <controlโN>,[count] jโ move the cursor downcountlines without changing the current column.<controlโL>,<controlโR>โ repaint the screen. ๐จ[count] <controlโM>,[count] +โ move the cursor downcountlines to the first nonblank character of that line.[count] <controlโP>,[count] kโ move the cursor upcountlines, without changing the current column.<controlโT>โ return to the most recent tag context.<controlโU>โ scroll backwardscountlines.<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 backwardscountlines, 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 forwardcountcharacters 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 upcountsentences.[count] )โ move forwardcountsentences.[count] ,โ reverse find charactercounttimes.[count] -โ move to first nonblank of the previous line,counttimes.[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 findcounttimes.[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 backwardscountbigwords.[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 forwardcountendโofโbigwords.[count] F <character>โ searchcounttimes backward through the current line for<character>.[count] Gโ move to linecount, or the last line of the file ifcountnot specified.[count] Hโ move to the screen linecount - 1lines 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 linecount - 1lines 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โ substitutecountlines.[count] T <character>โ search backwards,counttimes, 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 forwardcountbigwords.[buffer] [count] Xโ deletecountcharacters before the cursor.[buffer] [count] Yโ copy (or โyankโ)countlines into the specified buffer.ZZโ write the file and exit vi. main character exit. ๐[count] [[โ back upcountsection boundaries.[count] ]]โ move forwardcountsection boundaries.^โ move to first nonblank character on the current line.[count] _โ move downcount - 1lines, to the first nonblank character.[count] aโ enter input mode, appending the text after the cursor.[count] bโ move backwardscountwords.[buffer] [count] c motionโ change a region of text.[buffer] [count] d motionโ delete a region of text.[count] eโ move forwardcountendโofโwords.[count] f<character>โ search forward,counttimes, 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>โ replacecountcharacters.[buffer] [count] sโ substitutecountcharacters in the current line starting with the current character.[count] t <character>โ search forward,counttimes, 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 forwardcountwords.[buffer] [count] xโ deletecountcharacters.[buffer] [count] y motionโ copy (or โyankโ) a text region specified by thecountandmotioninto a buffer.[count1] z [count2] -|.|+|^|<carriageโreturn>โ redraw, optionally repositioning and resizing the screen.[count] {โ move backwardcountparagraphs.[count] |โ move to a specific column position on the current line.[count] }โ move forwardcountparagraphs.[count] ~โ reverse the case of the nextcountcharacter(s), if thetildeopoption is unset.[count] ~ motionโ reverse the case of the characters in a text region specified by thecountandmotion, if thetildeopoption 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 previousshiftwidthcolumn 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 nextshiftwidthcolumn 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 thealtweraseandttyweraseoptions.<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 thecdcommand. ๐ธ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 secondex/viwaits 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 secondex/vipauses on the matching character when theshowmatchoption is set. โฑ๏ธmesg[on]โ Permit messages from other users. ๐modelines,modeline[off]โ Read the first and last few lines of each file forexcommands. 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, theopenandvisualcommands 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 theautoindentand 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 thewraplenandwrapmarginedit options are set, thewrapmarginvalue is used. ๐wrapmargin,wm[0]โ Vi only. Break lines automatically, the specified number of columns from the right-hand margin. If both thewraplenandwrapmarginedit options are set, thewrapmarginvalue 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 theCOLUMNSenvironmental variable is not set whenex/viruns, or thecolumnsoption is explicitly reset by the user,ex/vienters the value into the environment. ๐EXINITโ A list ofexstartup commands, read if the variableNEXINITis 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 thevicdcommand. ๐LINESโ The number of rows on the screen. This value overrides any system or terminal specific values. If theLINESenvironmental variable is not set whenex/viruns, or thelinesoption is explicitly reset by the user,ex/vienters the value into the environment. ๐NEXINITโ A list ofexstartup commands. โจSHELLโ The user's shell of choice (see also theshelloption). ๐TERMโ The user's terminal type. The default is the type โunknownโ. If theTERMenvironmental variable is not set whenex/viruns, or thetermoption is explicitly reset by the user,ex/vienters the value into the environment. ๐ฅ๏ธTMPDIRโ The location used to stored temporary files (see also thedirectoryedit 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.docdirectory of the nex/nvi source code. - The files "autowrite", "input", "quoting" and "structures" found in the
nvi/docs/internalsdirectory 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
- debian bookworm: nvi 1.81.6-17+b2 ยท BSD-3
- debian trixie: nvi 1.81.6-23 ยท BSD-3
- ubuntu jammy: nvi 1.81.6-17 ยท BSD-3
- ubuntu noble: nvi 1.81.6-21 ยท BSD-3
- ubuntu questing: nvi 1.81.6-23
- ubuntu resolute: nvi 1.81.6-24 ยท BSD-3
- ubuntu stonking: nvi 1.81.6-24 ยท BSD-3
- Copyright (c) 1994 The Regents of the University of California. All rights reserved
- Copyright (c) 1994, 1995, 1996 Keith Bostic. All rights reserved
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms