⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vi.ref

📁 早期freebsd实现
💻 REF
字号:
.\" Copyright (c) 1994.\"     The Regents of the University of California.  All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"     @(#)vi.ref	8.23 (Berkeley) 4/18/94.\".Dd "April 18, 1994".Dt "EX/VI REFERENCE MANUAL" 1.Os.Sh NAME.Nm ex, vi, view.Nd text editors.Sh DESCRIPTION.Nm \&Viis a screen oriented text editor..Nm \&Exis a line-oriented text editor..Nm \&Exand.Nm \&viare different interfaces to the same program,and it is possible to switch back and forth during an edit session..Nm Viewis the equivalent of using the.Fl R(read-only) option of.Nm \&vi ..PpThis reference manual is the one provided with the.Nm nex/nviversions of the.Nm ex/vitext editors..Nm Nex/nviare intended as bug-for-bug compatible replacements for the originalFourth Berkeley Software Distribution (4BSD).Nm \&exand.Nm \&viprograms.This reference manual is accompanied by a traditional-style manual page.That manual page describes the functionality found in.Nm ex/viin far less detail than the description here.In addition, it describes the system interface to.Nm ex/vi ,e.g. command line options, environmental variables, and similar things..PpThis reference is intended for users already familiar with.Nm ex/vi .Anyone else should almost certainly read a good tutorial on theeditor first.If you're in an unfamiliar environment, and you absolutely have toget work done immediately, see the section entitled FAST STARTUPin the manual page.It's probably enough to get you going..PpFor the rest of this reference,.Nm nex/nviis used only when it's necessary to distinguish it from the historicimplementations of.Nm ex/vi ..Sh ADDITIONAL FEATURESThere are a few features in.Nm nex/nvithat are not found in historic versions of.Nm ex/vi .A list of those features is as follows:.Bl -tag -width indent.It "8-bit clean data, large lines, files".Nm \&Nvi/nexwill edit any format file.Line lengths are limited by available memory,and file sizes are limited by available disk space.The command.Dq "^X[0-9A-Fa-f]* ,"in input mode, will insert any legal character value into the text..It "Split screens"The command.Dq ":sp[lit] [file ...]"splits the screen in vi mode.The key.Dq "^W"switches between the foreground screens,and the.Dq ":resize count"command can be used to grow or shrink a particular screen..It "Background and foreground screens"The command.Dq ":bg"backgrounds the current screen,and the command.Dq ":fg [file]"foregrounds the backgrounded screenthat is editing the specified file, or, by default, the first backgroundscreen on the queue.The command.Dq ":di[splay] s[creens]"lists the background screens..It "Shell screens"The command.Dq ":sc[ript] [file ...]"runs a shell in the screen.Editing is unchanged, with the exception that a <carriage-return>enters the current line (stripped of any prompt) as input to theshell..It "Tag stacks"Tags are now maintained in a stack.The command.Dq "^T"returns to the previous tag location.The command.Dq ":tagpop [number \| file]"returns to the most recent taglocation by default, or, optionally to a specific tag number in thetag stack, or the most recent tag from the specified file.Use the command.Dq ":di[splay] t[ags]"to view the tags stack.The command.Dq ":tagtop"returns to the top of the tag stack..It "New displays"The command.Dq ":di[splay] b[uffers] \| s[creens] \| t[ags]"can beused to display, respectively, the current cut buffers,the backgrounded screens, and the tags stack..It "Infinite undo"The changes made during an edit session may be rolled backward andforward.A '.' command immediately after a 'u' command continues either forwardor backward depending on whether the 'u' command was an undo or a redo..It "Usage information"The command.Dq ":exu[sage] [cmd]"and.Dq "viu[sage] [key]"provide usageinformation for all of the ex and vi commands by default, or, optionally,for a specific command or key..It "Extended regular expressions"The.Dq ":set extended"command treats search and other command regularexpressions as extended (egrep(1) style) regular expressions..It "Word search"The command.Dq "^A"searches for the word referenced by the cursor..It "Number increment"The command.Dq "#"increments the number referenced by the cursor..It "Previous file"The command.Dq ":prev[ious][!]"edits the previous file from theargument list..It "Left-Right scrolling"The command.Dq ":set leftright"makes.Nm nvido left-right screen scrolling, instead of the traditional.Nm \&viline wrapping..Sh STARTUP INFORMATION.Nm Ex/viinterprets one of two possible environmental variables and reads upto three of five possible files during startup.The variables and files are expected to contain.Nm \&excommands, not.Nm \&vicommands.In addition, they are interpreted.Em beforethe file to be edited is read, and therefore many.Nm \&excommands may not be used.Generally, any command that requires output to the screen or thatneeds a file upon which to operate, will cause an error if includedin a startup file or environmental variable..PpFirst, the file.Pa /etc/vi.exrcis read.Second, the environmental variable.Ev NEXINIT(or the variable.Ev EXINIT ,if.Ev NEXINITisn't set) is interpreted.Third, if neither.Ev NEXINITor.Ev EXINITwas set, the file.Pa $HOME/.nexrc(or the file.Pa $HOME/.exrc ,if.Pa $HOME/.nexrcdoesn't exist) is read.Fourth, the file.Pa .nexrc(or the file.Pa .exrc ,if.Pa .nexrcdoesn't exist) is read..PpStartup files will not be read if they are owned by anyone otherthan the real user-id of the user running.Nm \&vi ,(or by.Dq rootin the case of the file.Pa /etc/vi.exrc )or if they are writable by anyone other than the owner.Home directory startup files (i.e..Pa $HOME/.nexrcand.Pa $HOME/.exrc )will not be read if the.Dq HOMEenvironmental variable is not set.Local startup files (i.e..Pa .nexrcand.Pa .exrc )will not be read if the.Sy exrcoption is turned off in the.Pa /etc/vi.exrc ,.Pa $HOME/.nexrc ,or.Pa $HOME/.exrcfiles, or in the.Ev NEXINITor.Ev EXINITenvironmental variables.It is not an error for any of the startup environmental variablesor files not to exist..PpBecause the.Nm \&excommand set supported by.Nm nex/nviis a superset of the command set supported by most historical implementationsof.Nm \&ex ,.Nm nex/nvican use the startup files created for the historical implementations,but the converse may not be true..PpFinally, if the.Fl -s(the historic.Floption)is specified, or if standard input is redirected from a file,all environmental variables and startup files will be ignored..Sh CHARACTER DISPLAYPrintable characters are displayed using the local character set.Non-printable characters, for which.Xr iscntrl (3)returns true, and which are less than octal \e076, are displayedas the string.Dq ^<character> ,where <character> is the character that is the character's valueoffset from the.Dq \&@character.For example, the octal character \e001 is by default displayed as .Dq \&^A .If.Xr iscntrl (3)returns true for the octal character \e177, it is displayed as thestring.Dq ^? .All other characters are displayed as either hexadecimal values,in the form.Dq "0x<high-halfbyte> ... 0x<low-halfbyte>" ,or as octal values, in the form.Dq "\<high-one-or-two-bits> ... \<low-three-bits> . The display of unknown characters is based on the value of the.Sy octaloption..PpIn.Nm \&vicommand mode, the cursor is always position on the last column ofcharacters which take up more than one column on the screen.In.Nm \&vitext insert mode, the cursor is positioned on the first column ofcharacters which take up more than one column on the screen..Sh SIZING THE SCREENThe size of the screen can be set in a number of ways..Nm Ex/vitakes the following steps until values are obtained for both thenumber of rows and number of columns in the screen..sp.Bl -enum -compact.ItIf the environmental variable.Ev LINESexists, it is used to specify the number of rows in the screen..ItIf the environmental variable.Ev COLUMNSexists, it is used to specify the number of columns in the screen..ItThe TIOCGWINSZ.Xr ioctl 2is attempted on the standard error file descriptor..ItThe termcap entry is checked for the.Dq \&lientry (rows) and the.Dq \&coentry (columns)..ItThe number of rows is set to 24, and the number of columns is setto 80..El.PpIf a window change size signal (SIGWINCH) is received,the same steps are taken with the exception that the first two stepsare skipped..Sh REGULAR EXPRESSIONS AND REPLACEMENT STRINGSRegular expressions are used in line addresses,as the first part of.Sy substitute ,.Sy global ,and.Sy vglobalcommands,and in search patterns..PpThe regular expressions supported by.Nm \&exand.Nm \&viare, by default, the Basic Regular Expressions (BRE's) described in theIEEE POSIX Standard 1003.2.The.Sy extendedoption causes all regular expressions to be interpreted as the ExtendedRegular Expressions (ERE's) described by the same standard.(See.Xr re_format 7for more information.Generally speaking, BRE's are.Xr ed 1and.Xr grep 1style regular expressions, and ERE's are.Xr egrep 1style regular expressions.).PpThere are some special strings and characters that can be used inRE's:.Bl -enum -compact.ItAn empty RE (e.g..Dq \&// )is equivalent to the last RE used..ItThe construct.Dq \e<matches the beginning of a word..ItThe construct.Dq \e>matches the end of a word..ItThe character.Dq \&~matches the replacement part of the last.Sy substitutecommand..El.PpWhen the.Sy magicoption is.Em notset,the only characters with special meanings are.Dq \&^at the beginning of an RE,.Dq \&$at the end of an RE, and the escaping character.Dq \&\e .The characters.Dq \&. ,.Dq \&* ,.Dq \&[ ,and.Dq \&~are treated as ordinary characters unless preceded by a.Dq \&\e ;when preceded by a.Dq \&\ethey regain their special meaning..PpReplacement strings are the second part of a.Sy substitutecommand..PpThe character.Dq \&&(or.Dq \e&if the.Sy magicoption is.Em notset) in the replacement string stands for the text matched by the REthat's being replaced.The character.Dq \&~(or.Dq \e~if the.Sy magicoption is.Em notset) stands for the replacement part of the previous.Sy substitutecommand..PpThe string.Dq \e# ,where.Dq \&#is an integer value from 1 to 9, stands for the text matched bythe portion of the RE enclosed in the #'th set of escaped parentheses,e.g..Dq \e(and.Dq \e) .For example, .Dq "s/abc\e(.*\e)def/\e1/"deletes the strings.Dq abcand.Dq deffrom the matched pattern..PpThe strings.Dq \el ,.Dq \eu ,.Dq \eL ,and.Dq \eUcan be used to modify the case of elements in the replacement string.The string.Dq \elcauses the next character to be converted to lowercase; the string.Dq \eubehaves similarly, but converts to uppercase.The strings.Dq \eLcauses characters up to the end of the string or the next occurrence ofthe strings.Dq \eeor.Dq \eEto be converted to lowercase; the string.Dq \eUbehaves similarly, but converts to uppercase..PpIn.Nm \&vi ,inserting a <control-M> into the replacement string will cause thematched line to be split into two lines at that point..Sh RECOVERYThere is no recovery program for.Nm nvi ,nor does.Nm nvirun setuid.Users may recover any file which they may read, and the superusermay recover any edit session..PpEdit sessions are backed by files in.Pa /var/tmp/vi.recover ,and are named.Dq "vi.XXXX" ,where.Dq "XXXX"is a number related to the process id.When a file is first modified, a second file, which contains anemail message for the user, is created, and is named.Dq "recover.XXXX" ,where, again,.Dq "XXXX"is associated with the process id.Both files are removed at the end of a normal edit session,but will remain if the edit session is abnormally terminatedor the user enters the ex/vi.Dq "preserve"command.The use of the.Pa /var/tmpdirectory may be changed setting the.Sy recdiroption in the user's or system startup information..PpThe recovery directory should have the.Dq "sticky-bit"set so that only the owners of files may remove them.If this is not possible on the system, then a pseudo-user shouldown the recovery directory.The recovery directory must be both read and write-able byany user..PpThe recovery file has all of the necessary information in it to enable theuser to recover the edit session.In addition, it has all of the necessary email headers for sendmail.When the system is rebooted, all of the files in.Pa /var/tmp/vi.recovernamed.Dq "recover.XXXX"should be sent by email,using the.Fl tflag of sendmail (or a similar mechanism in other mailers).A simple way to do this is to insert the following script into your.Pa /etc/rc.local(or other startup) file:.ne 7v.Bd -literal -offset indent -compact# Recover nvi editor files.virecovery=`echo /var/tmp/vi.recover/recover.*`if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then	echo 'Recovering vi editor sessions'	for i in $virecovery; do		sendmail -t < $i	donefi.Ed.PpIf.Nm ex/vireceives a hangup (SIGHUP) signal, it will email the recoveryinformation to the user itself..PpIf you don't have the sendmail program on your system, the source file.Pa nvi/recover.cwill have to be modified to use your local mail delivery programs..Sh SET OPTIONS#include <set.opt.roff>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -