Muffinresearch Labs by Stuart Colville

Vim: Setting the colorscheme Doesn’t Work | Comments (5)

Posted in Linux/Unix on 28th April 2009, 9:29 pm by Stuart

If you’ve found a fancy colorscheme for vim and you want to try it out, once you’ve saved the colorscheme file to ~/.vim/colors you can enable the theme with the following in a vim session’s command mode:

:colorscheme fruity

If you want the colorscheme to be permanent then you can set the name of the theme in your ~/.vimrc file with:

colorscheme fruity

However if this doesn’t work then it’s probably that your terminal doesn’t support enough colors. Fixing the amount of colors the terminal can display is fairly easy by simply exporting the TERM environment variable to use the 256 color xterm. (Sadly this is not possible on OSX’s leopard terminal as it only supports 16 colors though apparently iTerm does have 256 color support)

export TERM=xterm-256color

An alternative to this is to start vim with the terminal switch set to xterm-256color e.g:

vim -T xterm-256color

Once this is done the colorschemes should work just fine.

Simplying the colors used by gvim themes

Another issue that you can hit is when trying to use a gvim (gui version) theme in vim it may specify colors that don’t fit within the range your terminal is capable of displaying. CSApprox is a plugin which converts the colors in gvim themes to the closest color that will work with your term see http://www.vim.org/scripts/script.php?script_id=2390 for more info.

Post Tools

Comments: Add yours

1. On April 29th, 2009 at 11:51 am Bradley Wright said:

You can also fork the display logic in your .vimrc like so:

if has('gui_running')
colorscheme ir_black
else
colorscheme desert
end

2. On April 29th, 2009 at 11:56 am Stuart Colville said:

@Bradley Wright: nice tip

3. On April 29th, 2009 at 1:27 pm Bradley Wright said:

To be clear, “gui_running” is set by GVim, so that clause will never be true in the CLI version.

4. On April 30th, 2009 at 2:47 am Jim Klo said:

Actually, Bradley – gvim is just vim with gui extensions compiled in … the gui_running flag is honored AFAIK for all versions of VIM regardless

5. On May 7th, 2009 at 8:28 am Stuart Colville said:

If you’re finding you don’t have xterm-256color on your machine I found that installation of the ncurses-term package provided it on Hardy for example.







XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



GNU screen: open tab in current working directory|(1)

A nice trick for having screen open a new tab in the same directory as the one you’re currently in. To use it add it to your .screenrc

# Open new window in current dir.
bind c stuff "screen -X chdir \$PWD;screen^M"
bind ^c stuff "screen -X chdir \$PWD;screen^M"

Hat tip: mteckert on SuperUser.com

Ubuntu: add-apt-repository: command not found|(2)

When you’re using a minimal Ubuntu install if you find the ‘add-apt-repository’ command is missing (it’s useful for adding PPAs and other repositories), then simply run:

sudo apt-get install python-software-properties

Photos on Flickr

© Copyright 2004-12 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by Slicehost.com This page was baked in 0.547s.