tailieunhanh - Learning the vi Text Editor 6th phần 4

U, phiên bản chữ hoa u, Hoàn tác tất cả các chỉnh sửa trên một dòng đơn, miễn là con trỏ vẫn còn trên đường dây đó. Một khi bạn di chuyển một dòng, bạn không còn có thể sử dụng U. Lưu ý rằng bạn có thể lùi lại cuối cùng của bạn hoàn tác với u, Toggling giữa hai phiên bản của văn bản. u cũng sẽ lùi lại U và U sẽ undo bất kỳ thay đổi một dòng, bao gồm cả | This command works as follows. First ex finds and marks each line that matches the first pattern . that contains the word SYNTAX . Second for each marked line it sets . dot the current line to that line and executes the command. Using the move command the command moves the block of lines from the current line dot to the line before the one containing the word DESCRIPTION DESCRIPTION -1 to just before the line containing PARAMETERS PARAMETERS -1 . Note that ex can place text only below the line specified. To tell ex to place text above a line you first subtract one with -1 and then ex places your text below the previous line. In a case like this one command saves literally hours of work. This is a real-life example we once used a pattern match like this to rearrange a reference manual containing hundreds of pages. Block definition by patterns can be used equally well with other ex commands. For example if you wanted to delete all DESCRIPTION paragraphs in the reference chapter you could enter g DESCRIPTION PARAMETERS -1d This very powerful kind of change is implicit in ex s line addressing syntax but it is not readily apparent even to experienced users. For this reason whenever you are faced with a complex repetitive editing task take the time to analyze the problem and find out if you can apply pattern-matching tools to get the job done. More Examples Since the best way to learn pattern matching is by example here is a list of pattern-matching examples with explanations. Study the syntax carefully so that you understand the principles at work. You should then be able to adapt these examples to your own situation. 1. Put troff italicization codes around the word RETURN s RETURN fI fP g Notice that two backslashes are needed in the replacement because the backslash in the troff italicization code will be interpreted as a special character. fI alone would be interpreted as fI you must type fI to get fI. 2. Modify a list of pathnames in a file s home tim home

TỪ KHÓA LIÊN QUAN