Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Vim: Use background to Match Colors of Windows Console

📅 2011-Jul-29 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ vim, windows ⬩ 📚 Archive

Left: Default colors of Vim are horrible with background=dark. Right: With background=light

The default text, background and highlighting colors used by GVim are white-on-black and that for non-GUI Vim is black-on-white. If you have set your Windows command prompt to white-on-black or any other choice of dark-over-light colors, then non-GUI Vim renders in ugly and unreadable colors.

This can be fixed easily by switching the background property of Vim. This is not the background color per se, but influences the colors used by Vim for all aspects of its display like text, background and highlighting. The only two possible values for this property are light and dark. By default, background is set to light for GVim and is set to dark for non-GUI Vim.

So, to make non-GUI Vim use sane colors on a white-on-black Windows command prompt, use the command :set background=light. To make this permanent, add this setting to your vimrc file.

Note: All of this assumes that you have not changed the theme, colors and related settings applied by default by Vim.

Tried with: Vim 7.3

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