Skip to content

Instantly share code, notes, and snippets.

@ykrsm
Created August 13, 2017 06:32
Show Gist options
  • Save ykrsm/a5f9f0e59c14ba498302b7780e988b99 to your computer and use it in GitHub Desktop.
Save ykrsm/a5f9f0e59c14ba498302b7780e988b99 to your computer and use it in GitHub Desktop.
How to tweak your favorite Vim color Scheme.

tl;dr

  1. You can check color by :hi
  2. Change colors in your .vimrc
" Reset the background color in Normal mode so vim uses Terminal.app's background color"
highlight Normal ctermbg=none
" Reset the background color in Non Text area so vim uses Terminal.app's background color"
highlight NonText ctermbg=none

Problem

I found a cool vim color schemes but I did not fully get satisfied with colors.
But I am too lazy to build my own scheme.😣

Or sometimes, I found a scheme but it did not match with my Terminal background color.

Solution

Reveal your un-satisfaction

Open your vim and type :hi You can see a list of syntax highliting. All you have to do is find the part you want to change and keep the name such as Visual.We will use them later. If you do :hi in vim, you shoudl get something like this. :hi command

Change the color

Now that you know what you change, let's tweak the vim scheme

You can write the changes in your .vimrc

Let's take a look at my .vimrc

" Change the text color of Dictionary
highlight Directory ctermfg=blue
" Change the color of string when vertical split view is used
" Here I change the background color to none, which resets to the default"
" also, change the text color to blue"
highlight VertSplit ctermbg=none ctermfg=blue

There is only few things that you have to know

  • ctermfg : Stands for color terminal foreground, which means text color

  • ctermbf : Stands for color terminal background

  • If you want to reset the color use none. This is very useful when you are trying to match your vim background color and termianl color

  • Just add below to your .vimrc and you can match your vim color to your terminal color

" Reset the background color in Normal mode so vim uses Terminal.app's background color"
highlight Normal ctermbg=none
" Reset the background color in Non Text area so vim uses Terminal.app's background color"
highlight NonText ctermbg=none
@preshetin
Copy link

thank you! Works like charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment