📄 vi.man
字号:
.\" 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.1 8.5 (Berkeley) 4/20/94.\".Dd "April 20, 1994".Dt EX/VI 1.Os.Sh NAME.Nm ex, vi, view.Nd text editors.Sh SYNOPSIS.Nm \&ex.Op Fl eFlRsv.Op Fl c Ar cmd.Op Fl r Ar file.Op Fl t Ar tag.Op Fl w Ar size.Op Fl x Ar \&aw.Op Ar "file ...".Nm \&vi.Op Fl eFlRv.Op Fl c Ar cmd.Op Fl r Ar file.Op Fl t Ar tag.Op Fl w Ar size.Op Fl x Ar \&aw.Op Ar "file ...".Nm view.Op Fl eFlRv.Op Fl c Ar cmd.Op Fl r Ar file.Op Fl t Ar tag.Op Fl w Ar size.Op Fl x Ar \&aw.Op Ar "file ...".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 manual page 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.For the rest of this manual page,.Nm nex/nviis used only when it's necessary to distinguish it from the historicimplementations of.Nm ex/vi ..PpThis manual page is intended for users already familiar with.Nm ex/vi .Anyone else should almost certainly read a good tutorial on theeditor before this manual page.If you're in an unfamiliar environment, and you absolutely have toget work done immediately, read the section near the end of thismanual page, entitled FAST STARTUP.It's probably enough to get you going..PpThe following options are available:.Bl -tag -width Ds .It Fl cExecute.Ar cmdimmediately after starting the edit session.Particularly useful for initial positioning in the file, however.Ar cmdis not limited to positioning commands.This is the POSIX 1003.2 interface for the historic.Dq "+cmd"syntax..Nm Nex/nvisupports both the old and new syntax..It Fl eStart editing in ex mode, as if the command name were.Nm \&ex ..It Fl FDon't copy the entire file when first starting to edit.(The default is to make a copy in case someone else modifiesthe file during your edit session.).It Fl lList the files that may be recovered using the.Fl roption of.Nm \&vi .This is the new interface for the historic syntax of the.Fl roption without a file argument..Nm Nex/nvisupports both the old and new syntax..It Fl RStart editing in read-only mode, as if the command name was.Nm view ,or the readonly option was set..It Fl rRecover the specified file..It Fl sEnter batch mode; applicable only to.Nm \&exedit sessions.Batch mode is useful when running.Nm \&exscripts.Prompts, informative messages and other user oriented messageare turned off,and no startup files or environmental variables are read.This is the POSIX 1003.2 interface for the historic.Dq \&\-argument..Nm \&Nex/nvisupports both the old and new syntax..It Fl tStart editing at the specified tag.(See.Xr ctags 1 )..It Fl wSet the initial window size to the specified number of lines..It Fl vStart editing in vi mode, as if the command name was.Nm \&vior.Nm view ..It Fl xReserved for X11 interfaces..Em "No X11 support is currently implemented.".El.PpCommand input for.Nm ex/viis read from the standard input.In the.Nm \&viinterface, it is an error if standard input is not a terminal.In the.Nm \&exinterface, if standard input is not a terminal,.Nm \&exwill read commands from it regardless, however, the session will abatch mode session, exactly as if the.Fl soption had been specified..Pp.Nm Ex/viexits 0 on success, and greater than 0 if an error occurs..Sh ENVIRONMENTAL VARIABLES.Bl -tag -width XXXX -compact.It Ev COLUMNSThe number of columns on the screen.This value overrides any system or terminal specific values.If the COLUMNS environmental variable is not set when.Nm ex/viruns, or the.Sy columnsoption is explicitly reset by the user,.Nm ex/vienters the value into the environment..It Ev EXINITA list of.Nm \&exstartup commands, read if the variable.Ev NEXINITis not set..It Ev HOMEThe user's home directory, used as the initial directory pathfor the startup.Pa $HOME/.nexrcand.Pa $HOME/.exrcfiles.This value is also used as the default directory for the.Nm \&vi.Sy \&cdcommand..It Ev LINESThe number of rows on the screen.This value overrides any system or terminal specific values.If the LINES environmental variable is not set when.Nm ex/viruns, or the.Sy linesoption is explicitly reset by the user,.Nm ex/vienters the value into the environment..It Ev NEXINITA list of.Nm \&exstartup commands..It Ev SHELLThe user's shell of choice (see also the.Sy shelloption)..It Ev TERMThe user's terminal type.The default is the type.Dq unknown .If the TERM environmental variable is not set when.Nm ex/viruns, or the.Sy termoption is explicitly reset by the user,.Nm ex/vienters the value into the environment..It Ev TMPDIRThe location used to stored temporary files (see also the.Sy directoryoption)..El.Sh SET OPTIONS#include <set.opt.roff>.Sh FAST STARTUPThis section will tell you the minimum amount that you need todo simple editing tasks using.Nm \&vi .If you've never used any screen editor before, you're likely to haveproblems even with this simple introduction.In that case you should find someone that already knows.Nm \&viand have them walk you through this section..Pp.Nm \&Viis a screen editor.This means that it takes up almost the entire screen, displaying partof 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.Nm \&vi ,and for.Nm \&vito give information to you..PpThe other fact that you need to understand is that.Nm \&viis a modeful editor, i.e. you are either entering text or youare executing commands, and you have to be in the right modeto 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.Dq escapekey, usually labeled.Dq escon your terminal's keyboard.)If you're ever confused as to which mode you're in,keep entering the <escape> key until.Nm \&vibeeps at you.(Generally,.Nm \&viwill beep at you if you try and do something that's not allowed.It will also display error messages.).PpTo start editing a file, enter the command.Dq Li "vi file_name<carriage-return>" .The command you should enter as soon as you start editing is.Dq Li ":set verbose showmode<carriage-return>" .This will make the editor give you verbose error messages and displaythe current mode at the bottom of the screen..PpThe commands to move around the file are:.Bl -tag -width XXXX -compact.It Sy hMove the cursor left one character..It Sy jMove the cursor down one line..It Sy kMove the cursor up one line..It Sy lMove the cursor right one character..It Sy <cursor-arrows>The cursor arrow keys should work, too..It Sy /text<carriage-return>Search for the string.Dq textin the file, and move the cursor to its first character..El.PpThe commands to enter new text are:.Bl -tag -width XXXX -compact.It Sy aAppend new text,.Em afterthe cursor..It Sy iInsert new text,.Em beforethe cursor..It Sy oOpen a new line below the line the cursor is on, and startentering text..It Sy OOpen a new line above the line the cursor is on, and startentering text..It Sy <escape>Once you've entered input mode using the one of the.Sy \&a ,.Sy \&i ,.Sy \&O ,or .Sy \&ocommands, use.Sy <escape>to quit entering text and return to command mode..El.PpThe commands to copy text are:.Bl -tag -width XXXX -compact.It Sy yyCopy the line the cursor is on..It Sy pAppend the copied line after the line the cursor is on..El.PpThe commands to delete text are:.Bl -tag -width XXXX -compact.It Sy ddDelete the line the cursor is on..It Sy xDelete the character the cursor is on..El.PpThe commands to write the file are:.Bl -tag -width XXXX -compact.It Sy :w<carriage-return>Write the file back to the file with the name that you originally usedas an argument on the.Nm \&vicommand line..It Sy :w file_name<carriage-return>Write the file back to the file with the name.Dq file_name ..El.PpThe commands to quit editing and exit the editor are:.Bl -tag -width XXXX -compact.It Sy :q<carriage-return>Quit editing and leave vi (if you've modified the file, but notsaved your changes,.Nm \&viwill refuse to quit)..It Sy :q!<carriage-return>Quit, discarding any modifications that you may have made..El.PpOne 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.Dq physicalcharacters and lines, i.e. they affect the entire line no matterhow many screen lines it takes up and the entire character no matterhow many screen columns it takes up..Sh BUGSSee the file.Pa nvi/docs/bugs.currentfor a list of the known bugs in this version..Sh FILES.Bl -tag -width /var/tmp/vi.recover -compact.It Pa /bin/shThe default user shell..It Pa /etc/vi.exrcSystem-wide vi startup file..It Pa /tmpTemporary file directory..It Pa /var/tmp/vi.recoverRecovery file directory..It Pa $HOME/.nexrc1st choice for user's home directory startup file..It Pa $HOME/.exrc2nd choice for user's home directory startup file..It Pa .nexrc1st choice for local directory startup file..It Pa .exrc2nd choice for local directory startup file..El.Sh SEE ALSO.Xr ctags 1 ,.Xr more 1 ,.Xr curses 3 ,.Xr dbopen 3.spThe.Dq "Vi Quick Reference"card..sp.Dq "An Introduction to Display Editing with Vi" ,found in the.Dq "UNIX User's Manual Supplementary Documents" ..sp.Dq "Edit: A tutorial" ,found in the.Dq "UNIX User's Manual Supplementary Documents" ..sp.Dq "\&Ex Reference Manual (Version 3.7)" ,found in the.Dq "UNIX User's Manual Supplementary Documents" ..Pp.Nm Nroff/troffsource for the previous three documents are distributed with.Nm nex/nviin the.Pa nvi/USD.docdirectory of the.Nm nex/nvisource code..spThe files.Dq autowrite ,.Dq input ,.Dq quoting ,and.Dq structures ,found in the.Pa nvi/docs/internalsdirectory of the.Nm nex/nvisource code..Sh HISTORYThe.Nm nex/nvireplacements for the.Nm ex/vieditor first appeared in 4.4BSD..Sh STANDARDS.Nm \&Nex/nviis close to IEEE Std1003.2 (``POSIX'').That document differs from historical.Nm ex/vipractice in several places; there are changes to be made on both sides.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -