SlideShare a Scribd company logo
1 of 20
Editor
CSIE 基爾 @ NCU網路開源社
Updated: 11172013
課程
• 相關學分:編譯器
• 等級:基本
• 背景知識:NO
• 課程目標:
• 懂得如何使用vi編輯器
Editor
編輯器的存在
• 是為了要讓我們編輯檔案的。(廢話!)

• 編輯器@圖形化介面
• 編輯器@純指令介面
• http://hackertyper.com/
編輯器種類
emacs
vi / vim
nano
ee
.
.
.
我們可以先嘗試用ee這套編輯器
#使用ee編輯檔案
$ ee <filename>
Vi - Basic
為什麼我挑Vi? (by Vbird)
• 所有的 Unix Like 系統都會內建 vi 文書編輯器
• 很多個別軟體的編輯介面都會主動呼叫 vi
• vim 具有程式編輯的能力
• 編輯速度快
Mode (模式)
• 一般模式:<esc>
• 命令模式:<一般模式下輸入特殊關鍵字>
• 視覺模式:<v @ 一般模式>

• 編輯模式:<i>,<insert>

#切換一般模式
$ <esc>
#切換編輯模式
$ <i> 或 <insert>
編輯檔案、開新檔案
@vi
檔案若不存在 > 檔案會暫存
@vim
檔案若不存在 > 存檔時會要求取檔名
非常不建議編輯不存在的檔案

#開新檔案
$ vi <filename>
#開啟舊檔
$ vi <filename>
編輯模式:編輯檔案
#切換回家目錄
$ cd ~
#新增檔案 test.txt
$ touch test.txt
#編輯檔案
$ vi test.txt
#切換模式編輯
$ <insert>
一般模式:刪除行
• dd @ 模式底下

#切換一般模式
$ <esc>
#移動刪除目標行
#輸入命令
$ <d>+<d>
一般模式:上一步、下一步
• 復原:u @一般模式
• 恢復復原: . @一般模式

#到一般模式
$ <esc>
#復原
$ <u>
#放棄復原
$ <.>
命令模式:搜尋
• / @ 一般模式
• 一次只能搜尋一個,從頭開始
• 找完會顯示Search wrapped

#到一般模式
$ <esc>
#輸入/進入命令模式
$ </>
#在命令/後尋找t字元
$/t
命令模式:存檔、離開
• 命令的開始: : @ 一般模式
• 存檔::w
• 離開::q
• 存檔+離開::wq
• 強制存檔::w!

#到一般模式
$ <esc>
#進入命令模式
$ <:>
#存檔後離開
$ :wq
Vim
vim
• 全名:vi improved
• 意旨進化版的vi編輯器
• 在Freebsd裡面並非內建
客製化自己的vim @ .vimrc
• VI編譯器能夠下命令改造
• Example:set nu #加入行號

#編輯test.txt
$ vi test.txt
#進入命令模式
$ <:>
#下命令set nu
$ :set nu
.vimrc範例
視覺模式:區塊編輯
• 複製:y @ 視覺模式標記內容
• 貼上:p @ 視覺模式標記內容
• 刪除:d @視覺模式標記內容
• only in vim
• vi只有提供單行編輯

#到一般模式
$ <esc>
#移動到標記首位
#切換視覺模式
$ <v>
#複製
$ <y>
#到一般模式
$ <esc>
#移動到貼上位置
#貼上
$ <p>

More Related Content

Viewers also liked

Viewers also liked (6)

Povestea unui proiect
Povestea unui proiectPovestea unui proiect
Povestea unui proiect
 
Mediul inconjurator
Mediul inconjuratorMediul inconjurator
Mediul inconjurator
 
Marina
MarinaMarina
Marina
 
Protejati mediul
Protejati mediulProtejati mediul
Protejati mediul
 
Tuffarsi in vim
Tuffarsi in vimTuffarsi in vim
Tuffarsi in vim
 
Vim
VimVim
Vim
 

Similar to Ch4 vi editor(2013 ncu-nos_nm)

Elixir 好用的編輯器
Elixir 好用的編輯器Elixir 好用的編輯器
Elixir 好用的編輯器bobo52310
 
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩Wen-Tien Chang
 
Introduction to vim
Introduction to vimIntroduction to vim
Introduction to vim政謙 陳
 
GNU Autoconf / Automake #4
GNU Autoconf / Automake #4GNU Autoconf / Automake #4
GNU Autoconf / Automake #4imacat .
 
李成银:前端编译平台
李成银:前端编译平台李成银:前端编译平台
李成银:前端编译平台taobao.com
 
前端编译平台
前端编译平台前端编译平台
前端编译平台Welefen Lee
 
Athrun instrument driver
Athrun instrument driverAthrun instrument driver
Athrun instrument driverdrewz lin
 
构建可维护的Javascript 小米网
构建可维护的Javascript 小米网构建可维护的Javascript 小米网
构建可维护的Javascript 小米网yang alex
 
Inspire dgt 網路技術分享_flash actionscritp class
Inspire dgt 網路技術分享_flash actionscritp classInspire dgt 網路技術分享_flash actionscritp class
Inspire dgt 網路技術分享_flash actionscritp classinspire digital
 
以Code igniter為基礎的網頁前端程式設計
以Code igniter為基礎的網頁前端程式設計以Code igniter為基礎的網頁前端程式設計
以Code igniter為基礎的網頁前端程式設計Amigo 陳兆祥
 
Multi thread 多執行緒程式設計(use c#)
Multi thread 多執行緒程式設計(use c#)Multi thread 多執行緒程式設計(use c#)
Multi thread 多執行緒程式設計(use c#)Gelis Wu
 
Continuous integration
Continuous integrationContinuous integration
Continuous integrationnetdbncku
 
Java Build Tool course in 2011
Java Build Tool course in 2011Java Build Tool course in 2011
Java Build Tool course in 2011Ching Yi Chan
 
使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式Will Huang
 
豆瓣I os自动化测试实践和经验
豆瓣I os自动化测试实践和经验豆瓣I os自动化测试实践和经验
豆瓣I os自动化测试实践和经验drewz lin
 
Tcon分享 芈峮
Tcon分享 芈峮Tcon分享 芈峮
Tcon分享 芈峮mijun_hlp
 
编辑器设计U editor
编辑器设计U editor编辑器设计U editor
编辑器设计U editortaobao.com
 

Similar to Ch4 vi editor(2013 ncu-nos_nm) (20)

Elixir 好用的編輯器
Elixir 好用的編輯器Elixir 好用的編輯器
Elixir 好用的編輯器
 
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
 
Introduction to vim
Introduction to vimIntroduction to vim
Introduction to vim
 
GNU Autoconf / Automake #4
GNU Autoconf / Automake #4GNU Autoconf / Automake #4
GNU Autoconf / Automake #4
 
專題-2017Linux Driver 實現
專題-2017Linux Driver 實現專題-2017Linux Driver 實現
專題-2017Linux Driver 實現
 
李成银:前端编译平台
李成银:前端编译平台李成银:前端编译平台
李成银:前端编译平台
 
前端编译平台
前端编译平台前端编译平台
前端编译平台
 
Athrun instrument driver
Athrun instrument driverAthrun instrument driver
Athrun instrument driver
 
构建可维护的Javascript 小米网
构建可维护的Javascript 小米网构建可维护的Javascript 小米网
构建可维护的Javascript 小米网
 
Inspire dgt 網路技術分享_flash actionscritp class
Inspire dgt 網路技術分享_flash actionscritp classInspire dgt 網路技術分享_flash actionscritp class
Inspire dgt 網路技術分享_flash actionscritp class
 
Java - TA課 - 開發環境
Java - TA課 - 開發環境Java - TA課 - 開發環境
Java - TA課 - 開發環境
 
以Code igniter為基礎的網頁前端程式設計
以Code igniter為基礎的網頁前端程式設計以Code igniter為基礎的網頁前端程式設計
以Code igniter為基礎的網頁前端程式設計
 
Some tips
Some tipsSome tips
Some tips
 
Multi thread 多執行緒程式設計(use c#)
Multi thread 多執行緒程式設計(use c#)Multi thread 多執行緒程式設計(use c#)
Multi thread 多執行緒程式設計(use c#)
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
 
Java Build Tool course in 2011
Java Build Tool course in 2011Java Build Tool course in 2011
Java Build Tool course in 2011
 
使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式
 
豆瓣I os自动化测试实践和经验
豆瓣I os自动化测试实践和经验豆瓣I os自动化测试实践和经验
豆瓣I os自动化测试实践和经验
 
Tcon分享 芈峮
Tcon分享 芈峮Tcon分享 芈峮
Tcon分享 芈峮
 
编辑器设计U editor
编辑器设计U editor编辑器设计U editor
编辑器设计U editor
 

More from Kir Chou

Learn from LL(1) to PEG parser the hard way
Learn from LL(1) to PEG parser the hard wayLearn from LL(1) to PEG parser the hard way
Learn from LL(1) to PEG parser the hard wayKir Chou
 
Time travel: Let’s learn from the history of Python packaging!
Time travel: Let’s learn from the history of Python packaging!Time travel: Let’s learn from the history of Python packaging!
Time travel: Let’s learn from the history of Python packaging!Kir Chou
 
Python パッケージの影響を歴史から理解してみよう!
Python パッケージの影響を歴史から理解してみよう!Python パッケージの影響を歴史から理解してみよう!
Python パッケージの影響を歴史から理解してみよう!Kir Chou
 
The str/bytes nightmare before python2 EOL
The str/bytes nightmare before python2 EOLThe str/bytes nightmare before python2 EOL
The str/bytes nightmare before python2 EOLKir Chou
 
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史) PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史) Kir Chou
 
Introduction of CTF and CGC
Introduction of CTF and CGCIntroduction of CTF and CGC
Introduction of CTF and CGCKir Chou
 
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PY
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PYPyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PY
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PYKir Chou
 
Spime - personal assistant
Spime - personal assistantSpime - personal assistant
Spime - personal assistantKir Chou
 
Ch9 package & port(2013 ncu-nos_nm)
Ch9 package & port(2013 ncu-nos_nm)Ch9 package & port(2013 ncu-nos_nm)
Ch9 package & port(2013 ncu-nos_nm)Kir Chou
 
Ch8 file system management(2013 ncu-nos_nm)
Ch8   file system management(2013 ncu-nos_nm)Ch8   file system management(2013 ncu-nos_nm)
Ch8 file system management(2013 ncu-nos_nm)Kir Chou
 
Ch7 user management(2013 ncu-nos_nm)
Ch7   user management(2013 ncu-nos_nm)Ch7   user management(2013 ncu-nos_nm)
Ch7 user management(2013 ncu-nos_nm)Kir Chou
 
Ch10 firewall(2013 ncu-nos_nm)
Ch10 firewall(2013 ncu-nos_nm)Ch10 firewall(2013 ncu-nos_nm)
Ch10 firewall(2013 ncu-nos_nm)Kir Chou
 
Knowledge Management in Distributed Agile Software Development
Knowledge Management in Distributed Agile Software DevelopmentKnowledge Management in Distributed Agile Software Development
Knowledge Management in Distributed Agile Software DevelopmentKir Chou
 
Sitcon2014 community by server (kir)
Sitcon2014   community by server (kir)Sitcon2014   community by server (kir)
Sitcon2014 community by server (kir)Kir Chou
 
Webapp(2014 ncucc)
Webapp(2014 ncucc)Webapp(2014 ncucc)
Webapp(2014 ncucc)Kir Chou
 
廢除雙二一議題 保留方論點 (2013ncu全幹會)
廢除雙二一議題   保留方論點 (2013ncu全幹會)廢除雙二一議題   保留方論點 (2013ncu全幹會)
廢除雙二一議題 保留方論點 (2013ncu全幹會)Kir Chou
 
Ch6 ssh(2013 ncu-nos_nm)
Ch6   ssh(2013 ncu-nos_nm)Ch6   ssh(2013 ncu-nos_nm)
Ch6 ssh(2013 ncu-nos_nm)Kir Chou
 

More from Kir Chou (20)

Learn from LL(1) to PEG parser the hard way
Learn from LL(1) to PEG parser the hard wayLearn from LL(1) to PEG parser the hard way
Learn from LL(1) to PEG parser the hard way
 
Time travel: Let’s learn from the history of Python packaging!
Time travel: Let’s learn from the history of Python packaging!Time travel: Let’s learn from the history of Python packaging!
Time travel: Let’s learn from the history of Python packaging!
 
Python パッケージの影響を歴史から理解してみよう!
Python パッケージの影響を歴史から理解してみよう!Python パッケージの影響を歴史から理解してみよう!
Python パッケージの影響を歴史から理解してみよう!
 
The str/bytes nightmare before python2 EOL
The str/bytes nightmare before python2 EOLThe str/bytes nightmare before python2 EOL
The str/bytes nightmare before python2 EOL
 
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史) PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
PyCon TW 2018 - A Python Engineer Under Giant Umbrella (巨大保護傘下的 Python 碼農辛酸史)
 
Introduction of CTF and CGC
Introduction of CTF and CGCIntroduction of CTF and CGC
Introduction of CTF and CGC
 
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PY
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PYPyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PY
PyCon TW 2017 - Why do projects fail? Let's talk about the story of Sinon.PY
 
GCC
GCCGCC
GCC
 
Spime - personal assistant
Spime - personal assistantSpime - personal assistant
Spime - personal assistant
 
Ch9 package & port(2013 ncu-nos_nm)
Ch9 package & port(2013 ncu-nos_nm)Ch9 package & port(2013 ncu-nos_nm)
Ch9 package & port(2013 ncu-nos_nm)
 
Ch8 file system management(2013 ncu-nos_nm)
Ch8   file system management(2013 ncu-nos_nm)Ch8   file system management(2013 ncu-nos_nm)
Ch8 file system management(2013 ncu-nos_nm)
 
Ch7 user management(2013 ncu-nos_nm)
Ch7   user management(2013 ncu-nos_nm)Ch7   user management(2013 ncu-nos_nm)
Ch7 user management(2013 ncu-nos_nm)
 
Ch10 firewall(2013 ncu-nos_nm)
Ch10 firewall(2013 ncu-nos_nm)Ch10 firewall(2013 ncu-nos_nm)
Ch10 firewall(2013 ncu-nos_nm)
 
Knowledge Management in Distributed Agile Software Development
Knowledge Management in Distributed Agile Software DevelopmentKnowledge Management in Distributed Agile Software Development
Knowledge Management in Distributed Agile Software Development
 
Cms part2
Cms part2Cms part2
Cms part2
 
Cms part1
Cms part1Cms part1
Cms part1
 
Sitcon2014 community by server (kir)
Sitcon2014   community by server (kir)Sitcon2014   community by server (kir)
Sitcon2014 community by server (kir)
 
Webapp(2014 ncucc)
Webapp(2014 ncucc)Webapp(2014 ncucc)
Webapp(2014 ncucc)
 
廢除雙二一議題 保留方論點 (2013ncu全幹會)
廢除雙二一議題   保留方論點 (2013ncu全幹會)廢除雙二一議題   保留方論點 (2013ncu全幹會)
廢除雙二一議題 保留方論點 (2013ncu全幹會)
 
Ch6 ssh(2013 ncu-nos_nm)
Ch6   ssh(2013 ncu-nos_nm)Ch6   ssh(2013 ncu-nos_nm)
Ch6 ssh(2013 ncu-nos_nm)
 

Recently uploaded

educ6506presentationtc3302771-240427173057-06a46de5.pptx
educ6506presentationtc3302771-240427173057-06a46de5.pptxeduc6506presentationtc3302771-240427173057-06a46de5.pptx
educ6506presentationtc3302771-240427173057-06a46de5.pptxmekosin001123
 
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书jakepaige317
 
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...黑客 接单【TG/微信qoqoqdqd】
 
哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制
哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制
哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制jakepaige317
 
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptx
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptxEDUC6506(001)_ClassPresentation_2_TC330277 (1).pptx
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptxmekosin001123
 
EDUC6506_ClassPresentation_TC330277 (1).pptx
EDUC6506_ClassPresentation_TC330277 (1).pptxEDUC6506_ClassPresentation_TC330277 (1).pptx
EDUC6506_ClassPresentation_TC330277 (1).pptxmekosin001123
 

Recently uploaded (6)

educ6506presentationtc3302771-240427173057-06a46de5.pptx
educ6506presentationtc3302771-240427173057-06a46de5.pptxeduc6506presentationtc3302771-240427173057-06a46de5.pptx
educ6506presentationtc3302771-240427173057-06a46de5.pptx
 
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书
 
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...
 
哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制
哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制
哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制
 
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptx
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptxEDUC6506(001)_ClassPresentation_2_TC330277 (1).pptx
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptx
 
EDUC6506_ClassPresentation_TC330277 (1).pptx
EDUC6506_ClassPresentation_TC330277 (1).pptxEDUC6506_ClassPresentation_TC330277 (1).pptx
EDUC6506_ClassPresentation_TC330277 (1).pptx
 

Ch4 vi editor(2013 ncu-nos_nm)