📄 vi.apwh.ms
字号:
at line number n,and "/text", which searches for "text" and starts at the line whereit is found..IP "^^" 16Switch back to the place you were before your last tag command.If your last tag command stayed within the file, ^^ returns to that tag.If you have no recent tag command, it will return to thesame place in the previous file that it was showing when you switchedto the current file..IP ":n[!]" 16Start editing the next file in the argument list. Since \fBvi\fRcan be called with multiple file names, the ":n" command tells it tostop work on the current file and switch to the next file. If thecurrent file was modifies, it has to be written out before the ":n"will work or else the "!" must be supplied, which says discard thechanges I made to the current file..IP ":n[!] file [file file ...]" 16.spReplace the current argument list with a new list of files and startediting the first file in this new list..IP ":r file" 16Read in a copy of "file" on the line after the cursor..IP ":r !cmd" 16Execute the "cmd" and take its output and put it into the file afterthe current line..IP ":!cmd" 16Execute any UNIX shell command..IP ":ta[!] tag" 16.B Vilooks in the file named.B tagsin the current directory..B Tagsis a file of lines in the format:.sp 1.ti +8tag filename \fBvi\fR-search-command.sp 1If \fBvi\fR finds the tag you specified in the \fB:ta\fR command,it stops editing the current file if necessary and if the current file isup to date on the disk and switches to the file specified and uses thesearch pattern specified to find the "tagged" item of interest. Thisis particularly useful when editing multi-file C programs such as theoperating system. There is a program called \fBctags\fR which willgenerate an appropriate \fBtags\fR file for C and f77programs so that by saying\fB:ta function<nl>\fR you will be switched to that function.It could also be useful when editing multi-file documents, though the\fBtags\fR file would have to be generated manually..LE.NH 1Special Arrangements for Startup.PP\fBVi\fR takes the value of \fB$TERM\fR and looks up the characteristicsof that terminal in the file \fB/etc/termcap\fR.If you don't know \fBvi\fR's name for the terminal you are workingon, look in \fB/etc/termcap\fR..PPWhen \fBvi\fR starts, it attempts to read the variable EXINITfrom your environment.*If that exists, it takes the values in it as the default valuesfor certain of its internal constants. See the section on "Set Values"for further details.If EXINIT doesn't exist you will get all the normal defaults..FS* On version 6 systemsInstead of EXINIT, put the startup commands in the file .exrcin your home directory..FE.PPShould you inadvertently hang up the phone while inside.B vi ,or should the computer crash,all may not be lost.Upon returning to the system, type:.DSvi \-r file.DEThis will normally recover the file. If there is more than onetemporary file for a specific file name, \fBvi\fR recovers thenewest one. You can get an older version by recovering thefile more than once.The command "vi -r" without a file name gives you the list of filesthat were saved in the last system crash(but.I notthe file just saved when the phone was hung up)..NH 1Set Commands.LP\fBVi\fR has a number of internal variables and switches which can beset to achieve special affects.These options come in three forms, those that are switches, which togglefrom off to on and back, those that require a numeric value, and thosethat require an alphanumeric string value.The toggle options are set by a command of the form:.DS:set option<nl>.DEand turned off with the command:.DS:set nooption<nl>.DECommands requiring a value are set with a command of the form:.DS:set option=value<nl>.DETo display the value of a specific option type:.DS:set option?<nl>.DETo display only those that you have changed type:.DS:set<nl>.DEand to display the long table of all the settable parameters andtheir current values type:.DS:set all<nl>.DE.PPMost of the options have a long form and an abbreviation. Both arelisted in the following table as well as the normal default value..PPTo arrange to have values other than the default used every time youenter.B vi ,place the appropriate.B setcommand in EXINIT in your environment, e.g..DSEXINIT='set ai aw terse sh=/bin/csh'export EXINIT.DEor.DSsetenv EXINIT 'set ai aw terse sh=/bin/csh'.DEfor.B shand.B csh ,respectively.These are usually placed in your .profile or .login.If you are running a system without environments (such as version 6)you can place the set command in the file .exrc in your homedirectory..VL 16.IP autoindent\ ai 16Default: noai Type: toggle.brWhen in autoindent mode, vi helps you indent code by starting eachline in the same column as the preceding line.Tabbing to the right with <tab> or <^T> will move this boundary tothe right, and it can be moved to the left with <^D>..IP autoprint\ ap 16Default: ap Type: toggle.brCauses the current line to be printed after each ex text modifying command.This is not of much interest in the normal \fBvi\fR visual mode..IP autowrite\ aw 16Default: noaw type: toggle.brAutowrite causes an automatic write to be done if there are unsavedchanges before certain commands which change files or otherwiseinteract with the outside world.These commands are :!, :tag, :next, :rewind, ^^, and ^]..IP beautify\ bf 16Default: nobf Type: toggle.brCauses all control characters except <tab>, <nl>, and <ff> to be discarded..IP directory\ dir 16Default: dir=/tmp Type: string.brThis is the directory in which \fBvi\fR puts its temporary file..IP errorbells\ eb 16Default: noeb Type: toggle.brError messages are preceded by a <bell>..IP hardtabs\ ht 16Default: hardtabs=8 Type: numeric.brThis option contains the value of hardware tabs in your terminal, orof software tabs expanded by the Unix system..IP ignorecase\ ic 16Default: noic Type: toggle.brAll upper case characters are mapped to lower case in regular expressionmatching..IP lisp 16Default: nolisp Type: toggle.brAutoindent for \fBlisp\fR code. The commands \fB( ) [[\fR and \fB]]\fRare modified appropriately to affect s-expressions and functions..IP list 16Default: nolist Type: toggle.brAll printed lines have the <tab> and <nl> characters displayed visually..IP magic 16Default: magic Type: toggle.brEnable the metacharacters for matching. These include \fB. * < > [string][^string]\fR and \fB[<chr>-<chr>]\fR..IP number\ nu 16Default: nonu Type: toggle.brEach line is displayed with its line number..IP open 16Default: open Type: toggle.brWhen set, prevents entering open or visual modes from ex or edit.Not of interest from vi..IP optimize\ opt 16Default: opt Type: toggle.brBasically of use only when using the \fBex\fR capabilities. Thisoption prevents automatic <cr>s from taking place,and speeds up output of indented lines,at the expense of losing typeahead on some versions of UNIX..IP paragraphs\ para 16Default: para=IPLPPPQPP\ bp Type: string.brEach pair of characters in the string indicate \fBnroff\fR macroswhich are to be treated as the beginning of a paragraph for the\fB{\fR and \fB}\fR commands. The default string is for the \fB-ms\fRand \fB-mm\fR macros.To indicate one letter \fBnroff\fR macros, such as \fB.P\fR or \fB.H\fR,quote a space in for the second character position. For example:.sp 1.ti +8:set paragraphs=P\e bp<nl>.sp 1would cause \fBvi\fR to consider \fB.P\fR and \fB.bp\fR as paragraphdelimiters..IP prompt 16Default: prompt Type: toggle.brIn.B excommand mode the prompt character \fB:\fR will be printed when\fBex\fR is waiting for a command. This is not of interest from vi..IP redraw 16Default: noredraw Type: toggle.brOn dumb terminals, force the screen to always be up to date,by sending great amounts of output. Useful only at high speeds..IP report 16Default: report=5 Type: numeric.brThis sets the threshold for the number of lines modified. Whenmore than this number of lines are modified, removed, or yanked,\fBvi\fR will report the number of lines changed at the bottom ofthe screen..IP scroll 16Default: scroll={1/2 window} Type: numeric.brThis is the number of lines that the screen scrolls up or down whenusing the <^U> and <^D> commands..IP sections 16Default: sections=SHNHH HU Type: string.brEach two character pair of this string specify \fBnroff\fR macro nameswhich are to be treated as the beginning of a section by the\fB]]\fR and \fB[[\fR commands. The default string is for the \fB-ms\fRand \fB-mm\fR macros.To enter one letter \fBnroff\fR macros, use a quoted space as thesecond character.See \fBparagraphs\fR for a fuller explanation..IP shell\ sh 16Default: sh=from environment SHELL or /bin/sh Type: string.brThis is the name of the \fBsh\fR to be used for "escaped" commands..IP shiftwidth\ sw 16Default: sw=8 Type: numeric.brThis is the number of spaces that a <^T> or <^D> will move over forindenting, and the amount < and > shift by..IP showmatch\ sm 16Default: nosm Type: toggle.brWhen a \fB)\fR or \fB}\fR is typed, show the matching \fB(\fR or \fB{\fRby moving the cursor to it for one second if it is on the current screen..IP slowopen\ slow 16Default: terminal dependent Type: toggle.brOn terminals that are slow and unintelligent, this option prevents theupdating of the screen some of the time to improve speed..IP tabstop\ ts 16Default: ts=8 Type: numeric.br<tab>s are expanded to boundaries that are multiples of this value..IP taglength\ tl 16Default: tl=0 Type: numeric.brIf nonzero, tag names are only significant to this many characters..IP term 16Default: (from environment \fBTERM\fP, else dumb) Type: string.brThis is the terminal and controls the visual displays. It cannot bechanged when in "visual" mode,you have to Q to command mode, type aset term command, and do ``vi.'' to get back into visual.Or exit vi, fix $TERM, and reenter.The definitions that drive a particularterminal type are found in the file \fB/etc/termcap\fR..IP terse 16Default: terse Type: toggle.brWhen set, the error diagnostics are short..IP warn 16Default: warn Type: toggle.brThe user is warned if she/he tries to escape tothe shell without writing out the current changes..IP window 16Default: window={8 at 600 baud or less, 16 at 1200 baud, and screensize \- 1 at 2400 baud or more} Type: numeric.brThis is the number of lines in the window whenever \fBvi\fR must redrawan entire screen. It is useful to make this size smaller if you areon a slow line..IP w300,\ w1200,\ w9600.brThese set window, but only within the corresponding speed ranges.They are useful in an EXINIT to fine tune window sizes.For example,.DSset w300=4 w1200=12.DEcauses a 4 lines window at speed up to 600 baud, a 12 line window at 1200baud, and a full screen (the default) at over 1200 baud..IP wrapscan\ ws 16Default: ws Type: toggle.brSearches will wrap around the end of the file when is option is set. Whenit is off, the search will terminate when it reaches the end or thebeginning of the file..IP wrapmargin\ wm 16Default: wm=0 Type: numeric.br\fBVi\fR will automatically insert a <nl> when it finds a naturalbreak point (usually a <sp> between words) that occurs within"wm" spaces of the right margin.Therefore with "wm=0" the option is off. Setting it to 10 wouldmean that any time you are within 10 spaces of the right margin\fBvi\fR would be looking for a <sp> or <tab> which it couldreplace with a <nl>. This is convenient for people who forgetto look at the screen while they type.(In version 3, wrapmargin behaves more like nroff, in that theboundary specified by the distance from the right edge of the screenis taken as the rightmost edge of the area where a break is allowed,instead of the leftmost edge.).IP writeany\ wa 16Default: nowa Type: toggle.br\fBVi\fR normally makes a number of checks before it writes out a file.This prevents the user from inadvertently destroying a file. When the"writeany" option is enabled, \fBvi\fR no longer makes these checks..LE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -