LilLeo6
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Vim 學習筆記 ## DAY 03 開始在 Vim 裡打字 - 在normal模式下: - 進入insert模式 - 輸入`i` = insert - 輸入`a` = append - 輸入`o` = new line - 離開normal模式 - 輸入`:w`= 存檔 - 輸入`:q`= 離開 - 輸入`:wq`= 存檔然後離開 - 在insert模式下: - 進入normal模式 - 輸入`ESC` 或 - 輸入`Ctrl`+`[` ## DAY 04 在 Vim 裡移動游標 - `Ctrl`+`z`把Vim放到背景 - `fg`把背景的工作撿回來 - 在normal模式下,移動游標上下左右 - 輸入`h` = 往左 - 輸入`j` = 往下 - 輸入`k` = 往上 - 輸入`l` = 往右 :::info :bulb:注意 當上下移動時,若下一行或上一行是空白時,會移動到該行的最後一個字,而非直接往下或往上移動。 ::: ## DAY 05 Vim 之更快速、更精準的移動游標 - 在normal模式下 - 輸入`w` = 前進下一個字的字首(不包括特殊字元) - 輸入`W` = 前進下一個字的字首(包括特殊字元) - 輸入`e` = 前進下一個字的字尾(不包括特殊字元) - 輸入`E` = 前進下一個字的字尾(包括特殊字元) - 輸入`b` = 回到上一個字的字首(不包括特殊字元) - 輸入`B` = 回到上一個字的字首(包括特殊字元) - 輸入`{` = 移到上一個段落 - 輸入`}` = 移到下一個段落 - 輸入`gg` = 移到整份文件第一行的第一個字的字首 - 輸入`G` = 移到整份文件最後一行的第一個字的字首 - 輸入`0` = 移到游標所在的該行行首 - 輸入`$` = 移到游標所在的該行行尾 - 輸入`gk` = 移到上一行 - 輸入`gj` = 移到下一行 ## DAY 06 Vim 之在文件裡搜尋文字 - 在normal模式下 - 輸入`:set hlsearch` = 設定搜尋highlight效果 - 輸入`:set nohlsearch` = 設定搜尋highlight效果 - 輸入`/` + `欲搜尋的文字` = 搜尋文字 - 輸入`n` = 繼續搜尋下一個 - 輸入`N` = 繼續搜尋上一個 - 輸入`*` = 搜尋目前游標的這個字 - 輸入`n` = 繼續搜尋下一個 - 輸入`N` = 繼續搜尋上一個 - 輸入`fx` = 往後搜尋同一行最近的x - 輸入`Fx` = 往前搜尋同一行最近的x - 輸入`zz` = 讓某一行停在畫面中間 - 輸入`zt` = 讓某一行停在畫面上方 - 輸入`zb` = 讓某一行停在畫面下方 ## DAY 07 Vim 之選取、複製、貼上 - 在normal模式下: - 進入visual模式 - 輸入`v` = visual - 輸入`V` = visual且複製一整行 - 輸入`p`(如果已經複製文字後) = 在該游標貼上文字 - 輸入`數字(1~9)`+`p`(如果已經複製文字後) = 在該游標重複貼上幾次文字 - 輸入`yy` = 複製該游標所在的一整行 - 在visual模式(小寫v)下: - 輸入`h` = 往左 - 輸入`j` = 往下 - 輸入`k` = 往上 - 輸入`l` = 往右 - 輸入`w` = 前進下一個字的字首(不包括特殊字元) - 輸入`W` = 前進下一個字的字首(包括特殊字元) - 輸入`b` = 回到上一個字的字首(不包括特殊字元) - 輸入`B` = 回到上一個字的字首(包括特殊字元) - 輸入`{` = 移到上一個段落 - 輸入`}` = 移到下一個段落 - 輸入`gg` = 移到整份文件第一行的第一個字的字首 - 輸入`G` = 移到整份文件最後一行的第一個字的字首 - 輸入`0` = 移到游標所在的該行行首 - 輸入`$` = 移到游標所在的該行行尾 - 輸入`gk` = 移到上一行 - 輸入`gj` = 移到下一行 - 輸入`y` = yank(複製)並回到normal模式 - 輸入`ESC` 或輸入`Ctrl`+`[` 回到normal模式 - 在visual模式(大寫v)下: - 輸入`h` = 往左移動 - 輸入`j` = 往下移動一整行 - 輸入`k` = 往上移動一整行 - 輸入`l` = 往右移動 - 輸入`y` = yank(複製)並回到normal模式 - 輸入`ESC` 或輸入`Ctrl`+`[` 回到normal模式 ## DAY 08 Vim 之更多關於選取、複製、貼上 - 在normal模式下: - 輸入`3yy` = 複製游標所在的以下3行(其他數字以此類推) - 輸入`y3w` = 複製游標所在的以下3個字(其他數字以此類推) - 輸入`y$` = 複製游標處到行尾 - 輸入`yG` = 複製游標處到最後一行 - 輸入`ygg` = 複製游標處到第一行第一個字 - 輸入`P`(如果已經複製文字後) = 在該游標前貼上文字 - 輸入`u` = 回到上一步(undo) - 輸入`ctrl`+`r` = 重做(redo) - 輸入`"ay` = 把內容存到a暫存器(其他英文字母以此類推) - 輸入`"ap` = 貼上a暫存器的內容 - 輸入`:reg` = 可檢視目所有暫存器內容 - 輸入`:set clipboard=unnamed` = 暫存器可跟剪貼板溝通 :::info :bulb:注意 一次複製一整行後,貼上的接續點是以行為單位,會貼在下一行(輸入`p`)或上一行(輸入`P`) ::: ## DAY 09 Vim 之編輯文字 - 在normal模式下: - 輸入`I` = 跳到行首並進入insert模式 - 輸入`A` = 跳到行末並進入insert模式 - 輸入`O` = 再游標上方插入一行並進入insert模式 - 輸入`x` = 刪除游標所在文字,且會把刪除的字放入暫存器 - 輸入`d` = 可刪除選取內容(必須先用visual模式選取),且會把刪除的字放入暫存器(相當於剪下的功用) - 輸入`D` = 可刪除游標以後內容(只有游標所在那一行),且會把刪除的字放入暫存器 - 輸入`dd` = 可刪除游標所在那一行,且會把刪除的字放入暫存器 - 輸入`3dd` = 可刪除游標處以下3行,且會把刪除的字放入暫存器(其他數字以此類推) - 輸入`dG` = 可刪除游標以下所有內容,且會把刪除的字放入暫存器 - 輸入`dgg` = 可刪除游標以上所有內容,且會把刪除的字放入暫存器 - 輸入`c` = 可刪除選取內容(必須先用visual模式選取),並進入insert模式,且會把刪除的字放入暫存器 - 輸入`C` = 可刪除游標以後內容(只有游標所在那一行),並進入insert模式,且會把刪除的字放入暫存器 - 輸入`cc` = 可刪除游標所在那一行,並進入insert模式,且會把刪除的字放入暫存器 - 輸入`3cc` = 可刪除游標處以下3行,並進入insert模式,且會把刪除的字放入暫存器(其他數字以此類推) - 輸入`rx` = 取代游標所在文字改成x(x可為其他任意文字) - 輸入`>>` = 將游標所在的那一行增加縮排 - 輸入`<<` = 將游標所在的那一行減少縮排 - 輸入`>` = 可將選取內容增加縮排(必須先用visual模式選取) - 輸入`<` = 可將選取內容減少縮排(必須先用visual模式選取) - 輸入`=` = 可將選取的內容做排版(必須先用visual模式選取)(依照程式語言而定) ## DAY 10 Vim 之編輯多個檔案 Part 1 - 在開啟vim或normal模式下: - 輸入`:e a.html` = 開啟a.html(a.html可改成其他任何檔名) - 輸入`:tabe` = 開啟新分頁 - 輸入`:tabe a.html` = 開啟a.html分頁 - 輸入`gt` = 跳到下一個分頁 - 輸入`gT` = 跳到上一個分頁 - 輸入`:vnew` = 新增垂直視窗 - 輸入`ctrl`+`w`+`hjkl` = 移動游標到指定視窗 - 輸入`:qa` = 結束全部工作 - 在終端機下: - 輸入`vim -O a.html b.c` = 用垂直分割視窗開啟a.html和b.c - 輸入`vim -O *` = 用分割視窗開啟該路徑下所有檔案 - 輸入`vim -p a.html b.c` = 用分頁視窗開啟a.html和b.c - 輸入`vim -p *` = 用分頁視窗開啟該路徑下所有檔案 ## DAY11 Vim 之編輯多個檔案 Part 2 - Buffer - 在終端機下 - 輸入`vim *` = 開啟該路徑下所有檔案 - 在開啟vim或normal模式下的buffer操作: - 輸入`:ls` = 列出所有buffer - 輸入`:b3` = 切換到第3個buffer(其他數字以此類推) - 輸入`:b ss.c` = 切換到符合檔名的buffer(不用打出完整檔名,只需打出一部份) - 輸入`ctrl`+`^(6)` = 切換到前一個buffer(與buffer編號無關) - 輸入`:bn` = 切換到下一個buffer - 輸入`:bp` = 切換到上一個buffer - 輸入`:bf` = 切換到第一個buffer - 輸入`:bl` = 切換到最後一個buffer - 輸入`:bd` = 關閉buffer - 輸入`:tab ba` = 把全部buffer展開成tab ## DAY 12 Vim 之更多選取方式 - 輸入`ctrl`+`v`進入visual block模式: - 註解常搭配`I`用 - 在normal模式下: - 輸入`viw` = 選取一個word(i = inner,w = word) - 輸入`vaw` = 選取一個word和後方一個空格(a = around,w = word) - 輸入`vi"` = 選取雙引號裡面的內容(i = inner)(雙引號可改為別的符號,例如單引號、小括號、大括號等等、以此類推) - 輸入`va"` = 選取雙引號以及裡面的內容(a = around) - 輸入`v{`或 `v}`= 選取上一段或下一段 :::info :bulb:注意 以上的`v`都能換成`c`或`d`(c = change,d = delete) ::: ## DAY 13 Vim Text Object - 名詞: - `w` = word - `s` = sentence - `p` = paragraph - `t` = tag - `'` - `"` - `{` - `[` - `(` - 動詞: - `y` = yank - `v` = visual - `p` = paste - `c` = change - `d` = delete - ... - 範圍: - `i` = inner - `a` = a or around - 量詞: - 數字 - 一些範例: - 輸入`viw` = 選取1個word - 輸入`d3w` = 刪除3個word - 輸入`3yy` = 複製3行 - 輸入`3w` = 往下移動3個word - 輸入`5p` = 貼上5次 ## DAY 14 Vim 之其它實用的小技巧 - 在normal模式下: - 輸入`^` = 移動到行首(不包括行首前面的空白) - 輸入`13G` = 直接跳到第13行 - 輸入`:set number` = 設定行號 - 輸入`ctrl` +`f` = 往下翻一頁 - 輸入`ctrl` +`b` = 往上翻一頁 - 輸入`zf` = 把選取的內容折起來 - 輸入`zd` = 把折疊的內容解開(或在折疊的那行輸入`l`) - 輸入`zfip` = 把選取的段落折起來 - 輸入`~` = 大小寫互換 - 輸入`.` = 重做最後的動作(做註解能用到) - 輸入`J` = 把多行並成一行 :::info :bulb:注意 以上的動詞都能應用在text object ::: - 在insert模式下: - 輸入`ctrl`+`w` = 刪除前一個word - 輸入`ctrl`+`u` = 刪除游標前的內容 :::info :bulb:注意 以上的2個指令在終端機下也能用 ::: - 在normal模式下: - 輸入`:! 指令名稱` = 執行外部程式 - 輸入`:h` = 查看使用手冊 - 輸入`:h 指令` = 查詢vim指令 - 在終端機下: - 輸入`vimtutor` = 簡易教學(也能輸入`vimtutor zh_tw`) ## DAY 15 Vim 的設定檔 Part 1 - 修改~/.vimrc - `"` = 註解 - `set number` = 設定行號 - `set clipboard=unnamed` = 設定剪貼板共用 - `set hlsearch` = 設定讓搜尋明顯 - `set cursorline` = 設定讓游標處有底線 - `set noswapfile` = 設定關閉swap檔 - 在normal模式下: - `:source` = 載入設定檔 ## DAY 16 Vim 的設定檔 Part 2 - 修改~/.vimrc - 輸入`set softtabstop=4` = 使用4個space取代tab - 輸入`set shiftwidth=4` = 在`>`的時候使用2個空個做縮排 - 輸入`set expandtab` = 使用space取代tab - 須搭配normal模式下`:retab`重新設定文件裡面的tab - 輸入`set ignorecase` = 設定搜尋時不分大小寫 - 輸入`set incsearch` = 設定漸進式搜尋 - 輸入`set showtabline=2` = 只要有任何分頁會顯現出來都 - 輸入`set splitright` = 新增垂直視窗時會出現在右方 - 輸入`syntax on` = 打開程式碼語法高亮 - 輸入`filetype indent on` = 根據程式語言種類進行縮排 - 輸入`filetype plugin on` = 根據程式語言種類載入外掛 ## DAY 17 Vim 的設定檔之 Key Mapping part 1 |命令|Normal mode|Visual mode|Insert mode| |:-:|:---------:|:---------:|:---------:| |map|yes |yes | | |nmap|yes | | | |vmap| |yes | | |imap| | |yes | - 在normal模式下: - 輸入`:h key-notation` = 查詢特殊鍵 - 輸入`:map` = Map Keying(可改成imap、vmap、nmap) - 輸入`:unmap` = 取消Map Keying(可改成iunmap、vunmap、nunmap) - 輸入`mpaclear` = 把全部的對應取消掉 ## DAY 18 Vim 的設定檔之 Key Mapping part 2 - 修改~/.vimrc - `noremap` = no recursive mapping - Leader Key :預設`\` - `:let mapleader=","` = 把leader設成逗號 ## DAY 19 Vim 的設定檔 Part 3 - 修改~/.vimrc - 利用try...catch...endtry 捕捉錯誤訊息 - `set ruler` = 顯示目前游標所在處的狀態 - `set scrolloff=4` = 剩下4行就開始捲動 - `set wrap` = 自動折行 - `set linebreak` = 在比較適當的地方換行 - `set showmode` = 設定在左下角顯示現在模式 - `set showcmd` = 設定顯示敲打了什麼指令 - `set smartcase` = 比較聰明的搜尋 - `set list` = 顯示每行最後的空白所在處 - 在normal模式下: - 輸入`:set` = 檢視目前非預設值的設定 - 輸入`:set all` = 檢視所有能用的的設定 - 輸入`:colorscheme `,接著再按`ctrl`+`d` = 顯示所有能用的顏色主題 ## DAY 20 Vim 之自動命令 - 修改~/.vimrc - 視窗切換時候顯示/隱藏游標底線 ``` autocmd WinEnter * setlocal cursorline autocmd WinLeave * setlocal nocursorline ``` - 存檔時自動把行末多餘的空白刪除 ``` autocmd BufWritePre * :%s/\s\+$//e ``` ## DAY 21 整理你的 Vim 設定 - .vim 檔案是vimscript - 使用`:h vimfiles` 查詢vim建議使用的檔案規劃 ## DAY 22 使用 Vim 外掛 - 外掛管理工具:[VimPlug](https://github.com/junegunn/vim-plug) - 建議用Git管理設定 ## DAY 23 好用的 Vim 外掛介紹 part 1 - Vim-Airline https://github.com/vim-airline/vim-airline - NERDTree https://github.com/scrooloose/nerdtree - `U` = 往上一層目錄 - `C` = 往下一層目錄 - `?` = 求助 - VimAwesome https://vimawesome.com - fzf https://github.com/junegunn/fzf ## DAY 29 Vim 之巨集(Macro) - 在normal模式下: - 輸入`qa` = 開始錄製巨集到a暫存器 - 輸入`q` = 停止錄製 - 輸入`@a` = 播放巨集 ## DAY 30 Vim 之其它漏網之魚 - 在normal模式下: - 輸入`:%s/text/cch/gc` = 將此檔案所有text取代成cch字串(每次取代都會詢問)(若不想詢問則把最後的c拿掉)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully