vim-colorschemes 是一个很好的主题合集,vim 的主题都放在 ~/.vim/colors 下(neovim 的放在 init.vim ?),没有请 mkdir ~/.vim/colors然后终端运行:

  1. git clone https://github.com/flazz/vim-colorschemes.git ~/vim-colorschemes
  2. 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 / 配置文件 添加以下内容:

      1. hi LineNr ctermfg=LightGrey
      2. hi Pmenu ctermbg=White
      3. hi PmenuSel ctermbg=LightCyan
      4. hi PmenuSbar ctermbg=White
      5. hi PmenuThumb ctermbg=Yellow

      提醒:修改配置不会对正在编辑文件的 vim 生效,如果要生效:在编辑文件窗口 :source 修改的配置文件 。或者 使用命令 hi Pmenu ctermbg=White 之类的临时预览,确定之后修改配置再重新打开所编辑的文件。

    • 使用 [:h highlight-ctermfg](http://vimhelp.appspot.com/syntax.txt.html#highlight-ctermfg) 查看支持的颜色名称(不支持 hex 颜色):

      1. ctermbg={color-nr} *highlight-ctermbg*
      2. The {color-nr} argument is a color number. Its range is zero to
      3. (not including) the number of tui-colors available.
      4. The actual color with this number depends on the type of terminal
      5. and its settings.
      6. [...]
      7. The following (case-insensitive) names are recognized:
      8. *cterm-colors*
      9. NR-16 NR-8 COLOR NAME ~
      10. 0 0 Black
      11. 1 4 DarkBlue
      12. 2 2 DarkGreen
      13. 3 6 DarkCyan
      14. 4 1 DarkRed
      15. 5 5 DarkMagenta
      16. 6 3 Brown, DarkYellow
      17. 7 7 LightGray, LightGrey, Gray, Grey
      18. 8 0* DarkGray, DarkGrey
      19. 9 4* Blue, LightBlue
      20. 10 2* Green, LightGreen
      21. 11 6* Cyan, LightCyan
      22. 12 1* Red, LightRed
      23. 13 5* Magenta, LightMagenta
      24. 14 3* Yellow, LightYellow
      25. 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.

      1. hl-ColorColumn

      ColorColumn used for the columns set with ‘colorcolumn’

      1. hl-Conceal

      Conceal placeholder characters substituted for concealed

      1. text (see 'conceallevel')
      2. hl-Cursor

      Cursor the character under the cursor lCursor the character under the cursor when language-mapping

      1. is used (see 'guicursor')
      2. hl-CursorIM

      CursorIM like Cursor, but used when in IME mode CursorIM

      1. hl-CursorColumn

      CursorColumn the screen column that the cursor is in when ‘cursorcolumn’ is

      1. set
      2. hl-CursorLine

      CursorLine the screen line that the cursor is in when ‘cursorline’ is

      1. set
      2. hl-Directory

      Directory directory names (and other special names in listings)

      1. hl-DiffAdd

      DiffAdd diff mode: Added line diff.txt

      1. hl-DiffChange

      DiffChange diff mode: Changed line diff.txt

      1. hl-DiffDelete

      DiffDelete diff mode: Deleted line diff.txt

      1. hl-DiffText

      DiffText diff mode: Changed text within a changed line diff.txt

      1. hl-EndOfBuffer

      EndOfBuffer filler lines (~) after the last line in the buffer.

      1. By default, this is highlighted like hl-NonText.
      2. hl-ErrorMsg

      ErrorMsg error messages on the command line

      1. hl-VertSplit

      VertSplit the column separating vertically split windows

      1. hl-Folded

      Folded line used for closed folds

      1. hl-FoldColumn

      FoldColumn ‘foldcolumn’

      1. hl-SignColumn

      SignColumn column where signs are displayed

      1. hl-IncSearch

      IncSearch ‘incsearch’ highlighting; also used for the text replaced with

      1. ":s///c"
      2. hl-LineNr

      LineNr Line number for “:number” and “:#” commands, and when ‘number’

      1. or 'relativenumber' option is set.
      2. hl-LineNrAbove

      LineNrAbove Line number for when the ‘relativenumber’

      1. option is set, above the cursor line.
      2. hl-LineNrBelow

      LineNrBelow Line number for when the ‘relativenumber’

      1. option is set, below the cursor line.
      2. hl-CursorLineNr

      CursorLineNr Like LineNr when ‘cursorline’ is set and ‘cursorlineopt’ is

      1. set to "number" or "both", or 'relativenumber' is set, for
      2. the cursor line.
      3. hl-MatchParen

      MatchParen The character under the cursor or just before it, if it

      1. is a paired bracket, and its match. pi_paren.txt
      2. hl-ModeMsg

      ModeMsg ‘showmode’ message (e.g., “— INSERT —“)

      1. hl-MoreMsg

      MoreMsg more-prompt

      1. hl-NonText

      NonText ‘@’ at the end of the window, characters from ‘showbreak’

      1. and other characters that do not really exist in the text
      2. (e.g., ">" displayed when a double-wide character doesn't
      3. fit at the end of the line).
      4. hl-Normal

      Normal normal text

      1. hl-Pmenu

      Pmenu Popup menu: normal item.

      1. hl-PmenuSel

      PmenuSel Popup menu: selected item.

      1. hl-PmenuSbar

      PmenuSbar Popup menu: scrollbar.

      1. hl-PmenuThumb

      PmenuThumb Popup menu: Thumb of the scrollbar.

      1. hl-Question

      Question hit-enter prompt and yes/no questions

      1. hl-QuickFixLine

      QuickFixLine Current quickfix item in the quickfix window.

      1. hl-Search

      Search Last search pattern highlighting (see ‘hlsearch’).

      1. Also used for similar items that need to stand out.
      2. hl-SpecialKey

      SpecialKey Meta and special keys listed with “:map”, also for text used

      1. to show unprintable characters in the text, 'listchars'.
      2. Generally: text that is displayed differently from what it
      3. really is.
      4. hl-SpellBad

      SpellBad Word that is not recognized by the spellchecker. spell

      1. This will be combined with the highlighting used otherwise.
      2. hl-SpellCap

      SpellCap Word that should start with a capital. spell

      1. This will be combined with the highlighting used otherwise.
      2. hl-SpellLocal

      SpellLocal Word that is recognized by the spellchecker as one that is

      1. used in another region. spell
      2. This will be combined with the highlighting used otherwise.
      3. hl-SpellRare

      SpellRare Word that is recognized by the spellchecker as one that is

      1. hardly ever used. spell
      2. This will be combined with the highlighting used otherwise.
      3. hl-StatusLine

      StatusLine status line of current window

      1. hl-StatusLineNC

      StatusLineNC status lines of not-current windows

      1. Note: if this is equal to "StatusLine" Vim will use "^^^" in
      2. the status line of the current window.
      3. hl-StatusLineTerm

      StatusLineTerm status line of current window, if it is a terminal window.

      1. hl-StatusLineTermNC

      StatusLineTermNC status lines of not-current windows that is a terminal

      1. window.
      2. hl-TabLine

      TabLine tab pages line, not active tab page label

      1. hl-TabLineFill

      TabLineFill tab pages line, where there are no labels

      1. hl-TabLineSel

      TabLineSel tab pages line, active tab page label

      1. hl-Terminal

      Terminal terminal window (see terminal-size-color)

      1. hl-Title

      Title titles for output from “:set all”, “:autocmd” etc.

      1. hl-Visual

      Visual Visual mode selection

      1. hl-VisualNOS

      VisualNOS Visual mode selection when vim is “Not Owning the Selection”.

      1. Only X11 Gui's gui-x11 and xterm-clipboard supports this.
      2. hl-WarningMsg

      WarningMsg warning messages

      1. hl-WildMenu

      WildMenu current match in ‘wildmenu’ completion

      1. 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.

  1. 结果展示:<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/2697283/1613554686463-ce0734c7-42b8-457c-ad14-93c1996cb177.png#height=478&id=Jb9xY&name=image.png&originHeight=955&originWidth=934&originalType=binary&size=82111&status=done&style=none&width=467)
  2. <a name="Cn2qL"></a>
  3. # 设置 gui 颜色
  4. 参考:[https://vi.stackexchange.com/questions/13458/make-vim-show-all-the-colors](https://vi.stackexchange.com/questions/13458/make-vim-show-all-the-colors)
  5. 1. vim 的配置文件中开启 gui
  6. ```bash
  7. set termguicolors
  1. 终端(或者模拟终端)软件必须支持和开启真彩色(true color)
  2. 配置 highlight :使用 guifg guibg gui 等参数。

关于颜色:

一些帮助信息:
: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

  1. highlight Error ctermbg=161
  2. highlight ErrorMsg NONE
  3. highlight link ErrorMsg Error

Error 必须已经被设置; ErrorMsg 必须被清除配置:如果不使用 NONE 来清除,则可以用 highlight! link ErrorMsg Error 来替代后两行语句。