看板 Editor 關於我們 聯絡資訊
上一篇簡介了vi時代流傳下來的神奇指令 一開始雖然可能會用不習慣 但是這是vi/vim和別的編輯器最不一樣也最迷人的地方 在列當中的移動指令上次有幾個沒講: f{char} find cursor is placed on {char} F{char} find backward cursor is placed on {char} t{char} find cursor is placed on the character left of {char} T{char} find backward cursor is placed on the character right of {char} , find {char} again (backward) ; find {char} again forward 以上指令我認為看英文比較快,因為中文同樣繞口...:p This is a pen, and this is a pencil. ^cursor fi 往右找到第一個i This is a pen, and this is a pencil. ti 同上,但停在i之前 This is a pen, and this is a pencil. 2fi or fi; 向右找到第二個i This is a pen, and this is a pencil. 大寫則是往前找 使用, ; 可以向前或向後找同樣的字元,但是只限於在同一列 用, ; 比數字鍵方便^ ^ 看到游標有移動吧? 這也是motion指令的一種,可以配合action指令來操作 如y2fr(複製到第二個r) y2tr(複製到第二個r之前) 有時候要處理的文字不是一兩個單字而是區塊之類的時候 能夠將區塊反白再做處理會比硬記指令放心 也因此就有了visual mode (反白模式,或可以說是視覺化motion操作模式) 在normal mode下按v即可進入visual mode 在最下面的一條狀態上面可以看到是INSERT, VISUAL等字樣顯示是什麼mode (上次教學沒講到,真是粗心..) in VISUAL mode: This is a pen, and this is a pencil. fi This is a pen, and this is a pencil. ; This is a pen, and this is a pencil. 接下來大部分的action指令都可以用 d 刪除選取文字 c 刪修選取文字 y 複製選取文字 通常在這種情況下會用到的action指令也只有上面這幾項吧?XD 除了visual mode之外,還有兩個指令可以防止你不小心輸入錯誤: u undo ctrl_r redo 存檔、關檔相關的指令上次沒有提到: :q quit 離開 :w write 存檔 :x ?? 存檔且離開 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.136.190.64 ※ 編輯: dryman 來自: 220.136.190.64 (01/26 11:47)
ckclark::x = ZZ 03/02 05:38