Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem running Vim. I am editing files with recognisable file extensions - .xml, .php - however the text is black. This would not be a problem except I run terminal windows with a black background.

I can get to see my files by setting the terminal session to have a white background, but I would like a fix rather than a workaround.

I have renamed/moved the .vim and .viminfo files in my home directory but that has not magically restored my vim settings (that were fine yesterday morning).

Any ideas?

share|improve this question
up vote 6 down vote accepted

Try informing vim that your terminal has a black background with :set bg=dark. If your text is still black, try setting an environment variable that says your terminal is capable of color before you start vim by running export TERM=xterm-color.

share|improve this answer
Thank you very much for such a speedy reply! That worked a treat. – Mathew Jun 2 '11 at 9:39
Add whichever one of those fixed your issue to either ~/.vimrc or ~/.bashrc to make it a permanent preference. – Caleb Jun 2 '11 at 9:52
...I won't yet! I will reboot and see what happens. If there is no need then I will get a more definitive answer to post here. Obviously, running Ubuntu I only hibernate rather than reboot... – Mathew Jun 2 '11 at 11:21

I'm new to this site.

You can definitively set your background color in $HOME/(.)vimrc by writing the line

set bg=dark

I hope this help you.

share|improve this answer
Thanks for the tip - I cleared out my .vim* files and the colour scheme still persisted, even in new terminal windows. :set bg=dark worked for me, still not sure why! – Mathew Jun 2 '11 at 9:40
And welcome to SE - you will enjoy it...! – Mathew Jun 2 '11 at 9:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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