以下是如何在Vim中隨處替換顏色。首先,在vim使用:highlight
命令查看所有預定義色組的一個樣本。您還應該閱讀:help highlight
的輸出以查看所有顏色突出顯示組的定義。
一旦你已經確定你想改變一個候選替換組(更好的色彩)的組,請使用如下命令:
" Fix the difficult-to-read default setting for search/replace text
" highlighting. The bang (!) is required since we are overwriting the
" DiffText setting. Use the ":highlight" command in vim to see
" alternate color choices if you don't like "Todo" or "StatusLine"
highlight! link IncSearch Todo " Yellow
highlight! link Search StatusLine " Light tan
" Fix the difficult-to-read default setting for diff text highlighting.
" The bang (!) is required since we are overwriting the DiffText
" setting. The highlighting for "Todo" also looks nice (yellow) if you
" don't like the "MatchParen" (Aqua) diff color.
highlight! link DiffText MatchParen " Aqua
" highlight! link DiffText Todo " Yellow
爲highlight
vim的幫助表示你也可以指定顏色十六進制RGB像:
:highlight Comment guifg=#11f0c3 guibg=#ff00ff
也有很多很好的信息可以通過使用:help syntax
發現。
與往常一樣,一旦找到你喜歡的顏色,你應該將它們保存在〜/ .vimrc文件中(當然保存在Git中),這樣每次啓動GVim時都會自動應用它們。