Oreilly learning the vi Editor phần 7

Hãy làm việc thông qua cách bạn Có thể Một số ký tự đặc biệt sử dụng trong thay thế. Giả sử rằng bạn có một file dài và bạn muốn thay thế đó các con chữ với các em trong suốt từ tập tin đó. Trước tiên, bạn lưu các sửa đổi với bộ đệm: w, Sau đó, hãy thử thay thế toàn cầu:% s / con / trẻ em / g Khi bạn tiếp tục chỉnh sửa, bạn nhận thấy sự xuất hiện của các từ như vậy là childrenish. . | Chapter 6 Global Replacement By prefixing the s command with an address you can extend its range to more than one line. For example 50 100s old new g will change every occurrence of old to new from line 50 to line 100. The following command will change every occurrence of old to new within the entire file 1 s old new g You can also use instead of 1 to specify every line in a file. Thus the last command could also be given like this s old new g Global replacement is much faster than finding each instance of a string and replacing it individually. Because the command can be used to make many different kinds of changes and because it is so powerful we are first going to illustrate simple replacements and then build to complex context-sensitive replacements. Confirming Substitutions It makes sense to be overly careful when using a search and replace command. It sometimes happens that what you get is not what you expect. You can undo any search and replacement command by entering u provided that the command was the most recent edit you made. But you don t always catch undesired changes until it is too late to undo them. Another way to protect your edited file is to save the file with w before performing a global replacement. Then at least you can quit the file without saving your edits and go back to where you were before the change was made. You can also read the previous version of the buffer back in with e . It s wise to be cautious and know exactly what is going to be changed in your file. If you d like to see what the search turns up and confirm each replacement before it is made add the c option for confirm at the end of the substitute command 1 30s his the gc It will display the entire line where the string has been located and the string will be marked by a series of carets AAAA . copyists at his school If you want to make the replacement you must enter y for yes and press RETURN If you don t want to make a change simply press RETURN . this can be used for

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.