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

📄 vi.apwh.ms

📁 早期freebsd实现
💻 MS
📖 第 1 页 / 共 3 页
字号:
in the file and the character "<a-z>" becomes the label for referringto this location in the file.  See the next two commands.  Mnemonic:\fBm\fRark.B NOTE:The mark command is not a motion, and cannot be used as the targetof commands such as delete..IP "\(aa<a-z>" 16Move the cursor to the beginning of the line that is marked with the label"<a-z>"..IP "\(ga<a-z>" 16Move the cursor to the exact position on the line that was marked withwith the label "<a-z>"..IP "\(aa\(aa" 16Move the cursor back to the beginning of the line where it was before thelast "non-relative" move.  A "non-relative" move is something such as asearch or a jump to a specific line in the file, rather than moving thecursor or scrolling the screen..IP "\(ga\(ga" 16Move the cursor back to the exact spot on the line where it was locatedbefore the last "non-relative" move..LE.NH 2Searches.LPThe following commands allow you to search for items in a file..VL 16.IP [cnt]f{chr} 16.sp 1Search forward on the line for the next or "cnt"'th occurrence ofthe character "chr".  The cursor is placed \fBat\fR the characterof interest.  Mnemonic: \fBf\fRind character.IP [cnt]F{chr} 16.sp 1Search backwards on the line for the next or "cnt"'th occurrence ofthe character "chr".  The cursor is placed \fBat\fR the characterof interest..IP [cnt]t{chr} 16.sp 1Search forward on the line for the next or "cnt"'th occurrence ofthe character "chr".  The cursor is placed \fBjust preceding\fRthe character of interest.  Mnemonic: move cursor up \fBt\fRo character.IP [cnt]T{chr} 16.sp 1Search backwards on the line for the next or "cnt"'th occurrence ofthe character "chr".  The cursor is placed \fBjust preceding\fRthe character of interest..IP "[cnt];" 16Repeat the last "f", "F", "t" or "T" command..IP "[cnt]," 16Repeat the last "f", "F", "t" or "T" command, but in the oppositesearch direction.  This is useful if you overshoot..IP "[cnt]/[string]/<nl>" 16.brSearch forward for the next occurrence of "string".Wrap around at the end of the filedoes occur.The final \fB</>\fR is not required..IP "[cnt]?[string]?<nl>" 16.brSearch backwards for the next occurrence of "string".  If a count isspecified, the count becomes the new window size.  Wrap around at the beginningof the file does occur.The final \fB<?>\fR is not required..IP n 16Repeat the last /[string]/ or ?[string]? search.  Mnemonic: \fBn\fRextoccurrence..IP N 16Repeat the last /[string]/ or ?[string]? search, but in the reversedirection..IP ":g/[string]/[editor command]<nl>" 16.sp 1Using the \fB:\fR syntax it is possible to do global searches ala thestandard UNIX "ed" editor..LE.NH 2Text Insertion.LPThe following commands allow for the insertion of text.  All multicharactertext insertions are terminated with an <esc> character.The last changecan always be \fBundone\fR by typing a \fBu\fR.The text insert in insertion mode can contain newlines..VL 16.IP a{text}<esc> 16Insert text immediately following the cursor position.Mnemonic: \fBa\fRppend.IP A{text}<esc> 16Insert text at the end of the current line.Mnemonic: \fBA\fRppend.IP i{text}<esc> 16Insert text immediately preceding the cursor position.Mnemonic: \fBi\fRnsert.IP I{text}<esc> 16Insert text at the beginning of the current line..IP o{text}<esc> 16Insert a new line after the line on which the cursor appears andinsert text there.  Mnemonic:  \fBo\fRpen new line.IP O{text}<esc> 16Insert a new line preceding the line on which the cursor appearsand insert text there..LE.NH 2Text Deletion.LPThe following commands allow the user to delete text in various ways.All changes can always be \fBundone\fR by typing the \fBu\fR command..VL 16.IP "[cnt]x" 16Delete the character or characters starting at the cursor position..IP "[cnt]X" 16Delete the character or characters starting at the character precedingthe cursor position..IP "D" 16Deletes the remainder of the line starting at the cursor.Mnemonic: \fBD\fRelete the rest of line.IP "[cnt]d{motion}" 16.brDeletes one or more occurrences of the specified motion.Any motion from sections 4.1 and 4.2 can be used here.The d can be stuttered (e.g. [cnt]dd) to delete cnt lines..LE.NH 2Text Replacement.LPThe following commands allow the user to simultaneously delete andinsert new text.  All such actions can be \fBundone\fR by typing\fBu\fR following the command..VL 16.IP "r<chr>" 16Replaces the character at the current cursor position with <chr>.  Thisis a one character replacement.  No <esc> is required for termination.Mnemonic:  \fBr\fReplace character.IP "R{text}<esc>" 16Starts overlaying the characters on the screen with whatever you type.It does not stop until an <esc> is typed..IP "[cnt]s{text}<esc>" 16Substitute for "cnt" characters beginning at the current cursorposition.  A "$" will appear at the position in the text where the"cnt"'th character appears so you will know how much you are erasing.Mnemonic: \fBs\fRubstitute.IP "[cnt]S{text}<esc>" 16Substitute for the entire current line (or lines).  If no count is given,a "$" appears at the end of the current line.  If a count of more than1 is given, all the lines to be replaced are deleted before the insertionbegins..IP "[cnt]c{motion}{text}<esc>" 16.brChange the specified "motion" by replacing it with theinsertion text.  A "$" will appear at the end of the last itemthat is being deleted unless the deletion involves whole lines.Motion's can be any motion from sections 4.1 or 4.2.Stuttering the c (e.g. [cnt]cc) changes cnt lines..LE.NH 2Moving Text.LP\fBVi\fR provides a number of ways of moving chunks of text around.There are nine buffers into which each piece of text which is deletedor "yanked" is put in addition to the "undo" buffer.The most recent deletion or yank is in the "undo" buffer and alsousually in buffer1, the next most recent in buffer 2, and so forth.  Each new deletionpushes down all the older deletions.  Deletions older than 9disappear.  There is alsoa set of named registers, a-z, into which text can optionallybe placed.  If any delete or replacement type command is precededby \fB"<a-z>\fR, that named buffer will contain the text deletedafter the command is executed.  For example, \fB"a3dd\fR will deletethree lines starting at the current line and put them in buffer \fB"a\fR.*.FS* Referring to an upper case letter as a buffer name (A-Z) is thesame as referring to the lower case letter, except that text placedin such a buffer is appended to it instead of replacing it..FEThere are two more basic commands andsome variations useful in getting and putting text into a file..VL 16.IP ["<a-z>][cnt]y{motion} 16.sp 1Yank the specified item or "cnt" items and put in the "undo" buffer orthe specified buffer.  The variety of "items" that can be yankedis the same as those that can be deleted with the "d" command orchanged with the "c" command.  In the same way that "dd" meansdelete the current line and "cc" means replace the current line,"yy" means yank the current line..IP ["<a-z>][cnt]Y 16Yank the current line or the "cnt" lines starting from the currentline.  If no buffer is specified, they will go into the "undo" buffer,like any delete would.  It is equivalent to "yy".Mnemonic:  \fBY\fRank.IP ["<a-z>]p 16Put "undo" buffer or the specified buffer down \fBafter\fR the cursor.If whole lines were yanked or deleted into the buffer, then they will beput down on the line following the line the cursor is on.  Ifsomething else was deleted, like a word or sentence, then it willbe inserted immediately following the cursor.Mnemonic:  \fBp\fRut buffer.IPIt should be noted that text in the named buffers remains there when youstart editing a new file with the \fB:e file<esc>\fR command.  Sincethis is so, it is possible to copy or delete text from one file andcarry it over to another file in the buffers.However, the undo buffer and the ability to undo are lost whenchanging files..IP ["<a-z>]P 16Put "undo" buffer or the specified buffer down \fBbefore\fR the cursor.If whole lines where yanked or deleted into the buffer, then they will beput down on the line preceding the line the cursor is on.  Ifsomething else was deleted, like a word or sentence, then it willbe inserted immediately preceding the cursor..IP [cnt]>{motion} 16The shift operator will right shift all the text from the line on whichthe cursor is located to the line where the \fBmotion\fR is located.The text is shifted by one \fBshiftwidth\fR.  (See section 6.)\fB>>\fR means right shift the current line or lines..IP [cnt]<{motion} 16The shift operator will left shift all the text from the line on whichthe cursor is located to the line where the \fBitem\fR is located.The text is shifted by one \fBshiftwidth\fR.  (See section 6.)\fB<<\fR means left shift the current line or lines.Once the line has reached the left margin it is not further affected..IP [cnt]={motion} 16Prettyprints the indicated area according to.B lispconventions.The area should be a lisp s-expression..LE.NH 2Miscellaneous Commands.LP\fBVi\fR has a number of miscellaneous commands that are veryuseful.  They are:.VL 16.IP ZZ 16This is the normal way to exit from vi.If any changes have been made, the file is written out.Then you are returned to the shell..IP ^L 16Redraw the current screen.  This is useful if someone "write"s youwhile you are in "vi" or if for any reason garbage gets onto thescreen..IP ^R 16On dumb terminals, those not having the "delete line" function(the vt100 is such a terminal), \fBvi\fR saves redrawing thescreen when you delete a line by just marking the line with an"@" at the beginning and blanking the line.  If you want toactually get rid of the lines marked with "@" and see what thepage looks like, typing a ^R will do this..IP \s+4.\s0 16"Dot" is a particularly useful command.  It repeats the lasttext modifying command.  Therefore you can type a command once andthen to another place and repeat it by just typing "."..IP u 16Perhaps the most important command in the editor,u undoes the last command that changed the buffer.Mnemonic:  \fBu\fRndo.IP U 16Undo all the text modifying commands performed on the current linesince the last time you moved onto it..IP [cnt]J 16Join the current line and the following line.  The <nl> is deletedand the two lines joined, usually with a space between theend of the first line and the beginning of what was the secondline.  If the first line ended with a "period", then two spacesare inserted.A count joins the next cnt lines.Mnemonic: \fBJ\fRoin lines.IP Q 16Switch to \fBex\fR editing mode.In this mode \fBvi\fR will behave very much like \fBed\fR.The editor in this mode will operate on single lines normally andwill not attempt to keep the "window" up to date.Once in this mode it is also possible to switch to the \fBopen\fRmode of editing.  By entering the command \fB[line number]open<nl>\fRyou enter this mode.  It is similar to the normal visual modeexcept the window is only \fBone\fR line long.Mnemonic: \fBQ\fRuit visual mode.IP ^] 16An abbreviation for a tag command.The cursor should be positioned at the beginning of a word.That word is taken as a tag name, and the tag with thatname is found as if it had been typed in a :tag command..IP [cnt]!{motion}{UNIX\ cmd}<nl> 16.brAny UNIX filter(e.g. command that reads the standard input and outputs somethingto the standard output) can be sent a section of the current file andhave the output of the command replace the original text.  Usefulexamples are programs like \fBcb\fR, \fBsort\fR, and\fBnroff\fR.  For instance, using \fBsort\fR it would be possible tosort a section of the current file into a new list.Using \fB!!\fR means take a line or lines starting at the line thecursor is currently on and pass them to the UNIX command..B NOTE:To just escape to the shell for one command,use :!{cmd}<nl>, see section 5..IP z{cnt}<nl> 16This resets the current window size to "cnt" lines and redraws the screen..LE.NH 2Special Insert Characters.LPThere are some characters that have special meanings duringinsert modes.  They are:.VL 16.IP ^V 16During inserts, typing a ^V allows you to quote control charactersinto the file.  Any character typed after the ^V will be insertedinto the file..IP [^]^D\ or\ [0]^D 16<^D> without any argument backs up one \fBshiftwidth\fR.  This is necessaryto remove indentation that was inserted by the \fBautoindent\fR feature.^<^D> temporarily removes all the autoindentation, thus placing the cursorat the left margin.  On the next line, the previous indent level will berestored.  This is useful for putting "labels" at the left margin.0<^D> says remove all autoindents and stay that way.  Thus the cursormoves to the left margin and stays there on successive lines until<tab>'s are typed.  As with the <tab>, the <^D> is only effective beforeany other "non-autoindent" controlling characters are typed.Mnemonic: \fBD\fRelete a shiftwidth.IP ^W 16If the cursor is sitting on a word, <^W> moves the cursor back to the beginningof the word, thus erasing the word from the insert.Mnemonic: erase \fBW\fRord.IP <bs> 16The backspace always serves as an erase during insert modes in additionto your normal "erase" character.  To insert a <bs> into your file, usethe <^V> to quote it..LE.NH 1\fB:\fR Commands.LPTyping a ":" during command mode causes \fBvi\fR to put the cursor atthe bottom on the screen in preparation for a command.  In the":" mode, \fBvi\fR can be given most \fBed\fR commands.  It isalso from this mode that you exit from \fBvi\fR or switch to differentfiles.  All commands of this variety are terminated by a <nl>, <cr>,or <esc>..VL 16.IP ":w[!] [file]" 16Causes \fBvi\fR to write out the current text to the disk.  It iswritten to the file you are editing unless "file" is supplied.  If"file" is supplied, the write is directed to that file instead.  Ifthat file already exists, \fBvi\fR will not perform the write unlessthe "!" is supplied indicating you.I reallywant to destroy the older copy of the file..IP :q[!] 16Causes \fBvi\fR to exit.  If you have modified the file you arelooking at currently and haven't written it out, \fBvi\fR willrefuse to exit unless the "!" is supplied..IP ":e[!] [+[cmd]] [file]" 16.sp 1Start editing a new file called "file" or start editing the currentfile over again.  The command ":e!" says "ignore the changes I've madeto this file and start over from the beginning".  It is useful ifyou really mess up the file.  The optional "+" says instead of startingat the beginning, start at the "end", or,if "cmd" is supplied, execute "cmd" first.Useful cases of this are where cmd is "n" (any integer) which starts

⌨️ 快捷键说明

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