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

Những ví dụ này sẽ cung cấp cho bạn một ý tưởng về các phím tắt thông minh có thể xác định bản đồ bàn phím: 1. Thêm văn bản bất cứ khi nào bạn di chuyển đến cuối của một từ:: bản đồ điện tử ea Hầu hết thời gian, lý do duy nhất bạn muốn di chuyển đến cuối của một từ là thêm văn bản. Trình tự bản đồ này đặt ở chế độ chèn tự động. Lưu ý rằng chìa khóa ánh xạ, điện tử, đã. | map g A ea 10nAMA 3x Note that you have to quote both the ESC and RETURN characters with CTRL-V. A is the sequence that appears when you type CTRL-V followed by ESC. AM is the sequence shown when you type CTRL-V RETURN. Now simply typing g will perform the entire series of edits. At a slow baud rate you can actually see the edits happening individually. At a fast baud rate it will seem to happen by magic. Don t be discouraged if your first attempt at key mapping fails. A small error in defining the map can give very different results from the ones you expect. Type u to undo the edit and try again. More Examples of Mapping Keys These examples will give you an idea of the clever shortcuts possible when defining keyboard maps 1. Add text whenever you move to the end of a word map e ea Most of the time the only reason you want to move to the end of a word is to add text. This map sequence puts you in insert mode automatically. Note that the mapped key e has meaning in vi. You re allowed to map a key that is already used by vi but the key s normal function will be unavailable as long as the map is in effect. This isn t so bad in this case since the E command is often identical to e. 2. Transpose two words map K dwElp We discussed this sequence earlier in the chapter but now you need to use E assume here and in the remaining examples that the e command is mapped to ea . Remember that the cursor begins on the first of the two words. Unfortunately because of the l command this sequence and the earlier version doesn t work if the two words are at the end of a line during the sequence the cursor ends up at the end of the line and l cannot move further right. Here s a better solution map K dwwP You could also use W instead of w. 3. Save a file and edit the next one in a series map q wAM nAM Notice that you can map keys to ex commands but be sure to finish each ex command with a carriage return. This sequence makes it easy to move from one file to the next and is .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.