Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Như đã đề cập trước đó, bạn có thể lùi lại lệnh cuối cùng của bạn nếu bạn thực hiện một lỗi. Đơn giản chỉ cần nhấn u. Con trỏ không cần phải được trên đường, nơi chỉnh sửa đã được thực hiện. Để tiếp tục ví dụ trên, cho thấy việc xoá các dòng trong việc thực hành tập tin: | Substitute screen for line on line 1 1s screen line Invoke vi editor on file vi Go to first line 1 5.1.2 Problem Checklist While editing in vi you accidentally end up in the ex editor. A Q in the command mode of vi invokes ex. Any time you are in ex the command vi returns you to the vi editor. 5.2 Editing with ex Many ex commands that perform normal editing operations have an equivalent in vi that does the job more simply. Obviously you will use dw or dd to delete a single word or line rather than using the delete command in ex. However when you want to make changes that affect numerous lines you will find the ex commands more useful. They allow you to modify large blocks of text with a single command. These ex commands are listed below along with abbreviations for those commands. Remember that in vi each ex command must be preceded with a colon. You can use the full command name or the abbreviation whichever is easier to remember. delete d Delete lines. move m Move lines. copy co Copy lines. t Copy lines a synonym for co . You can separate the different elements of an ex command with spaces if you find the command easier to read that way. For example you can separate line addresses patterns and commands in this way. You cannot however use a space as a separator inside a pattern or at the end of a substitute command. 5.2.1 Line Addresses For each ex editing command you have to tell ex which line number s to edit. And for the ex move and copy commands you also need to tell ex where to move or copy the text to. You can specify line addresses in several ways With explicit line numbers With symbols that help you specify line numbers relative to your current position in the file With search patterns as addresses that identify the lines to be affected Let s look at some examples. 5.2.2 Defining a Range of Lines You can use line numbers to explicitly define a line or range of lines. Addresses that use explicit numbers are called absolute line addresses. For example 3 18d