bash script to change the vim colorscheme from the list of locally available schemes

\"MacVim
Image via Wikipedia

Today I was just wondering how good it would be to have a script to change the vim colorscheme from the command prompt. The plan for the script was simply to print the list of available schemes and then let the user select the actions from there on. So, here is the result:

#!/bin/bash –
#===============================================================================
#
#          FILE:  change_vim_colorscheme.sh
#
#         USAGE:  ./change_vim_colorscheme.sh
#
#   DESCRIPTION: Change the vim colorscheme from command prompt
#
#       OPTIONS:  —
#  REQUIREMENTS:  —
#          BUGS:  —
#         NOTES:  —
#        AUTHOR:  Amit Agarwal (AKA), amit.agarwal@amit-agarwal.co.in
#       COMPANY:  Individual
#       VERSION:  1.0
#       CREATED:  02/02/2010 10:30:07 PM IST
#      REVISION:  —
#===============================================================================

cd ~/.vim/colors
for i in *.vim
do
echo \”${i%.vim}\”
done

read -p \”Enter one of the colorschemes :: \” choice
file=~/.vim/colors/$choice.vim
if [ ! -f $file ]
then
echo \”Colorscheme file \”$file\” does not exist\”
exit -1
fi

sed \’s#\\(^ *colorscheme\\).*#\\1 \’$choice\’#\’ ~/.vimrc > /tmp/vimrc
diff ~/.vimrc /tmp/vimrc
read -p \”Do you want to make the changes (y/n) :: \” yn
if [ $yn = \”y\” ]
then
echo {/tmp/,~/.}vimrc
cp {/tmp/,~/.}vimrc
else
echo \”Modified changes are available in /tmp/vimrc\”
fi

\"Reblog

In (any) vi, add a keystroke to format the current paragraph.

vi editor is very powerful in the sense that you can use maps, abbreviations and recordings. One such example is when you are trying to write a email or trying to write a paragraph and you want to format it. You can create a mapping like so, in your .exrc or .vimrc and use it to format the paragraph.

map ^A !}fmt

\"Reblog

Built-in lists in vim

Vimscript provides excellent support for operating on collections of data, a cornerstone of programming. In this third article in the series, learn how to use Vimscript\’s built-in lists to ease everyday operations such as reformatting lists, filtering sequences of filenames, and sorting sets of line numbers. You\’ll also walk through examples that demonstrate the power of lists to extend and enhance two common uses of Vim: creating a user-defined function to align assignment operators, and improving the built-in text completions mechanism.

URL: http://www.ibm.com/developerworks/linux/library/l-vim-script-3/index.html?ca=drs-

\"Reblog