Vi editor command (copy) I. Unix editor overview editor is one of the important tools for using computers. in various operating systems, editors are essential components. Unix and similar ix Operating System series provide a series... vi editor command (copy) I. Unix editor overview editor is one of the important tools for using computers. in various operating systems, editors are essential components. Unix and similar ix Operating System series provide a series of ex editors, including ex, edit, ed, and vi. ex, edit, and ed are all row editors, which are rarely used now. the reason Unix provides them is that they meet the needs of various users, especially some end users. Fortunately, Unix provides a full-screen Vi editor, which makes our work much easier. Many DOS users complain that the Vi editor is not as easy as the edit editor in DOS, because Vi takes into account the needs of various users, some general editing keys are not used (their definitions are different on different terminals, and they are not even used on some terminals ). The status switch method is used, but this is just a habit. once you use vi skillfully, you will think it is actually very useful. Although Vi uses the status switch method, there are a variety of computer hardware and operating systems, some computers do not have a few function keys on the keyboard! Isn't some functions unavailable? This problem is also the same in Unix systems. almost all major computer manufacturers have their own Unix systems, and the vi operation methods will also be somewhat different. Here we use a PC keyboard to describe vi operations, but in the specific environment also need to refer to the relevant information, this is worth noting. II. Vi entry (1). when entering vi, Type vi under the system prompt characters (such as $, #). <file name>, vi can automatically help you load the file to be edited or open a new file (if the file does not exist or the file name is missing ). After entering vi, a tilde sign will appear on the left side of the screen. if this symbol is at the beginning of a column, it indicates that this column is currently empty. (2) as described above, there are two modes in vi: command mode and input mode. In command mode, Keys entered are processed as commands. for example, if a is input, vi inserts a character at the current position. In the input mode, vi treats the input key as the inserted character. To switch from the command mode to the input mode, you only need to enter the corresponding input commands (such as a and A). to switch from the input mode to the command mode, you need to enter the ESC key in the input mode, if you do not know the current mode, you can press [ESC] several more times. if the system beeps, it indicates that it is in the command mode. Payment: an instruction that enters the input mode in command mode: new (append) a: adds data from the end of the cursor position, and the data after the cursor moves to the backend as the new data is added. A: add data at the bottom of the column where the cursor is located. Insert I: insert data from the front of the cursor. the data after the cursor is moved to the backend with the new data. I: insert data starting from the first non-blank character in the column where the cursor is located. Open o: Adds a column under the column where the cursor is located and enters the input mode. O: add a new column to the column where the cursor is located and enter the input mode. (3) exit vi. in command mode, type: q,: q !,: Wq or: x (note: No.), the vi will be exited. Where: wq and: x are stored and exited, while q is directly exited. if the file has a new change, vi will prompt you to save the file and the q command will also be invalid, in this case, you can use the w command to save the file and then use q to exit, or use the wq or x command to exit. if you do not want to save the changed file, you need to use: q! Command to exit vi without saving the file. (4) Basic editing works with function keys on the general keyboard, such as direction keys, [Insert], and [Delete]. now you can use vi to edit files. Of course, vi also provides many other functions to facilitate text processing. What is editing? It is generally regarded as the addition, modification and deletion of text, and even the moving and copying of text blocks. This section describes how to delete and modify vi. (Note: In the original concept of vi, input and editing are two things. Editing is performed in command mode. you can use the command to move the cursor to locate the place to be edited before editing the command .) Command for deleting and modifying a File: x: delete the character where the cursor is located. Dd: delete the column where the cursor is located. R: modify the character where the cursor is located and the character to be corrected after r. R: Enter the retrieval and replacement status. The new text will overwrite the original text until you press [ESC] to return to the command mode. S: delete the cursor character and enter the input mode. S: delete the column where the cursor is located and enter the input mode. Actually, there is no such trouble on PC! Both input and edit operations can be completed in input mode. For example, if you want to Delete a character, simply press [Delete. The Insert and replace statuses can be directly switched using [Insert], making it impossible to edit commands in any command mode. However, as mentioned above, these commands can be used on almost every terminal, rather than just on a PC. In command mode, the basic commands for moving the cursor are h, j, k, and l. I think you should be able to guess that you only need to use the direction keys of the PC, and you can use them either in the command mode or in the input mode. Not easy. Of course, the PC keyboard also has some shortcomings. The command u can be used to restore deleted text, while the command U can restore all changes in the column where the cursor is located. This is the same as the [Undo] button function on some computers. III. attachment: vi Detailed instruction table (1). basic editing instruction: append a: add information from the end of the cursor, the data after the cursor is moved to the backend with the new data. A: add data at the bottom of the column where the cursor is located. Insert I: insert data from the front of the cursor. the data after the cursor is moved to the backend with the new data. I: insert data starting from the first non-blank character in the column where the cursor is located. Open o: Adds a column under the column where the cursor is located and enters the input mode. O: add a new column to the column where the cursor is located and enter the input mode. X: delete the character of the cursor. Dd: delete the column where the cursor is located. R: modify the character where the cursor is located and the character to be corrected after r. R: Enter the retrieval and replacement status. The new text will overwrite the original text until you press [ESC] to return to the command mode. S: delete the cursor character and enter the input mode. S: delete the column where the cursor is located and enter the input mode. (2) cursor movement command: Because many edits are positioned by the cursor, vi provides many ways to move the cursor: 0 moves to the front of the column where the cursor is located $
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service