Cursor Line And Column - 進階應用
如何設定
設定外觀
hi CursorLine ctermfg=NONE ctermbg=237 cterm=NONE
hi CursorColumn ctermfg=NONE ctermbg=237 cterm=NONE
功能啟用
set cursorline
set cursorcolumn
綁定事件
au InsertLeave * set cursorline cursorcolumn
au InsertEnter * set nocursorline nocursorcolumn
au WinEnter * set cursorline cursorcolumn
au WinLeave * set nocursorline nocursorcolumn
也可以合併寫成如下
au InsertLeave,WinEnter * set cursorline cursorcolumn
au InsertEnter,WinLeave * set nocursorline nocursorcolumn
如何測試
執行下面指令,產生一個檔案,暫時先命名為「vimrc」,可以任意命名。
cat > vimrc << EOF
hi CursorLine ctermfg=NONE ctermbg=237 cterm=NONE
hi CursorColumn ctermfg=NONE ctermbg=237 cterm=NONE
set cursorline
set cursorcolumn
au InsertLeave,WinEnter * set cursorline cursorcolumn
au InsertEnter,WinLeave * set nocursorline nocursorcolumn
EOF
執行下面指令測試
$ vim -u ./vimrc