vim-colorschemes 是一个很好的主题合集,vim 的主题都放在 ~/.vim/colors
下(neovim 的放在 init.vim
?),没有请 mkdir ~/.vim/colors
然后终端运行:
git clone https://github.com/flazz/vim-colorschemes.git ~/vim-colorschemes
cp ~/vim-colorschemes/colors/* .vim/colors
- 在 vim 界面使用
:colorscheme <按tab>
和 Enter 来预览主题,永久使用主题需要写入 vimrc 配置文件(见最后面) 调整默认主题的技巧:针对
LightDefault
主题- 可以开两个终端界面,一个更改主题配置(使用
:w
而不是:wq
来保存不退出),一个使用:colorscheme LightDefault
命令来更新主题 例如弹出框的背景色默认为 Magenta (紫红色)修改成 White、选中项改成和滚动条 LightCyan (淡青色);行号默认为 Yellow (黄色)要修改成 LightGrey(浅灰色),可以在
~/.vim/colors/LightDefault.vim
/ 配置文件 添加以下内容:hi LineNr ctermfg=LightGrey
hi Pmenu ctermbg=White
hi PmenuSel ctermbg=LightCyan
hi PmenuSbar ctermbg=White
hi PmenuThumb ctermbg=Yellow
提醒:修改配置不会对正在编辑文件的 vim 生效,如果要生效:在编辑文件窗口
:source 修改的配置文件
。或者 使用命令hi Pmenu ctermbg=White
之类的临时预览,确定之后修改配置再重新打开所编辑的文件。使用
[:h highlight-ctermfg](http://vimhelp.appspot.com/syntax.txt.html#highlight-ctermfg)
查看支持的颜色名称(不支持 hex 颜色):ctermbg={color-nr} *highlight-ctermbg*
The {color-nr} argument is a color number. Its range is zero to
(not including) the number of tui-colors available.
The actual color with this number depends on the type of terminal
and its settings.
[...]
The following (case-insensitive) names are recognized:
*cterm-colors*
NR-16 NR-8 COLOR NAME ~
0 0 Black
1 4 DarkBlue
2 2 DarkGreen
3 6 DarkCyan
4 1 DarkRed
5 5 DarkMagenta
6 3 Brown, DarkYellow
7 7 LightGray, LightGrey, Gray, Grey
8 0* DarkGray, DarkGrey
9 4* Blue, LightBlue
10 2* Green, LightGreen
11 6* Cyan, LightCyan
12 1* Red, LightRed
13 5* Magenta, LightMagenta
14 3* Yellow, LightYellow
15 7* White
以及支持的参数: ``` highlight-groups highlight-default These are the default highlighting groups. These groups are used by the ‘highlight’ option default. Note that the highlighting depends on the value of ‘background’. You can see the current settings with the “:highlight” command.
hl-ColorColumn
ColorColumn used for the columns set with ‘colorcolumn’
hl-Conceal
Conceal placeholder characters substituted for concealed
text (see 'conceallevel')
hl-Cursor
Cursor the character under the cursor lCursor the character under the cursor when language-mapping
is used (see 'guicursor')
hl-CursorIM
CursorIM like Cursor, but used when in IME mode CursorIM
hl-CursorColumn
CursorColumn the screen column that the cursor is in when ‘cursorcolumn’ is
set
hl-CursorLine
CursorLine the screen line that the cursor is in when ‘cursorline’ is
set
hl-Directory
Directory directory names (and other special names in listings)
hl-DiffAdd
DiffAdd diff mode: Added line diff.txt
hl-DiffChange
DiffChange diff mode: Changed line diff.txt
hl-DiffDelete
DiffDelete diff mode: Deleted line diff.txt
hl-DiffText
DiffText diff mode: Changed text within a changed line diff.txt
hl-EndOfBuffer
EndOfBuffer filler lines (~) after the last line in the buffer.
By default, this is highlighted like hl-NonText.
hl-ErrorMsg
ErrorMsg error messages on the command line
hl-VertSplit
VertSplit the column separating vertically split windows
hl-Folded
Folded line used for closed folds
hl-FoldColumn
FoldColumn ‘foldcolumn’
hl-SignColumn
SignColumn column where signs are displayed
hl-IncSearch
IncSearch ‘incsearch’ highlighting; also used for the text replaced with
":s///c"
hl-LineNr
LineNr Line number for “:number” and “:#” commands, and when ‘number’
or 'relativenumber' option is set.
hl-LineNrAbove
LineNrAbove Line number for when the ‘relativenumber’
option is set, above the cursor line.
hl-LineNrBelow
LineNrBelow Line number for when the ‘relativenumber’
option is set, below the cursor line.
hl-CursorLineNr
CursorLineNr Like LineNr when ‘cursorline’ is set and ‘cursorlineopt’ is
set to "number" or "both", or 'relativenumber' is set, for
the cursor line.
hl-MatchParen
MatchParen The character under the cursor or just before it, if it
is a paired bracket, and its match. pi_paren.txt
hl-ModeMsg
ModeMsg ‘showmode’ message (e.g., “— INSERT —“)
hl-MoreMsg
MoreMsg more-prompt
hl-NonText
NonText ‘@’ at the end of the window, characters from ‘showbreak’
and other characters that do not really exist in the text
(e.g., ">" displayed when a double-wide character doesn't
fit at the end of the line).
hl-Normal
Normal normal text
hl-Pmenu
Pmenu Popup menu: normal item.
hl-PmenuSel
PmenuSel Popup menu: selected item.
hl-PmenuSbar
PmenuSbar Popup menu: scrollbar.
hl-PmenuThumb
PmenuThumb Popup menu: Thumb of the scrollbar.
hl-Question
Question hit-enter prompt and yes/no questions
hl-QuickFixLine
QuickFixLine Current quickfix item in the quickfix window.
hl-Search
Search Last search pattern highlighting (see ‘hlsearch’).
Also used for similar items that need to stand out.
hl-SpecialKey
SpecialKey Meta and special keys listed with “:map”, also for text used
to show unprintable characters in the text, 'listchars'.
Generally: text that is displayed differently from what it
really is.
hl-SpellBad
SpellBad Word that is not recognized by the spellchecker. spell
This will be combined with the highlighting used otherwise.
hl-SpellCap
SpellCap Word that should start with a capital. spell
This will be combined with the highlighting used otherwise.
hl-SpellLocal
SpellLocal Word that is recognized by the spellchecker as one that is
used in another region. spell
This will be combined with the highlighting used otherwise.
hl-SpellRare
SpellRare Word that is recognized by the spellchecker as one that is
hardly ever used. spell
This will be combined with the highlighting used otherwise.
hl-StatusLine
StatusLine status line of current window
hl-StatusLineNC
StatusLineNC status lines of not-current windows
Note: if this is equal to "StatusLine" Vim will use "^^^" in
the status line of the current window.
hl-StatusLineTerm
StatusLineTerm status line of current window, if it is a terminal window.
hl-StatusLineTermNC
StatusLineTermNC status lines of not-current windows that is a terminal
window.
hl-TabLine
TabLine tab pages line, not active tab page label
hl-TabLineFill
TabLineFill tab pages line, where there are no labels
hl-TabLineSel
TabLineSel tab pages line, active tab page label
hl-Terminal
Terminal terminal window (see terminal-size-color)
hl-Title
Title titles for output from “:set all”, “:autocmd” etc.
hl-Visual
Visual Visual mode selection
hl-VisualNOS
VisualNOS Visual mode selection when vim is “Not Owning the Selection”.
Only X11 Gui's gui-x11 and xterm-clipboard supports this.
hl-WarningMsg
WarningMsg warning messages
hl-WildMenu
WildMenu current match in ‘wildmenu’ completion
hl-User1 hl-User1..9 hl-User9
The ‘statusline’ syntax allows the use of 9 different highlights in the statusline and ruler (via ‘rulerformat’). The names are User1 to User9.
- 可以开两个终端界面,一个更改主题配置(使用
For the GUI you can use the following groups to set the colors for the menu, scrollbars and tooltips. They don’t have defaults. This doesn’t work for the Win32 GUI. Only three highlight arguments have any effect here: font, guibg, and guifg.
结果展示:<br />
<a name="Cn2qL"></a>
# 设置 gui 颜色
参考:[https://vi.stackexchange.com/questions/13458/make-vim-show-all-the-colors](https://vi.stackexchange.com/questions/13458/make-vim-show-all-the-colors)
1. 在 vim 的配置文件中开启 gui:
```bash
set termguicolors
- 终端(或者模拟终端)软件必须支持和开启真彩色(true color)
- 配置 highlight :使用
guifg
guibg
gui
等参数。
关于颜色:
- 256 颜色代码、名称、编号:https://jonasjacek.github.io/colors/
- 256 颜色名称、分类、代码:https://html-color-codes.info/color-names/
- 调色盘:https://paletton.com/
- https://www.materialpalette.com/colors
- 分类型变量配色:https://colorbrewer2.org/
一些帮助信息::h termguicolors
:h highlight-args
:h cterm-colors
把 hi 的配置项链接到另一个配置项
参考:https://stackoverflow.com/questions/26958070/how-do-i-link-highlighting-groups-in-a-vim-colour-scheme
例子:把 ErrorMsg
的配置链接到 Error
highlight Error ctermbg=161
highlight ErrorMsg NONE
highlight link ErrorMsg Error
Error
必须已经被设置; ErrorMsg
必须被清除配置:如果不使用 NONE 来清除,则可以用 highlight! link ErrorMsg Error
来替代后两行语句。