Thalatta
Thalatta

Reputation: 4578

How to set a black background

I cannot figure out how to set the background color to black in Vim. I am running Vim from Mac OS X 10.5.8's Terminal.app (does this mean that I am using MacVim?).

My .gvimrc file looks like this:

syntax on
set background = dark

All this appears to accomplish is to make text more bold than before.

Doing things like

:highlight Normal guibg=Black

in Vim doesn't seem to do anything either.

Also should I have anything in my .vimrc file? I am not sure which configuration file is relevant to the Vim that is automatically installed on Mac OSX (that is accessible with the vim command at the terminal).

Upvotes: 1

Views: 11995

Answers (2)

romainl
romainl

Reputation: 196476

Well, technically, it is very possible to use MacVim in a terminal. I do that everyday and it works great!

But you are using Mac OS X's default Vim in a terminal. Since it's not a GUI version of Vim, it won't read your ~/.gvimrc and it won't apply :hi Normal guibg=black for obvious reasons.

Settings for CLI Vim and general settings should go into ~/.vimrc, leaving ~/.gvimrc for GUI-specific settings.

To get a black background in CLI Vim, type the following in normal mode:

:hi Normal ctermbg=black

To persist this setting, add the same line (without the :) to your ~/.vimrc, preferably after any colorscheme command.

Depending on the colorscheme you are using, Normal may not be the only place where to do that change.

Upvotes: 8

FDinoff
FDinoff

Reputation: 31419

If you are using Terminal.app you are not using MacVim. MacVim is a standalone gVim package for mac.

To change the background to be black you need to change Terminal.app's Preferences.

Go to Preferences -> Settings and choose Pro under profiles on the left. (Or create your own profile that has a black background.)

Also those commands should be in .vimrc instead of .gvimrc. To understand the difference of the two type :h vimrc and :h gvimrc in vim.

Upvotes: 4

Related Questions