TYPO free

home

fighting for TYPO free code

VIM colors

11 Feb 2009

I look at a terminal window a lot during the course of the day. I also use VIM quite a lot for editing configuration files and scripts. I was really happy when I discovered that VIM can do syntax highlighting so I can look at pretty colors. Pretty colors make my life behind the screen more bearable.

I was happily coding until I came across a page explaining about 256 color terminals and 256 color support in VIM. Of course I wanted this too. The normal 16 color themes are all quite 'hard' on the eyes. The 256 color based themes are much easier on the eyes. I tried a couple of themes. I liked zenburn the most.

But soon I learnt how to make my own colorscheme and use that. It took me a while to add the last bits of color to it. I only recently learnt about the joys of 'tab mode' in VIM and just last week I reworked the 'vimdiff' colors.

I don't use gvim at all, so I only have the colorscheme for terminals. Here it is:

  1. " Vim color file
  2. " Name: typofree.vim
  3. " Maintainer: Michiel Roos <[email protected]>
  4. " Created: ma 06 okt 2008 07:29:31 pm CEST
  5. " Last Modified: wo 25 feb 2009 09:41:12 am CET
  6. " License: This file is placed in the public domain.
  7. " Version: 0.1 alpha
  8. "
  9. " This is a 256 color theme for xterm-256color
  10.  
  11. set background=dark
  12. hi clear
  13. if exists("syntax_on")
  14. syntax reset
  15. endif
  16.  
  17. let colors_name = "typofree"
  18.  
  19. hi Normal ctermfg=247 ctermbg=NONE cterm=NONE
  20. hi SpecialKey ctermfg=127 ctermbg=NONE cterm=NONE " ^M
  21. hi NonText ctermfg=20 ctermbg=NONE cterm=NONE " e.g. the + symbol on line wrap
  22. hi PreProc ctermfg=68 ctermbg=NONE cterm=NONE
  23.  
  24. hi Cursor ctermfg=130 ctermbg=NONE cterm=NONE
  25. hi CursorLine ctermfg=NONE ctermbg=NONE cterm=underline
  26. hi CursorColumn ctermfg=NONE ctermbg=234 cterm=NONE
  27.  
  28. hi DiffAdd ctermfg=NONE ctermbg=22 cterm=NONE
  29. hi DiffDelete ctermfg=NONE ctermbg=52 cterm=NONE
  30. hi DiffChange ctermfg=NONE ctermbg=17 cterm=NONE
  31. hi DiffText ctermfg=NONE ctermbg=NONE cterm=underline
  32.  
  33. hi ModeMsg ctermfg=65 ctermbg=NONE cterm=NONE
  34. hi MoreMsg ctermfg=65 ctermbg=NONE cterm=NONE
  35. hi Question ctermfg=65 ctermbg=NONE cterm=NONE
  36.  
  37. hi Pmenu ctermfg=16 ctermbg=23 cterm=NONE
  38. hi PmenuSel ctermfg=65 ctermbg=23 cterm=NONE
  39. hi PmenuSbar ctermfg=16 ctermbg=23 cterm=NONE
  40. hi PmenuThumb ctermfg=65 ctermbg=23 cterm=NONE
  41.  
  42. hi IncSearch ctermfg=209 ctermbg=88 cterm=NONE
  43. hi Search ctermfg=209 ctermbg=88 cterm=NONE
  44. "hi NonText ctermfg=38 ctermbg=NONE cterm=NONE
  45. hi Visual ctermfg=231 ctermbg=60 cterm=NONE
  46. hi Error ctermfg=231 ctermbg=88 cterm=NONE
  47.  
  48. hi FoldColumn ctermfg=88 ctermbg=NONE cterm=NONE
  49. hi Folded ctermfg=108 ctermbg=23 cterm=NONE
  50.  
  51. hi StatusLineNC ctermfg=94 ctermbg=234 cterm=NONE
  52. hi StatusLine ctermfg=208 ctermbg=236 cterm=NONE
  53. hi VertSplit ctermfg=16 ctermbg=23 cterm=NONE
  54.  
  55. " Tab menu
  56. hi TabLineSel ctermfg=208 ctermbg=NONE cterm=NONE
  57. hi TabLineFill ctermfg=94 ctermbg=236 cterm=underline
  58. hi TabLine ctermfg=94 ctermbg=236 cterm=underline
  59.  
  60. hi Comment ctermfg=240 ctermbg=NONE cterm=NONE
  61. hi Todo ctermfg=16 ctermbg=94 cterm=NONE
  62.  
  63. hi String ctermfg=65 ctermbg=NONE cterm=NONE " 'blah'
  64. "hi Character ctermfg=65 ctermbg=NONE cterm=NONE
  65. hi Number ctermfg=88 ctermbg=NONE cterm=NONE
  66. hi Boolean ctermfg=127 ctermbg=NONE cterm=NONE
  67. hi Float ctermfg=88 ctermbg=NONE cterm=NONE
  68. hi Constant ctermfg=127 ctermbg=NONE cterm=NONE
  69.  
  70. hi Identifier ctermfg=68 ctermbg=NONE cterm=NONE " the text in $blah
  71. hi Function ctermfg=137 ctermbg=NONE cterm=NONE " init() substr()
  72.  
  73. hi Define ctermfg=28 ctermbg=NONE cterm=NONE " function
  74. hi Statement ctermfg=130 ctermbg=NONE cterm=NONE " $ = : . return if exit for
  75. hi Conditional ctermfg=130 ctermbg=NONE cterm=NONE " if then else
  76. hi Repeat ctermfg=130 ctermbg=NONE cterm=NONE " foreach while
  77. hi Label ctermfg=130 ctermbg=NONE cterm=NONE "
  78.  
  79. hi Operator ctermfg=178 ctermbg=NONE cterm=NONE " $ = : . return if exit for
  80.  
  81. hi Include ctermfg=28 ctermbg=NONE cterm=NONE " require include
  82. hi Type ctermfg=28 ctermbg=NONE cterm=NONE
  83. hi StorageClass ctermfg=28 ctermbg=NONE cterm=NONE
  84. hi Structure ctermfg=28 ctermbg=NONE cterm=NONE " class ->
  85. hi Typedef ctermfg=28 ctermbg=NONE cterm=NONE
  86.  
  87. hi Special ctermfg=88 ctermbg=NONE cterm=NONE " () {} []
  88. hi SpecialChar ctermfg=88 ctermbg=NONE cterm=NONE " hex, ocatal etc.
  89. " hi Delimiter ctermfg=88 ctermbg=NONE cterm=NONE

Save this in a file, store it under a name like 'typofree.vim' and put it in the folder ~/.vim/colors/

Now you can load your theme using the following command from within VIM:

colorscheme typofree

Great!

Now I changed my .vimrc to include the following snippet that makes my coloscheme load automagically when starting VIM from a 256 color capable terminal:

  1. " Set up pretty colors
  2. if &term ==? "xterm-256color" || &term ==? "screen-256color-bce"
  3. set t_Co=256
  4. colorscheme typofree
  5. else
  6. colorscheme default
  7. endif

That's it. Enjoy!

Cut and paste goodness can be found in the scripts section.

Steffen 12 Mar 2009, 11:58
Copy/pasted the examples and line numbers still stick to it? Remove the bogus stuff by using:
%s/^\s\{}\d\{}\.\n\s\{}//g
Michiel 12 Mar 2009, 12:22
Get your copy and paste version from the scripts section (link at the bottom of the article).
Steffen 12 Mar 2009, 22:03
Doesn't work on my machine.
Btw: your timtab feed is broken: links are sometimes prefixed with https:// and sometimes with https://
Commenting is closed for this item