Oeasy teaches you to play VIM – 24 – Custom Colors

Time:2022-4-30

custom colors

Recall the last lesson

  • This time we studied the color scheme

    • eurekacolorsLocation of
    • Downloaded and applied color scheme
    • Made their own color scheme
  • Now I want to change the color of the color scheme

    • Is it successful???

First, you have to have your own color scheme

Oeasy teaches you to play VIM - 24 - Custom Colors

#Find the location of colors
cd usr/share/vim/vim81/colors
#List all color schemes
ls
#Copy your own color scheme
sudo cp murphy.vim oeasy.vim
#View color scheme information
sudo vi oeasy.vim

Modify color scheme

Oeasy teaches you to play VIM - 24 - Custom Colors

  • The first five lines are comments
  • Line 7 cancels the original color matching
  • Line 8 set background
  • Lines 9-11 reset syntax highlighting
  • Line 12 names this color scheme, which can be modified tooeasy
  • Line 14 starts to set the colors of the various highlight groups
  • Let’s modify the first highlight group firstNormal

    • NormalI meanGeneral text
    • This type of text belongs to this highlight group
    • Similar to this are

      • notesComment
      • constantConstantetc.

Change the normal highlight group color

  • First, change the color scheme name tooeasy
  • findNormalgroup
  • holdNormalGroup background colorctermbgChange toblue
  • holdNormalForeground color of the groupctermfgChange toyellow
  • :wSave color file
  • colorscheme oeasyReset color file

Oeasy teaches you to play VIM - 24 - Custom Colors

View colors

  • :hi NormalCan viewNormalColor matching of groups
  • :hiYou can view all colors of the current color scheme
  • xxxIs the effect preview

Oeasy teaches you to play VIM - 24 - Custom Colors

Color details

  • hiyeshighlightAbbreviation of
  • :h hiYou can query help

Oeasy teaches you to play VIM - 24 - Custom Colors

Font features

  • :hi StatusLine
  • :hi StatusLine cterm=bold
  • :hi StatusLine cterm=bold,italic
  • :hi StatusLine cterm=bold,italic
  • :hi StatusLine cterm=bold,italic,underline
  • :hi StatusLine

Oeasy teaches you to play VIM - 24 - Custom Colors

  • term

    • intendterminal
    • A comma can be added between the effects
    • Corresponding black-and-white terminal
    • Not valid here
  • cterm

    • Bold bold
    • Underline underline
    • Italic tilt
    • None cancels any effects

Set color

  • hi StatusLine
  • hi StatusLine ctermfg=red ctermbg=blue
  • hi StatusLine
  • ctermfg

    • intendcolor terminal fore color
    • Foreground color settings
    • ctermfg=white
  • ctermbg

    • intendcolor terminal back color
    • Set by scene
    • ctermfg=red
  • guiRelated properties

    • Andguirelevant
    • No effect in current terminal
  • The color number corresponding to the color is the color value corresponding to ANSI from the system

Defines the color effect of the line where the cursor is located

  • Set cursor line highlighting
  • :set cursorline
  • :h 'cursorline'
  • :hi CursorLine
  • :hi CursorLine ctermbg=red ctermfg=white
  • :hi CursorLine
  • Cursorline moves as the cursor moves

Defines the color effect of the column where the cursor is located

  • Set cursor line highlighting
  • :set cursorcolumn
  • :h 'cursorcolumn'
  • :hi CursorColumn
  • :hi CursorColumn ctermbg=red ctermfg=white
  • :hi CursorColumn
  • As the cursor moves, the cursorcolumn moves
  • If there is a line feed problem

    • :set nowrap

Oeasy teaches you to play VIM - 24 - Custom Colors

Custom color name

  • definitionoeasygroup

    • :hi oeasy ctermbg=white ctermfg=red
  • seeoeasygroup

    • :hi oeasy
  • applicationoeasygroup

    • :set statusline=%#oeasy#%F%*

Oeasy teaches you to play VIM - 24 - Custom Colors

configuration file

  • set statusline=%-040.40(%F%m%)%-030.30([%l,%c]%)%p%%
  • set laststatus=2
  • set ruler
  • set number
  • set showcmd
  • set nocompatible
  • set showcmd
  • set showmode
  • set history=100
  • set t_Co=256
  • colorscheme blue
  • set cursorline
  • hi CursorLine ctermbg=red ctermfg=white
  • set cursorcolumn
  • hi CursorColumn ctermbg=red ctermfg=white

summary

  • We went deep into the color scheme this time

    • The specific color matching in the scheme has been modified
    • Established its own color matching
    • Applied your own color
  • Is there anything interesting in the configuration?

    • It’s red, green and blue
    • Can I have more colors?
  • Next time