Ex 命令。| 操作 | 鍵位 | 備註 |
|---|---|---|
| 光標移動 | h/j/k/l (左/下/上/右) | 數字前綴加速,如 10j |
| 單詞跳轉 | w(下一詞首) b(上一詞首) e(詞尾) | |
| 行首/尾 | 0 / $ | |
| 文件首/尾 | gg / G | |
| 翻頁 | Ctrl+f / Ctrl+b | |
| 刪除字符 | x (光標下) X (光標前) | |
| 刪除單詞/行 | dw / dd | D = d$ |
| 復制/粘貼 | yy / p(後) P(前) | Y = yy |
| 撤銷/重做 | u / Ctrl+r | |
| 搜索 | /pattern (向下) ?pattern (向上) | n/N 下一個/上一個 |
| 可視模式 | v(字符) V(行) Ctrl+v(塊) | 配合 d/y/c 操作選區 |
:w 保存:w file 另存為:q 退出 (無修改):q! 強制退出:wq / :x 保存並退出:set nu 顯示行號:set nonu 隱藏行號:%s/old/new/g 全文替換:!cmd 執行 Shell 命令 set nocompatible " 關閉 vi 兼容模式set number " 顯示行號set relativenumber " 相對行號 (配合 dj/k 快速移動)set cursorline " 高亮當前行set wrap " 自動換行set tabstop=4 shiftwidth=4 expandtab " 縮進 4 空格set autoindent " 自動縮進set hlsearch " 高亮搜索set incsearch " 增量搜索set ignorecase smartcase " 智能大小寫set mouse=a " 啟用鼠標支持syntax on " 語法高亮filetype plugin indent on " 文件類型插件 進階插件管理:vim-plug,安裝 Plug 'preservim/nerdtree'、Plug 'vim-airline/vim-airline' 等。