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

📄 vi.in

📁 早期freebsd实现
💻 IN
📖 第 1 页 / 共 5 页
字号:
is incorrect, you can replace it with the correct character by givingthe command \fBr\fR\fIc\fR,where \fIc\fR is replaced by the correct character.Finally if the character which is incorrect should be replacedby more than one character, give the command \fBs\fR which substitutesa string of characters, ending with \s-2ESC\s0, for it.If there are a small number of characterswhich are wrong you can precede \fBs\fR with a count of the number ofcharacters to be replaced.  Counts are also useful with \fBx\fR to specifythe number of characters to be deleted..NH 2More corrections: operators.PPYou already know almost enough to make changes at a higher level.All you need to know now is that the .B dkey acts as a delete operator.  Try the command.B dwto delete a word.Try hitting \fB.\fR a few times.  Notice that this repeats the effectof the \fBdw\fR.  The command \fB.\fR repeats the last command whichmade a change.  You can remember it by analogy with an ellipsis `\fB...\fR'..PPNow try\fBdb\fR.This deletes a word backwards, namely the preceding word.Try \fBd\fR\s-2SPACE\s0.  This deletes a single character, and is equivalentto the \fBx\fR command..PPAnother very useful operator is.B cor change.  The command .B cwthus changes the text of a single word.You follow it by the replacement text ending with an \s-2ESC\s0.Find a word which you can change to another, and try thisnow.Notice that the end of the text to be changed was marked with the character`$' so that you can see this as you are typing in the new material..NH 2Operating on lines.PPIt is often the case that you want to operate on lines.Find a line which you want to delete, and type \fBdd\fR,the.B doperator twice.  This will delete the line.If you are on a dumb terminal, the editor may just erase the line onthe screen, replacing it with a line with only an @ on it.  This linedoes not correspond to any line in your file, but only acts as a placeholder.  It helps to avoid a lengthy redraw of the rest of the screenwhich would be necessary to close up the hole created by the deletionon a terminal without a delete line capability..PPTry repeating the.B coperator twice; this will change a whole line, erasing its previous contents andreplacing them with text you type up to an \s-2ESC\s0.\*(dg.FS\*(dg The command \fBS\fR is a convenient synonym for for \fBcc\fR, byanalogy with \fBs\fR.  Think of \fBS\fR as a substitute on lines, while\fBs\fR is a substitute on characters..FE.PPYou can delete or change more than one line by preceding the.B ddor.B ccwith a count, i.e. \fB5dd\fR deletes 5 lines.You can also give a command like \fBdL\fR to delete all the lines up toand includingthe last line on the screen, or \fBd3L\fR to delete through the third fromthe bottom line.  Try some commands like this now.*.FS* One subtle point here involves using the \fB/\fR search after a \fBd\fR.This will normally delete characters from the current position to thepoint of the match.  If what is desired is to delete whole linesincluding the two points, give the pattern as \fB/pat/+0\fR, a line address..FENotice that the editor lets you know when you change a large number oflines so that you can see the extent of the change.The editor will also always tell you when a change you make affects text whichyou cannot see..NH 2Undoing.PPNow suppose that the last change which you made was incorrect;you could use the insert, delete and append commands to put the correctmaterial back.  However, since it is often the case that we regret achange or make a change incorrectly, the editor provides a.B u(undo) command to reverse the last change which you made.Try this a few times, and give it twice in a row to notice that an.B ualso undoes a.B u..PPThe undo command lets you reverse only a single change.  After you makea number of changes to a line, you may decide that you would rather havethe original state of the line back.  The.B Ucommand restores the current line to the state before you started changingit..PPYou can recover text which you delete, even ifundo will not bring it back; see the section on recovering lost textbelow..NH 2Summary.IP.TSlw(.50i)b a.\fR\s-2SPACE\s0\fP	advance the cursor one position^H	backspace the cursor^W	erase a word during an insert\fRerase\fP	your erase (usually ^H or #), erases a character during an insert\fRkill\fP	your kill (usually @, ^X, or ^U), kills the insert on this line\&\fB.\fP	repeats the changing commandO	opens and inputs new lines, above the currentU	undoes the changes you made to the current linea	appends text after the cursorc	changes the object you specify to the following textd	deletes the object you specifyi	inserts text before the cursoro	opens and inputs new lines, below the currentu	undoes the last change.TE.NH 1Moving about; rearranging and duplicating text.NH 2Low level character motions.PPNow move the cursor to a line where there is a punctuation or a bracketingcharacter such as a parenthesis or a comma or period.  Try the command\fBf\fR\fIx\fR where \fIx\fR is this character.  This command findsthe next \fIx\fR character to the right of the cursor in the currentline.  Try then hitting a \fB;\fR, which finds the next instance of thesame character.  By using the \fBf\fR command and then a sequence of\fB;\fR's you can oftenget to a particular place in a line much faster than with a sequenceof word motions or \s-2SPACE\s0s.There is also a \fBF\fR command, which is like \fBf\fR, but searches backward.  The \fB;\fR command repeats \fBF\fR also..PPWhen you are operating on the text in a line it is often desirable todeal with the characters up to, but not including, the first instance ofa character.  Try \fBdf\fR\fIx\fR for some \fIx\fR now andnotice that the \fIx\fR character is deleted.  Undo this with \fBu\fRand then try \fBdt\fR\fIx\fR;  the \fBt\fR here stands for to, i.e.delete up to the next \fIx\fR, but not the \fIx\fR.  The command \fBT\fRis the reverse of \fBt\fR..PPWhen working with the text of a single line, an \fB\(ua\fR moves thecursor to the first non-white position on the line, and a\fB$\fR moves it to the end of the line.  Thus \fB$a\fR will append newtext at the end of the current line..PPYour file may have tab (\fB^I\fR) characters in it.  Thesecharacters are represented as a number of spaces expanding to a tab stop,where tab stops are every 8 positions.*.FS* This is settable by a command of the form \fB:se ts=\fR\fIx\fR\s-2CR\s0,where \fIx\fR is 4 to set tabstops every four columns.  This haseffect on the screen representation within the editor..FEWhen the cursor is at a tab, it sits on the last of the several spaceswhich represent that tab.  Try moving the cursor back and forth overtabs so you understand how this works..PPOn rare occasions, your file may have nonprinting characters in it. These characters are displayed in the same way they are represented inthis document, that is with a two character code, the first characterof which is `^'.  On the screen non-printing characters resemble a `^'character adjacent to another, but spacing or backspacing over the characterwill reveal that the two characters are, like the spaces representinga tab character, a single character..PPThe editor sometimes discards control characters,depending on the character and the setting of the.I beautifyoption,if you attempt to insert them in your file.You can get a control character in the file by beginningan insert and then typing a \fB^V\fR before the controlcharacter.  The\fB^V\fR quotes the following character, causing it to beinserted directly into the file..PP.NH 2Higher level text objects.PPIn working with a document it is often advantageous to work in termsof sentences, paragraphs, and sections.  The operations \fB(\fR and \fB)\fRmove to the beginning of the previous and next sentences respectively.Thus the command \fBd)\fR will delete the rest of the current sentence;likewise \fBd(\fR will delete the previous sentence if you are at thebeginning of the current sentence, or the current sentence up to whereyou are if you are not at the beginning of the current sentence..PPA sentence is defined to end at a `.', `!' or `?' which is followed byeither the end of a line, or by two spaces.  Any number of closing `)',`]', `"' and `\(aa' characters may appear after the `.', `!' or `?' beforethe spaces or end of line..PPThe operations \fB{\fR and \fB}\fR move over paragraphs and the operations\fB[[\fR and \fB]]\fR move over sections.\*(dg.FS\*(dg The \fB[[\fR and \fB]]\fR operationsrequire the operation character to be doubled because they can move thecursor far from where it currently is.  While it is easy to get backwith the command \fB\(ga\(ga\fP,these commands would still be frustratingif they were easy to hit accidentally..FE.PPA paragraph begins after each empty line, and alsoat each of a set of paragraph macros, specified by the pairs of charactersin the definition of the string valued option \fIparagraphs\fR.The default setting for this option defines the paragraph macros of the\fI\-ms\fR and \fI\-mm\fR macro packages, i.e. the `.IP', `.LP', `.PP'and `.QP', `.P' and `.LI' macros.\*(dd.FS\*(dd You can easily change or extend this set of macros by assigning adifferent string to the \fIparagraphs\fR option in your EXINIT.See section 6.2 for details.The `.bp' directive is also considered to start a paragraph..FEEach paragraph boundary is also a sentence boundary.  The sentenceand paragraph commands canbe given counts to operate over groups of sentences and paragraphs..PPSections in the editor begin after each macro in the \fIsections\fR option,normally `.NH', `.SH', `.H' and `.HU', and each line with a formfeed \fB^L\fRin the first column.Section boundaries are always line and paragraph boundaries also..PPTry experimenting with the sentence and paragraph commands until you aresure how they work.  If you have a large document, try looking throughit using the section commands.The section commands interpret a preceding count as a different window size inwhich to redraw the screen at the new location, and this window sizeis the base size for newly drawn windows until another size is specified.This is very usefulif you are on a slow terminal and are looking for a particular section. You can give the first section command a small count to then see each successivesection heading in a small window..NH 2Rearranging and duplicating text.PPThe editor has a single unnamed buffer where the last deleted orchanged away text is saved, and a set of named buffers \fBa\fR\-\fBz\fRwhich you can use to save copies of text and to move text around inyour file and between files..PPThe operator.B yyanks a copy of the object which follows into the unnamed buffer.If preceded by a buffer name, \fB"\fR\fIx\fR\|\fBy\fR, where\fIx\fR here is replaced by a letter \fBa\-z\fR, it places the text in the namedbuffer.  The text can then be put back in the file with the commands.B pand.B P;\fBp\fR puts the text after or below the cursor, while \fBP\fR puts the textbefore or above the cursor..PPIf the text which youyank forms a part of a line, or is an object such as a sentence whichpartially spans more than one line, then when you put the text back,it will be placed after the cursor (or before if youuse \fBP\fR).  If the yanked text forms whole lines, they will be putback as whole lines, without changing the current line.  In this case,the put acts much like a \fBo\fR or \fBO\fR command..PPTry the command \fBYP\fR.  This makes a copy of the current line andleaves you on this copy, which is placed before the current line.The command \fBY\fR is a convenient abbreviation for \fByy\fR.The command \fBYp\fR will also make a copy of the current line, and placeit after the current line.  You can give \fBY\fR a count of lines toyank, and thus duplicate several lines; try \fB3YP\fR..PPTo move text within the buffer, you need to delete it in one place, andput it back in another.  You can precede a delete operation by thename of a buffer in which the text is to be stored as in \fB"a5dd\fRdeleting 5 lines into the named buffer \fIa\fR.  You can then move thecursor to the eventual resting place of the these lines and do a \fB"ap\fRor \fB"aP\fR to put them back.In fact, you can switch and edit another file before you put the linesback, by giving a command of the form \fB:e \fR\fIname\fR\s-2CR\s0 where\fIname\fR is the name of the other file you want to edit.  You willhave to write back the contents of the current editor buffer (or discardthem) if you have made changes before the editor will let you switchto the other file.An ordinary delete command saves the text in the unnamed buffer,so that an ordinary put can move it elsewhere.However, the unnamed buffer is lost when you change files,so to move text from one file to another you should use an unnamed buffer..NH 2Summary..IP.TSlw(.50i)b a.\(ua	first non-white on line$	end of line)	forward sentence}	forward paragraph]]	forward section(	backward sentence{	backward paragraph[[	backward sectionf\fIx\fR	find \fIx\fR forward in linep	put text back, after cursor or below current liney	yank operator, for copies and movest\fIx\fR	up to \fIx\fR forward, for operatorsF\fIx\fR	f backward in lineP	put text back, before cursor or above current lineT\fIx\fR	t backward in line.TE.NH 1High level commands.NH 2Writing, quitting, editing new files.PPSo far we have seen how to enter.I viand to write out our file using either\fBZZ\fR or \fB:w\fR\s-2CR\s0. The first exits fromthe editor,(writing if changes were made),the second writes and stays in the editor..PPIf you have changed the editor's copy of the file but do not wish tosave your changes, either because you messed up the file or decided that thechanges are not an improvement to the file, then you can give the command\fB:q!\fR\s-2CR\s0 to quit from the editor without writing the changes.You can also reedit the same file (starting over) by giving the command\fB:e!\fR\s-2CR\s0.  These commands should be used only rarely, and withcaution, as it is not possible to recover the changes you have made afteryou discard them in this manner.

⌨️ 快捷键说明

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