1 / 24

Linux Programming Tutoring

Linux Programming Tutoring. - Introduction to Editors for Linux. Outline. vim 基本指令 自定 vim 設定檔 (.vimrc) vim 進階技巧 emacs 基本指令 emacs 特殊功能. vim Overview. 一般模式 vim 預設的模式 可以移動游標 『 刪除字元 』 或 『 刪除整行 』 也可以 『 複製、貼上 』 來處理你的文件資料 編輯模式 一般模式中按下 『 i , I, o, O, a, A, r, R』 之後進入編輯模式 可編輯文件內容

galen
Télécharger la présentation

Linux Programming Tutoring

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. Linux Programming Tutoring - Introduction to Editors for Linux

  2. Outline • vim基本指令 • 自定vim設定檔 (.vimrc) • vim進階技巧 • emacs基本指令 • emacs特殊功能

  3. vim Overview • 一般模式 • vim預設的模式 • 可以移動游標 • 『刪除字元』或『刪除整行』 • 也可以『複製、貼上』來處理你的文件資料 • 編輯模式 • 一般模式中按下『i, I, o, O, a, A, r, R』之後進入編輯模式 • 可編輯文件內容 • 按下『Esc』這個按鍵即可退出編輯模式 • 指令列命令模式 • 一般模式中輸入『 : / ? 』即可進入此模式 • 可以『搜尋資料』 • 讀取、存檔、大量取代字元、離開 vi 、顯示行號

  4. vim Overview 一般模式 編輯模式 i,o,a(插入)r,R(取代) [ESC] :,/,? 指令列模式 [ESC]

  5. vim一般模式常用指令(1/2)

  6. vim一般模式常用指令(2/2)

  7. vim編輯模式常用指令

  8. vim指令列模式常用指令

  9. vim搜尋及取代常用指令

  10. vim 環境設定 • 使用者vim設定檔為 ~/.vimrc • 系統之vim設定檔通常為 /etc/vim/vimrc或 /etc/vimrc • 一般模式下輸入 :set all 可顯示所有設定選項

  11. vim常用設定

  12. .vimrc 設定範例 "這個檔案的雙引號 (") 是註解 sethlsearch "高亮度反白 setautoindent "自動縮排 set ruler "可顯示最後一行的狀態 setshowmode "左下角那一行的狀態 setnu “每行最前面顯示行號 setbg=dark "顯示不同的底色色調 syntaxon “進行語法檢驗顏色顯示

  13. vim 的暫存檔(1/2) • vim 會在與被編輯檔案的目錄下,建立一個 .filename.swp檔案 • 若vim不正常關閉,下次再開啟時會顯示以下畫面

  14. vim 的暫存檔(2/2) • [O]pen Read-Only:打開此檔案成為唯讀檔, 可以用在你只是想要查閱該檔案內容並不想要進行編輯行為時 • (E)dit anyway:還是用正常的方式打開你要編輯的那個檔案, 並不會載入暫存檔的內容 • (R)ecover:載入暫存檔的內容,用在要救回之前未儲存的工作。 不過當你救回來並且儲存離開 vim 後,還是要手動自行刪除那個暫存檔 • (D)elete it:開啟檔案前會先將這個暫存檔刪除 • (Q)uit:按下 q 就離開 vim ,不會進行任何動作回到命令提示字元。 • (A)bort:忽略這個編輯行為,與 quit 非常類似

  15. vim多重檔案編輯 想要將 A 檔案內的十條消息『移動』到 B 檔案去,通常要開兩個 vim 視窗來複製, 偏偏每個 vim 都是獨立的,因此並沒有辦法在 A 檔案下達『 nyy 』再跑到 B 檔案去『 p 』!此時這個多檔案編輯就派上用場了!

  16. vim多重視窗編輯

  17. emacs 快速入門 • 如果emacs是在X視窗啟動,則會自動開啟一個新視窗,如果不想如此可以下命令時加入 –nw選項: $emacs –nw 註:C-x 代表 Control x

  18. emacs常用指令 註:M-x 代表 META x 若沒META鍵通常為[ESC]鍵

  19. emacs常用指令

  20. emacs複製和貼上

  21. emacs搜尋相關指令 • 找到了之後按 C-g 可以取消搜尋,跳回原來的位置

  22. emacs視窗相關指令

  23. emacs特殊功能

  24. Reference • vim • http://linux.vbird.org/linux_basic/0310vi.php • http://en.wikipedia.org/wiki/Vim_%28text_editor%29 • emacs • http://www.gnu.org/software/emacs/tour/ • http://en.wikipedia.org/wiki/Emacs • http://www.gnu.org/software/chinese/manual/TUTORIAL.zh • http://shelandy.blogspot.com/2008/01/eamcs.html

More Related