VI is an extremely popular full-screen instrument editor in UNIX world, almost any unix machine
This software will be provided. Linux is of course, its VI is actually ELVIS (copyright issues), but they all
almost. After familiar with the paper under DOS, you may feel that VI is not easy to use; there is also developed on UNIX
Many updated, more useful instrument editors, but not necessarily installed on each UNIX machine.
Software. Therefore, the basic operation of learning VI is still good, so you have a heart in various machines.
VI basic concept
Unix provides a range of EX editors, including EX, EDIT, and VI. Relative to all screen editor, now
It may be difficult to imagine how to use EX, Edit, which has been used in this ranks (someone used DOS version 3.3.
Edlin? ). VI's original interest is "Visual", it is an editorial program that immediately reacts, that is,
To see the results of the operation immediately.
Also because VI is a full-screen editor, it must control what the entire terminal screen is displayed. Finally
There are many kinds of end-machine types, and the characteristics are not the same, so the VI is necessary to know which one is currently used.
Terminal. This is set by the TERM's environment variable, please check the shell used by setting the environment variable.
instruction of. (The response Unknow Terminal Type is responding unless the VI is executed, otherwise you can set it.)
As long as you perform VI, you can enter the editing environment of the VI. There is a rough thing for it before actual operation.
It's better to understand. VI has two modes, input mode, and instruction mode. Input mode is used to enter text
The instruction mode is an operational instruction used to download some of the arrangement files, archives, and leave VI, and the like. when
After performing VI, you will enter the command mode, and any of the characters entered at this time is considered to be instructions.
Enter and leave
To enter VI, you can type VI The file you want to edit or open a new file. After entering VI, the left side will have a wave symbol, and all the columns have This symbol represents this column is currently empty. To leave the VI, you can type: Q,: WQ instruction is Leave it again (pay attention to the colon). To switch to the command mode, use the [ESC] button, if not, now Is it in what model, you can press multiple [ESC], and you will send a beep to determine the entry instruction mode. VI input mode How do you enter your information? There are several instructions to enter the input mode: Added (Append) a starting new information from the position of the cursor, the data after the cursor moves backwards with the new information. A starts new information from the last place where the cursor is located. Insert (Insert) i From the front of the cursor, you start to insert the information, and the data after the cursor moves backwards with the new information. I starts inserting information from the first non-empty white font in the column of the cursor. Start (Open) o Add a column and enter the input mode under the column where the cursor is located. O Add a column above the column where the cursor is located and enters the input mode. Perhaps the text narrative looks a bit complicated, but as long as you actually do it, you can understand these ways. real It is important, especially if the computer is always try and verified. Tropic recommended to use it Don't just flexible K files, there is a half-time utility. (Note: This paragraph is nonsense.) VI basic editing With the function keys on the general keyboard, like the direction keys, [INSERT], [Delete], etc. Now you should already You can use VI to process text information. Of course, VI also provides many other features to make the text more convenient, interested, please continue. Let's go to the BCC before you continue. There are many labels, different hardware and operation systems. PC is not Just only IBM PC and its compatibility. In fact, including keyboard, terminal, etc. often have different regulations grid. What does this represent? In the editing software of the instrument, there will be such problems, and there are no specific functions on the keyboard of some computers! Then Is there some functions? This problem is the same on UNIX system, almost major computer manufacturers have themselves. The UNIX system, while the operation method of VI will also be a bit. We can use the PC's keyboard. Ming VI's operation, but still have to mention this problem. Delete and modification What is edited? Here we think that the new modification of the text and delete, even the movement of the text block, complex System, etc. Here first, how to make deletion and modification of VI first. (Note: In the original concept of VI, enter Editing is two code. Editing is in command mode, first using the command mobile cursor to position to edit The place before, then the instruction is edited. ) x Delete the cursor where the cursor is located. DD Deletes the column where the cursor is located. r modifies the cursor where the cursor is located, and then the character to be corrected. R Enter the substitution state, the new information will overwrite the original information until [ESC] is pressed back to the instruction mode. s Delete the cursor where the cursor is located and enter the input mode. S Delete the column where the cursor is located and enters the input mode. In fact, there is not so troublesome on the PC! Entering and editing can be done in the input mode. For example to delete In addition to the word element, press [Delete] directly. And the insertion state and the substitution state can be directly used [INSERT] For the editing instructions that do not use the instruction pattern. However, as mentioned earlier, these instructions are almost per unit. The terminal can be used instead of just in the PC. The basic instructions for moving cursors in the instruction mode are H, J, K, L. I want to come to everyone now I can guess as long as it is straight. The direction key of the PC can be used, and it can be in the instruction mode or input mode. Many easier. Of course, the PC keyboard is also inadequate. There is a good manual instruction u to recover the deleted information, and the U instruction You can recover all changes in the column where the cursor is located. This is the same as the [UNDO] button on some computers. VI advanced application I believe that I have a considerable understanding of VI now. Don't have any trouble for processing text. If it is happy Interesting to use the other features of VI to further simplify the operation process, continue to see. Mobile cursor Since many editing work is positioned by a cursor, VI provides many way of mobile cursors, this Several briefs to illustrate (these of course are instructions in the instruction mode): ┌ ----- ┬ ------------- ┬ ----- ┐ │ Directive │ Description │ Function Keys │ ├ ----- ┼ ------------- ┼ ----- ┤ │0 │ Move to the top of the cursor listed │ [Home] │ ├ ----- ┼ ------------- ┼ ----- ┤ │ $ │ Move to the last side of the column listed │ [end] │ ├ ----- ┼ ------------- ┼ ----- ┤ │ [Ctrl] [D] │ Upside Page │ │ ├ ----- ┼ ------------- ┼ ----- ┤ │ [Ctrl] [F] │ │ [PageDown] │ ├ ----- ┼ ------------- ┼ ----- ┤ │ [Ctrl] [u] │ Up to Page │ │├ ----- ┼ ------------- ┼ ----- ┤ │ [Ctrl] [B] │ 向 上 │ [PageUp] │ └ ----- ┴ ------------- ┴ ----- ┘ ┌ - ┬ ----------------- ┐ │ Directive │ Description │ ├ - ┼ ----------------- ┤ │H │ Move to the first column of the window │ ├ - ┼ ----------------- ┤ │M │ Move to the intermediate column of the window │ ├ - ┼ ----------------- ┤ │L │ Move to the last column of the window │ ├ - ┼ ----------------- ┤ │B │ Move the first letter │ Move to the next word │ ├ - ┼ ----------------- ┤ │W │ Move to the first letter of the previous word │ ├ - ┼ ----------------- ┤ │ Move to the last letter of the next word │ ├ - ┼ ----------------- ┤ │ ^ │ Move to the first non-empty-white character │ of the column where the cursor is located └ - ┴ ----------------- ┘ ┌ - ┬ ------------------- ┐ │ Directive │ Description │ ├ - ┼ ------------------- ┤ │N- │ 减 移动 移动 移动 移动 非 非 非 非 非 非 非 │ │ The front plus numbers can be specified to move to the above N columns │ ├ - ┼ ------------------- ┤ │N │ Plus Move to the next list of the first non-empty white character │ │ │ The front plus numbers can be specified to move to the following N columns │ ├ - ┼ ------------------- ┤ │NG │ Directly with Number N plus uppercase G moves to nth │ └ - ┴ ------------------- ┘ ┌ ---- ┬ --------------- ┐ │ Directive │ Description │ ├ ---- ┼ --------------- ┤ │FX │ Move to the right to X-character │ │FX │ Move left to X-RM to │ ├ ---- ┼ --------------- ┤ │TX │ move to the right to X-character before │ │TX │ Move left to X-character before │ ├ ---- ┼ --------------- ┤ │; │ Combined with F & T, repeat │ │, │ Combined with F & T, repeat │ ├ ---- ┼ --------------- ┤ │ / String │ Move to Right to String Place │ │? String │ Move left to the left to String Location │ ├ ---- ┼ --------------- ┤ │N │ Match / &? Use, repeat │ │N │ Match / &? Use, reverse direction │ └ ---- ┴ --------------- ┘ ┌ ---- ┬ ------------------- ┬ ---------- ┐ │ Directive │ Description │ Remarks │ ├ ---- ┼ ------------------ ┼ ---------- ┤ │N (│ 左 括 移动 移动 移动 │ │ The front plus the number can specify the forward N sentence │!.? Three symbols to define ││N) │ 移动 移动 移动 移动 前 前 前 前 前 前 │ │ A front plus numbers can specify backward Move N sentences │ │ │ ├ ---- ┼ ------------------ ┼ ---------- ┤ │N {│ The front │ of the left parentheses to the paragraph │ paragraph is │ │ │ A front plus numbers can specify a blank column defiance between paragraphs from the previous mobile N paragraph │ │N} │ The right front │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ A front plus numbers can specify backward mobile N paragraph │ │ │ └ ---- ┴ ------------------- ┴ ---------- ┘ Don't try to recite these instructions, otherwise the consequences are responsible. They look more and messy, in fact this is text The obstacle to the description of itself. Rethony again, actually use it as long as you can directly download these odds without the brain. The strange monster, far more than the death of the death, the model is much more. (Note: If you really don't want to delete information not my business. In addition, this paragraph is nonsense. ) Advanced editing instruction These editing instructions are very flexible, basically, constructed from instructions and scope. For example, DW is deleted Let D D (EletE) W (ORD) is deleted from the range W. The list of instructions are as follows: D Delete (Delete) Y replication (YANK) P Placement (PUT) C Modification (Change) The range can be the following: E Cursor location to the last letter of the word The first letter where the W cursor is positioned to the next word B Clap in the first letter to the previous word The last letter where the $ cursor is located in the list 0 Cursor location to the first letter to this column ) The first letter where the cursor is located to the next sentence (The first letter from the cursor is where the sentence is the first letter } The last letter where the cursor is positioned to the paragraph {Cursor location to the first letter to this paragraph To be honest, combined these instructions to edit the file with a little art atmosphere. Anyway, they offer more edits The ability of the text. It is worth noting that deletion and replication will put the contents of the specified range in the temporary area, Once you can use the instruction P to be applied to it else, this is a way VI used to process segment copying and movement. Some VI versions, such as the ELVIS used by Linux, can greatly simplify this 坨 directive. If you observe a little These editing instructions will find that the problem is actually a bit of a range, in fact, only four instructions. The command V is very easy to use, as long as the V key is pressed, the position where the cursor is located will be reversed, and then the cursor can be moved. Set the range, then the instructions are then edited directly. For the entire operation, VI additionally provides more convenient editing instructions. I have mentioned that the refers to deleting the entire text Let DD are one of them; CC can modify the entire text; and yy is copying the entire text; To delete the cursor to the column end all the text. Archive instruction The file instructions are mostly: start, and the editing directive is a bit different. For example, the instructions mentioned earlier are: Q. It is now briefly description as the end of this story: : Q End Editing (QUIT) Use: Q! Forced to leave if you don't want to archive. : W Archive (WRITE) Thereafter, you can add the file name to be archived. The file instruction can be combined, for example: WQ is that the arch will leave. ZZ function is: WQ is the same. It is also worth mentioning that the VI partial archive function. You can use: N, MW FileName to go to the specified filename of the ninthum to the rule of the ric column. The times are changing, the world is changing, Vi is also changing, but large In this way. Ok, I am willing to live a happy life with the princess since then.