Vim-vimrc 快捷鍵映射
文章目錄
- Vim-vimrc 快捷鍵映射
- Leader 鍵
- 快捷鍵映射:插入特定字符
- 插入 `--`
- 插入 `##`
- 插入 `==`
- 解釋
- Leader鍵設置
- 快速插入分隔線
Leader 鍵
我們還將 ,
設置為 Leader 鍵,使得其他快捷鍵映射更加簡潔。
let mapleader = ","
快捷鍵映射:插入特定字符
在 Vim 中,你可以使用快捷鍵插入特定的字符,比如連續的 -
或 =
,使文本編輯更加高效。
插入 --
nnoremap <leader>-- i-------------------------------<Esc>
插入 ##
nnoremap <leader>## i###############################<Esc>
插入 ==
nnoremap <leader>== i===============================<Esc>
解釋
- 使用
nnoremap
映射鍵位來插入特定的字符。 - 例如,
<leader>--
會插入連續的--
,<leader>##
會插入連續的#
。
Leader鍵設置
" Leader Key
let mapleader = ","
將Leader鍵設置為逗號,便于創建更多自定義快捷鍵組合。
快速插入分隔線
" Map shortcut -- to insert --------------------------
nnoremap -- i-------------------------------<Esc>" Map shortcut ## to insert ###########################
nnoremap ## i###############################<Esc>" Map shortcut == to insert ===========================
nnoremap == i===============================<Esc>
使用方法:
- 輸入
--
快速插入破折號分隔線 - 輸入
##
快速插入井號分隔線 - 輸入
==
快速插入等號分隔線