1 / 18

Vi 的基本指令

Vi 的基本指令. 一個文書編輯器 Berkeley 大學 Bill Joy 加強 ed 所有 UNIX 系統上都有 vi 多種不同的操作模式 vi 將檔案的部份資料印在終端機的螢幕上,因此稱為視覺編輯器. vi 需先知道所使用的終端機 檢查終端機種類 echo $term 設定終端機種類(暫時) set term=vt100 在 . login 中設定(永久) setenv TERM vt100. 啟動. vi vi < filename > vi -R < filename > (read only). vi 的三種模式. 輸入模式.

rossa
Download Presentation

Vi 的基本指令

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Vi的基本指令

  2. 一個文書編輯器 • Berkeley大學Bill Joy 加強ed • 所有UNIX系統上都有vi • 多種不同的操作模式 • vi將檔案的部份資料印在終端機的螢幕上,因此稱為視覺編輯器

  3. vi需先知道所使用的終端機 • 檢查終端機種類 echo $term • 設定終端機種類(暫時) set term=vt100 • 在 .login中設定(永久) setenv TERM vt100

  4. 啟動 vi vi <filename> vi -R <filename> (read only)

  5. vi的三種模式 輸入模式 ex模式 [ESC] [Enter] : 命令模式 i,I,a,A,o,O r,R,s,S :x, :q ZZ vi foo Shell

  6. 模式切換 • 命令模式 <ESC> • 編輯模式 i a A o O • ex模式 : • 顯示目前模式 : set showmode

  7. H J K L 瀏覽與移動 K J 上下 H L 左右 w 前一個字 b 後一個字 G 檔案尾端 ^F 前一個螢幕 ^B 後一個螢幕

  8. 增加及插入文字 a 在游標之後加入文字,游標後的文字 會被推到右邊 i 在游標之前加入文字,游標後的文字 會被推到右邊 A 在本行後開始加入文字 o 目前位置往下增加一行 O 目前位置往上增加一行 J 將下一行文字接到本行之後 r , R 取代文字

  9. 刪除文字 • x 刪除一個字母 • [number][command]motion • db往前刪除一個字 • dw往後刪除一個字 • dd刪除一行 • u 復原前一次修改    • U復原本行上所做的修改

  10. yy yank將游標所在的那行拷貝到buffer • 3yy • 4yw 拷貝游標所在起四個字 • p 將的內容貼在游標的後面 • P 將的內容貼在游標的前面

  11. 離開 • q 離開 • ZZ = wq 儲存離開 • q! 不儲存離開

  12. ed模式 • 在命令模式下按:即進入ed模式 • :w 存檔案,可加檔名,表示將寫入該檔 • :1,3w <filenmae> write pars of file • :r <filename> 讀取檔案 • :e <filename> 編輯新的檔案 , e! • :q    離開  • :12    跳到第12行 • :$ 跳到最後一行,與G一樣

  13. ed模式 • :/keyword 尋求keyword字串,可省略: • n 往前搜尋 • N往後搜尋

  14. ed模式 • :4,12s/ABC/DEF/ 將第4行到第12行中第一個“ABC”改為“DEF”, 最後一個/可省略 • :4,12s/ABC/DEF/g將第4行到第12行中所有“ABC”改為“DEF”, g 為globally • :1,$s/ABC/DEF 第一行到最後一行, s為search and replace • :1,$s/ABC/DEF/g

  15. 暫時跳回shell • :![command] :!ls -al • :sh<CR>

  16. 調整顯示畫面 • z<CR>將目前行移到螢幕頂端 • z.  將目前行移到螢幕中間 • z-  將目前行移到螢幕底部 • ^R 更新畫面

  17. . 重複上一個命令

  18. 設定你的喜好 • set • .exrc 放在home directory下

More Related