Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to set background in Vim

📅 2013-Feb-17 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ background, vim ⬩ 📚 Archive

The background setting in Vim is used to determine what colors to use for rendering the various elements of the editor. The setting takes one of only two values: dark or light.

By default, light background is used for GVim. For terminal Vim, the default background value is set based on the terminal. So, sometimes you may be using a dark terminal, but Vim might still use the light background. This results in weird colors that make Vim hard to use.

To control the background yourself, set it in your vimrc. For example, I like to set light background for GVim and dark background for all terminals:

" Dark background for Vim and light for GVim
if has( "gui_running" )
    set background=light
    set background=dark

Tried with: Vim 7.3 and Ubuntu 12.04 LTS

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧