sponsor Vim development Vim logo Vim Book Ad

changeColorScheme.vim : change color schemes

 script karma  Rating 34/13, Downloaded by 2233  Comments, bugs, improvements  Vim wiki

created by
Hosup Chung
 
script type
utility
 
description
Got ideas from following tips and scripts
vimtip #341, vimtip #358, vimscript #668, vimscript #109

Usage:
When this script is loaded, it will populate an array with each of color
scheme's file path.  You can then load different color schemes using
NextColorScheme(), PreviousColorScheme() or RandomColorScheme().

Or if you don't like current color scheme you can call
RemoveCurrentColorScheme() to remove the file.

There are 4 main functions
   1. You can either call them directly
      :call NextColorScheme()
      :call PreviousColorScheme()
      :call RandomColorScheme()
      :call RemoveCurrentColorScheme()

   2. You can map and save them in your [._]gvimrc.
      map <F4>   :call NextColorScheme()<CR>
      map <S-F4> :call PreviousColorScheme()<CR>
      map <C-F4> :call RandomColorScheme()<CR>
      map <F3>   :call RemoveCurrentColorScheme()<CR>

   3. You can also start each vim session with random color scheme by
      adding following line in your [._]gvimrc
      call RandomColorScheme()

Tip:
You can change your rulerformat in your [._]vimrc to display the name of
current color scheme on status line.

First, add this line to display status information
     set ruler

And add %{g:colors_name} in rulerformat to display name of current color
  scheme. For example,
     set rulerformat=%55(:%{g:colors_name}:\ %5l,%-6(%c%V%)\ %P%)

However, you will see an error message if you didn't load color scheme at
startup. So you might want to add %{GetColorSyntaxName()} instead.
     set rulerformat=%55(:%{GetColorSyntaxName()}:\ %5l,%-6(%c%V%)\ %P%)

GetColorSyntaxName() function is included in this script. It returns
the value of g:colors_name if it exists, otherwise an empty string. If you
are using a console version, then you might have to copy
GetColorSyntaxName() into .vimrc, because I think the plugin files get
loaded after evaluating .vimrc.
 
install details
Copy changeColorScheme.vim in your plugin directory
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
changeColorScheme.vim 0.4 2010-07-23 6.0 Hosup Chung added RemoveCurrentColorScheme() function (requested by auto didakto). If you don't like current color scheme, you can call RemoveCurrentColorScheme() to delete the color scheme file.
changeColorScheme.vim 0.3 2006-03-20 6.0 Hosup Chung updated code to handle file not found error due to color schemes were removed
changeColorScheme.vim 0.2 2006-02-03 6.0 Hosup Chung Updated RandomColorScheme()
changeColorScheme.vim 0.12 2004-08-17 6.0 Hosup Chung I finally tested this plugin on OS X and Linux
When searching color schemes, substituting eol didn't work on Linux.
I'm using "\n" instead of '\n' now, and it seems working.
ip used for rating: 18.218.184.214

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github