VI Editor User Guide
First, UNIX editor overview
The editor is one of the important tools using a computer. In various operating systems, the editor is an indispensable part. In the Unix and its similar IX operating system series, a range of EX editors, including EX, EDIT, ED, and VI for various users, including EX, EDIT, ED, and VI. The editor is now rarely used, and UNIX provides them is to consider the need to meet the needs of various users, especially certain end users.
Fortunately, UNIX provides a full-screen VI editor, which makes our work more relaxed. Many DOS users complain that the VI editor is not like Edit, such as Edit, because VI takes into account the needs of various users, does not use some universal editing keys (on each of the different terminals Definitions are different, and there is no such keys on some terminals). Instead, the method of switching is used, but this is just a habit, once you skilled VI, you will feel that it is also very easy. Although Vi uses a state switching method, the computer's hardware and operating system are varied, and there are few function keys on certain computers on keyboards! So don't you have some features? This problem is the same in the UNIX system, almost major computer vendors have their own UNIX systems, while VI's operating methods will also be inserted. Here we use the PC keyboard to illustrate the operation of the VI, but in the specific environment, you should pay attention to the corresponding information, this is worth noting.
Second, VI Getting Started
(1) entering VI
In the system prompt character (such as $, #), type VI
(2) two modes
As mentioned above, there are two modes: instruction mode and input mode. The button entered in the command mode will be processed as an instruction: if entered A, VI is considered to be inserted in the current location. In the input mode, VI processes the input button as inserted characters. Command mode Switch to the input mode Simply type the corresponding input command (such as A, a), and switch from the input mode to the instruction mode, you need to type the ESC button in the input mode, if you don't know what is now? Mode, you can press several [ESC], and the system is indicating that it is already in an instruction mode.
Pay: There is an instruction to enter the input mode:
Added (Append)
A: From the position of the cursor, new information is started, and the data after the cursor moves backwards with the new information.
A: Add information from the last place where the cursor is located.
Insert (Insert)
i: Inserting information from the position where the cursor is located, the data after the cursor moves backwards with the new information.
I: Insert the information from the first non-empty white font in the column where the cursor is located.
Start (Open)
o: Add a column and enter the input mode under the cursor.
O: Add a column above the column where the cursor is located and enters the input mode.
(3) Exit VI
Type: Q,: Q!,: Wq or: x (Note: Number), you will exit the VI. Where: WQ and: X is the deployment of the storage, and: q is directly exiting, and the vi will prompt you to save the file if the file already has a new change. At this time, you can use: w command to save the file. Use: Q to exit, or use: wq or: x command to exit, if you don't want to save after changing files, you need to use: Q! Command, this command will not save the file directly to exit the VI. (4) Basic editing
With the function keys on the typical keyboard, like the direction keys, [INSERT], [Delete], etc. Now you should already use VI to edit files. Of course, VI also provides other many features that make the text more convenient.
What is edited? It is generally considered to be new, modified, and deleted, even including blocking, copying, etc. of the text block. First introduce how the VI is deleted and modified. (Note: In the original concept of VI, the input and editing is two code. Editing is in the command mode, first using the command to move the cursor to locate the place where you want to edit, and then the instruction is edited.)
Delete commands with modifying files:
x: Delete the character in the cursor.
DD: Delete the column where the cursor is located.
r: Modify the character where the cursor is located, and then the character to be corrected.
R: Enter the replacement state, the new text will overwrite the original text 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 enter 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, you want to delete the character, press [Delete] directly. The insertion state and the replacement state can be used directly with [INSERT], and the editing instructions of any instruction mode are not used. However, as mentioned earlier, these instructions can be used per terminal, not just on the PC. The basic instructions of moving the cursor in the instruction mode are H, J, K, L. I want to come to you now you should also guess the direction of the PC directly using the PC, and whether it can be in the instruction mode or input mode. Many easier. Of course, the PC keyboard is also inadequate. There is a good use of instructions u to recover the deleted text, and the U command can restore all changes in the column where the cursor is located. This is the same as the [UNDO] button on some computers. Third, attachment: VI Detailed instruction table (1), basic editing instruction: new (APPEND)
A: From the position of the cursor, new information is started, and the data after the cursor moves backwards with the new information.
A: Add information from the last place where the cursor is located.
Insert (Insert)
i: Inserting information from the position where the cursor is located, the data after the cursor moves backwards with the new information.
I: Insert the information from the first non-empty white font in the column where the cursor is located.
Start (Open)
o: Add a column and enter the input mode under the cursor.
O: Add a column above the column where the cursor is located and enters the input mode.
x: Delete the character in the cursor.
DD: Delete the column where the cursor is located.
r: Modify the character where the cursor is located, and then the character to be corrected.
R: Enter the replacement state, the new text will overwrite the original text 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 enter the input mode.
(2), cursor movement instruction: Since many editing work is positioned by cursors, the VI provides many ways to move cursors, this is a few briefings to explain (these of course are instructions in instruction mode): Directive Function key 0 Move the front [home] $ [[[[[[[[[[ ] [F] Next [Ctrl] [u] to the upper page [Ctrl] [b] to top [PageUp]
The command description h moves to the first column M moving to the window M move to the intermediate column L of the window to move to the last column B moving to the window to move to the first letter W moving to the next word to move to the first letter of the previous word. The last letter of the next word ^ moves to the first non-empty white character in the column where the cursor is located
Instruction Description N- Dimensional movement to the first non-empty white font before the previous column plus the number can be specified to move to the above N column N plus mobile to the next column first non-empty white font front, plus Number can specify moving to the following N-column NG Directly with Digital N plus uppercase G Move to the N-column instruction Description FX moves to the right to X-character on the x-character to move to the X-character onto the X word Yuan Yun TX moved to the left to the X-character; with F & T, repeat it once, Take F & T, repeat / string to move to the right to move to the right place? String moves left to left Is there a String place n matches / &? Use, repeat N match / &? Use, reverse direction
Instructions Note N (the left parentheses moving to the sentence to the sentence are in front, the number can be specified to move N sentences forward moving N)! The three symbols define n) 移动 到 到 子The front plus numbers can specify back to move N sentences behind!.? Three symbols to define n { 左 括 括 移动 移动 移动 移动 最 前 是 是 是 是 是 列 是 是 是 列 是 是 是 是Before moving N paragraphs, the right front arc is moving to the next paragraph, and the number can be specified that the N paragraph paragraphs in the next paragraph is defined in the blank column between paragraphs.