Matt Jan
    • 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
    • Invite by email
      Invitee

      This note has no invitees

    • 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
    • Note Insights New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy 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
  • Invite by email
    Invitee

    This note has no invitees

  • 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- tags: Tools --- # Vim 筆記 ## 常用單一按鍵 - `i` : insert - `a` : append - `o` : open - `c` : change - `s` : substitute - `y` : yank - `d` : delete - `p` : paste - `r` : replace - `u` : undo ## 常用指令 (shell) - `vim $file name$` : 開啟$file name$檔案 - `vim .` : 開啟當前目錄,可用選取的方式進入該文件。 - `gg=G` : auto format(indent) the content. ### 普通模式 - `Esc` : 回到普通模式 - `ctrl + [` : 回到普通模式 - `i` : 進入文字編輯模式 - `:` : 進入命令行模式(insert) - `v` : 進入選取模式(visual),這裡是一行一行選取 - `Ctrl + v` : 進入選取模式,這裡是選取一個矩形 - `x` : 刪除當前字元 - `X` : 刪除前一字元 - `r` : 取代當前字元,後方須加上取而代之之字元 - `R` : 進入取代模式 - `dd` : 刪除當行文字 - `de` : 刪除一個單詞,與`dw`相同 - `yy` : 複製當行文字 - `y$` : 複製到結尾 - `yt"` : 複製到引號前一格 - `p` : 貼上剛才刪除及複製文字 - `P` : 在光標上一行,貼上剛才刪除及複製文字 - `>>` : 縮排文字 - `<<` : 反向縮排文字 - `.` : 重複上一次的執行指令,包含插入模式中輸入的文字 - `u` : undo,恢復上一動作 - `ctrl + r` : redo,重作剛才恢復的動作 - `U` : 一次恢復單行文字狀態 - `ctrl + a` : 遞增 - `ctrl + x` : 遞減 - `Ctrl + Shift + =` : 放大顯示字體 - `Ctrl + -` : 縮小字體 ### 命令行模式 - `:q` : 離開(quit) - `:w` : 存檔(write) - `:e $file name$` : 開啟另一檔案,檔名為$file name$ - `:e .` : 開啟目錄 - `:s/$舊的文字$/$新的文字$` : 用新的文字取代舊的文字 - `:s/$舊的文字$/$新的文字$/g` : 用新的文字取代舊的文字,作用於當前整行,`g`代表當前整行 - `:%s/$舊的文字$/$新的文字$/g` : 用新的文字取代舊的文字,作用於整個文件,`%`代表當前文件 - `:r $file name$` : 提取$file name$中的文字 - `:$行數$t.` : 複製第$行數$行到當前位置 - `:$起始行號$,$結束行號$t.` : 複製起始到結束行數的內容到當前位置 - `:$行號$m.` : 將第$行號$內容移動到當前位置 - `:$起始行號$,$局數行號$m.` : 將起始到結束行號間的內容,移動到當前位置 - `:find $檔案名稱$` : 無法直接執行,需要定位搜索路徑 - `:set path` : 看見預設路徑 - `:set path=**` : 更改預設路徑,在關閉Vim後,path 仍會被重製 - `:find **/$檔案名稱$` : 不更改路徑直接搜尋的方法 #### 視窗及分頁操作 - `:tabe $file name$` : 開啟另一檔案分頁,檔名為$file name$ - `:tabe .` : 開啟目錄分頁 - `gt` : 下一頁 - `gT` : 上一頁 - `:close` : 關閉分頁 - `:clos` : 關閉分頁 - `:split filename` : 將頁面做上下分割,新的檔案開在上方。 - `Ctrl + w + (hjklwtbp)` : 移動到要去的視窗 - h,j,k,l : 上下左右 - w : 在所有視窗迴圈移動 - t : 左上 - b : 右下 - p : 前一個 - `Ctrl + w + r` : 向右向下交換視窗位置 - `Ctrl + w + R` : 向左向上交換視窗位置 - `Ctrl + w + x` : 交換同行或同列視窗位置,預設為下一個視窗,可在命令前加上數字指定視窗 - `Ctrl + w + K` : 移動當前視窗至螢幕頂端,並佔用全部寬度 - `Ctrl + w + J` : 移動當前視窗至螢幕底端,並佔用全部寬度 - `Ctrl + w + H` : 移動當前視窗至螢幕左端,並佔用全部寬度 - `Ctrl + w + L` : 移動當前視窗至螢幕右端,並佔用全部寬度 - `Ctrl + w + T` : 移動當前視窗至屏新的現有分頁 - `Ctrl + w + =` : 平均劃分所有視窗 - `Ctrl + w + -` : 當前視窗的高度減少一行 - `resize n` : 指定當視窗高度 - [頁面分割](https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/179258/) #### 光標移動與定位 ##### 定位行數 - `G` : 頁面底端 - `gg` : 頁面頂端 - `ctrl + d` : 向下半頁 - `ctrl + u` : 向上半頁 - `ctrl + f` : 向下整頁 - `ctrl + b` : 向上整頁 - `ctrl + e` : 將整個頁面,向下移動一行文字 - `ctrl + y` : 將整個頁面,向上移動一行文字 - `zz` : 將當前行置於頁面中間 - `zt` : 將當前行置於頁面頂端 - `zb` : 將當前行置於頁面尾端 - `H` : 將光標置於該頁面首 - `L` : 將光標至於該頁面尾 - `M` : 將光標至於該頁面中間 - `:行數` : 跳轉到第$行數$行 - `行數G` : 同上,主要用於錄製巨集,為了輸入的連貫性,避免進入其他模式的情況。 - `/` : 查找功能 - `n` : 找到下一段相符的文字 - `N` : 找到上一段相符的文字 ##### 水平移動 - `0` : 移動至行首 - `$` : 移動至行尾 - `^` : 移動到有文字的最前 - `g_` : 移動到有文字的最後 - `w` : 移動到當前位置往後看的第一個單字開頭 - `e` : 移動到當前位置往後看的第一個單字結尾 - `b` : 移動到當前位置往前看的第一個單字開頭 - `W` : 與`w`相同,以空格為基準。 - `E` : 與`e`相同,以空格為基準。 - `B` : 與`b`相同,以空格為基準。 行內查找功能 - `f 字符` : 移動到下一個$字符$處 - `t 字符` : 移動到下一個$字符$前一格 - `F 字符` : 移動到上一個$字符$處 - `T 字符` : 移動到上一個$字符$後一格 - `;` : 重複上一次查找 可以多種指令互相搭配,例如:`:wq`就是存檔後離開。 ### 插入模式 - `i` : 在當前位置進入插入模式 - `a` : 在當前位置下一格進入插入模式 - `o` : 在當前位置下方新增一行,進入插入模式 - `s` : 取代當前文字,並且進入插入模式 - `c` : 取代文字,須搭配光標移動指令 - `cw` : 替換一個單詞 - `c$` : 替換到結尾文字 - `cf"` : 替換到第一個引號 - `I` : 在當前行首進入插入模式 - `A` : 在當前行尾進入插入模式 - `O` : 在當前上一行進入插入模式 - `S` : 取代整行文字並進入插入模式 - `C` : 與`c$`相同作用 ### 選取模式 - `vi` : 進入選取模式,選取當前字元所在單詞 - `va` : 同`vi`,不過會多選取一個空格 - e.g. `viw` 選取當前字符所在單詞 - e.g. `vi)` 選取當前字符所在()內所有字符,要在()中才能正確選取 - e.g. `v2i{` 選取當前字符所在第二層{}內所有字符,要在至少兩層{}中才能正確選取 - e.g. `vit` 選取標籤格式的兩個標籤中的文字 - e.g. `vat` 選取包含標籤的所有文字 - `V` : 以行為單位進行選取 - `ctrl + v` : 以列為單位進行選取 - `"+y` : 複製選取的文字到系統剪貼簿 ```shell= vim --version | grep clipboard # -clipboard +keymap +printer +vertsplit # 由於該版本不支援系統 clipboard所以 apt-get install vim-gtk # 就能使用了 " ``` ### 寄存器 - `"q3yy` : `"q` 代表要使用`寄存器q`,`3yy`代表要複製三行,所以整個指令代表,複製三行文字到寄存器q - `"qp` : 將`寄存器q`中的內容貼上 - `"Qyy` : `寄存器q`中已有內容,要追加內容到該寄存器中時使用 - 寄存器的編號為 a\~z,0\~9 ### 書籤 須搭配寄存器使用 - `mq` : 當前光標位置紀錄到`寄存器q`中,僅限於該檔案中,若要跨檔案,要用大寫字母 - \``q` : 回到`寄存器q`紀錄的位置,僅限於該檔案中,若要跨檔案,要用大寫字母 - \`\` : 回到上一個位置 ### 巨集 在普通模式`q`+任意寄存器,代表開始錄製巨集 - `qq` : 代表開始錄製巨集,儲存於`寄存器q` - `q` : 代表錄製結束 - `@q` : 代表執行一次`寄存器q`中的巨集 - `@@` : 代表執行上一次執行的巨集 要特別注意開頭集結尾的位置,可先校正位置(0 確保跑到該行開頭) 另外,寄存器大寫時,代表追加其他巨集動作 ### 版面配置 #### 折疊(folding) ##### Generate the folding - `zfap` : 將游標所在處的那個段落折疊成一行 - `af7G` : 自游標所在處至全文第7行折疊 - `3,9fold` : 將第3行至第7行折疊 - `5zF` : 將游標所在處算起5行的內容折疊 ##### Operate the folding - `zo` : 將游標所在處折疊打開(z open) - `zc` : 將游標所在處已打開內容再度摺疊起來(z close) - `zr` : 將全文的所有折疊依層次通通打開(z reduce) - `zm` : 將全文的所有折疊依層次通通摺疊起來(z more) - `zR` : 與`zr`相同,但會打開巢狀折疊的所有折疊 - `zM` : 與`zm`相同,但對巢狀折疊亦有作用 - `zi` : 切換折疊與否 - `zn` : 打開全文所有折疊 - `zN` : 鄉退`zn`的指令,回覆所有折疊 ##### Memory of the folding - `:mkview` : 記憶當前文件折疊 - `loadview`: 載入之前記憶的折疊

    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