1

I am using vim 7.4.52 in Ubuntu 14.04 LTS.My vim background color is darkblue. I set this in .vimrc using set background darkblue

Now I want to set the background color with another color using hex code.

Is there any system to set this? i.e.set background=#300A24(this is my default terminal color)

  • 1
    :h 'background' :h hl-Normal – Christian Brabandt Sep 30 '16 at 9:45
  • @Christian Brabandt, this means what? – alhelal Oct 2 '16 at 11:30
  • 1
    It means to read the help – Christian Brabandt Oct 2 '16 at 13:20
3

To set the background (and foreground) to some explicit color, you probably want to use a highlight command in your vimrc, such as

" plain text
hi Normal     ctermfg=227 ctermbg=17

(assuming you are indeed in a terminal and not a gvim window).

The color codes '227' and '17' are interpreted in the terminal, and, sadly, they are not simple hex codes. To find which colors they correspond to in a given terminal, you can use this little script:

#!/usr/bin/bash   
for i in {0..255} ; do
  printf "\x1b[38;5;${i}mcolour${i} "
done
  • 2
    I think that an important point to add to your answer is that the command used by OP was nonsensical: From :h 'background' you can see that background can only have two values light or dark, the doc says Setting this option does not change the background color, it tells Vim what the background color looks like.. So using background is not meant to change the background color. – statox Sep 30 '16 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.