Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created May 29, 2020 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peter279k/2656ca6d1547f8a85f495c0d85c76d17 to your computer and use it in GitHub Desktop.
Save peter279k/2656ca6d1547f8a85f495c0d85c76d17 to your computer and use it in GitHub Desktop.
The vi/vim command cheatsheet and best practices
i : 游標 前方 插入 字元
a : 游標 後方 插入 字元
O : 游標 上方 插入 空白行
o : 游標 下方 插入 空白行
del : 刪除一個字元
dd : 刪除一行
3dd : 刪除三行
yy : 複製 一行
p : 在游標 下方 貼上
P : 在游標 上方 貼上
3yy : 複製 三行
:1 : 移動 游標 到檔案的 第 1 行
:N : 移動 游標 到檔案的 第 N 行
:$ : 移動 游標 到檔案的 最行一行
ctrl + g: 顯示 游標 在檔案的 行 跟 列 的位置
u : 上一步
ctrl + r: 下一步
/String : 搜尋 字串
n : 向下搜尋
N : 向上搜尋
:w : 存檔 然後繼續編輯
:wq! : 存檔 然後結束 vi
:q! : 不存檔結束 vi
:1,$s/[Cc]at/Dog/g : 以正規表示式 搜尋 取代 字串
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment