Vim
m (End-of-install bug killed.) |
m (Double-brackets are like moldy cheese.. they don't work!!) |
||
| Line 20: | Line 20: | ||
set -e | set -e | ||
| − | # Version 1. | + | # Version 1.2c, 2007-10-05 |
# | # | ||
# - Updated 2007-05-30 by Chris Shymanik (chris@chipsncheese.com) | # - Updated 2007-05-30 by Chris Shymanik (chris@chipsncheese.com) | ||
| Line 71: | Line 71: | ||
## Pre-download clean-up and checking. | ## Pre-download clean-up and checking. | ||
# Clear and/or create the source directory. | # Clear and/or create the source directory. | ||
| − | if | + | if [ -d ${SRCDIR} ]; then |
echo "Source directory already exists! Cleaning it..." | echo "Source directory already exists! Cleaning it..." | ||
rm -rf ${SRCDIR}/* | rm -rf ${SRCDIR}/* | ||
| Line 80: | Line 80: | ||
# Check for existing vim install and remove it if exists. Else create it. | # Check for existing vim install and remove it if exists. Else create it. | ||
| − | if | + | if [ -d ${INSTALLDIR} ]; then |
echo "Install directory exists! Removing contents..." | echo "Install directory exists! Removing contents..." | ||
rm -rf ${INSTALLDIR}/* | rm -rf ${INSTALLDIR}/* | ||
| Line 87: | Line 87: | ||
mkdir -p ${INSTALLDIR} | mkdir -p ${INSTALLDIR} | ||
fi | fi | ||
| − | if | + | if [ -d ${BINDIR} ]; then |
echo "Deleting vim binary if it exists..." | echo "Deleting vim binary if it exists..." | ||
rm ${BINDIR}/vim >/dev/null 2>&1 | rm ${BINDIR}/vim >/dev/null 2>&1 | ||
| Line 102: | Line 102: | ||
# Do a bit of error checking while grabbing the sources. | # Do a bit of error checking while grabbing the sources. | ||
| − | if | + | if [ -a ${DISTDIR}/${VIM}.tar.bz2 ]; then |
echo "Skipping wget of ${VIM}.tar.bz2" | echo "Skipping wget of ${VIM}.tar.bz2" | ||
else | else | ||
wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${VIM}.tar.bz2 | wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${VIM}.tar.bz2 | ||
# If primary mirror fails, use the alternative mirror. | # If primary mirror fails, use the alternative mirror. | ||
| − | if | + | if [ -a ${DISTDIR}/${VIM}.tar.bz2 ]; then |
echo "Got ${VIM}.tar.bz2" | echo "Got ${VIM}.tar.bz2" | ||
else | else | ||
wget $WGETOPT ftp://ftp.vim.org/pub/vim/unix/${VIM}.tar.bz2 | wget $WGETOPT ftp://ftp.vim.org/pub/vim/unix/${VIM}.tar.bz2 | ||
# Check to make sure the alternative mirror worked. | # Check to make sure the alternative mirror worked. | ||
| − | if | + | if [ -a ${DISTDIR}/${VIM}.tar.gz ]; then |
echo "Got ${VIM}.tar.gz" | echo "Got ${VIM}.tar.gz" | ||
else | else | ||
| Line 146: | Line 146: | ||
rm -rf ${SRCDIR} | rm -rf ${SRCDIR} | ||
| − | if | + | if [ ${DISTDEL} == "Yes" ]; then |
rm -rf ${DISTDIR} | rm -rf ${DISTDIR} | ||
| − | elif | + | elif [ ${DISTDEL} == "No" ]; then |
echo "Your DISTDIR will not be cleaned." | echo "Your DISTDIR will not be cleaned." | ||
else | else | ||
Revision as of 10:29, 5 October 2007
Vim, which stands for Vi IMproved, is an open source, multiplatform text editor extended from vi.
Contents |
Custom Installation
| The instructions provided in this article or section are considered advanced. You are expected to be knowledgeable in the UNIX shell. |
For those of us who'd like to take advantage of VIM 7's latest features, in consideration of DreamHost's older 6.3 version,
the information below will get you started.
Please keep in mind this article was designed for ADVANCED USERS who already have some *nix shell experience.
Custom VIM installations will NOT be supported by DH Staff.
Create and run the shell install script in your home directory:
vim71_install.sh
This is the latest version of VIM.
Older versions of the script will be preserved on the discussion page for now.
#!/bin/sh
set -e
# Version 1.2c, 2007-10-05
#
# - Updated 2007-05-30 by Chris Shymanik (chris@chipsncheese.com)
# - Minor revision 1.2b on 2007-09-19 to fix an end-of-install bug.
# - Updated VIM to version 7.1.
# - Added some error checking and an option to clean DISTDIR.
## USER CONFIGURATION OPTIONS
# Where do you want all this stuff built?
# ***Don't pick a directory that already exists!***
# We clean up after ourselves at the end!
SRCDIR=${HOME}/source
# And where should it be installed?
INSTALLDIR=${HOME}/share/vim
# Set DISTDIR to somewhere persistent.
DISTDIR=${HOME}/dist
# Delete contents of DISTDIR after installation? (Default: Yes)
DISTDEL="Yes"
# Set BINDIR to wherever you keep your binaries.
# The default is, ~/bin (/home/username/bin).
BINDIR=${HOME}/bin
# Set whatever nice value you wish here.
# Higher values indicate lower priority,
# Lower values indicate higher priority.
# Range: -20 to 20
NICE=19
# Name of the VIM install package
# (without any extension, ie: .tar.bz2)
VIM="vim-7.1"
# What features of VIM do you wish to enable or disable?
# ***Probably best not to change anything here!***
VIMFEATURES="--prefix=${HOME} \
--enable-perlinterp \
--enable-rubyinterp \
--enable-multibyte \
--disable-netbeans \
--with-features=big \
--disable-gui \
--without-x"
########## DO NOT MODIFY BELOW ##########
sleep 1s
# Push the install dir's bin directory into the path.
export PATH=${INSTALLDIR}/bin:$PATH
## Pre-download clean-up and checking.
# Clear and/or create the source directory.
if [ -d ${SRCDIR} ]; then
echo "Source directory already exists! Cleaning it..."
rm -rf ${SRCDIR}/*
else
echo "Creating source directory..."
mkdir -p ${SRCDIR}
fi
# Check for existing vim install and remove it if exists. Else create it.
if [ -d ${INSTALLDIR} ]; then
echo "Install directory exists! Removing contents..."
rm -rf ${INSTALLDIR}/*
else
echo "Creating installation directory..."
mkdir -p ${INSTALLDIR}
fi
if [ -d ${BINDIR} ]; then
echo "Deleting vim binary if it exists..."
rm ${BINDIR}/vim >/dev/null 2>&1
else
echo "Creating BINDIR if it doesn't exist..."
mkdir -p ${BINDIR} >/dev/null 2>&1
fi
## Grab the required source archives.
set +e
cd ${DISTDIR}
# Wget options
WGETOPT="-t1 -T10 -w5 -q -c"
# Do a bit of error checking while grabbing the sources.
if [ -a ${DISTDIR}/${VIM}.tar.bz2 ]; then
echo "Skipping wget of ${VIM}.tar.bz2"
else
wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${VIM}.tar.bz2
# If primary mirror fails, use the alternative mirror.
if [ -a ${DISTDIR}/${VIM}.tar.bz2 ]; then
echo "Got ${VIM}.tar.bz2"
else
wget $WGETOPT ftp://ftp.vim.org/pub/vim/unix/${VIM}.tar.bz2
# Check to make sure the alternative mirror worked.
if [ -a ${DISTDIR}/${VIM}.tar.gz ]; then
echo "Got ${VIM}.tar.gz"
else
echo "Failed to get ${VIM}.tar.bz2. Aborting install!"
exit 0
fi
fi
fi
## Unpack the source archives.
set -e
cd ${SRCDIR}
echo "Extracting ${VIM}..."
tar xjf ${DISTDIR}/${VIM}.tar.bz2
echo "Done."
## Compile and install the package(s).
cd ${SRCDIR}/vim*/src
./configure ${VIMFEATURES}
# make clean
nice -n ${NICE} make
# Move our newly created binary to our binaries directory.
mv ${SRCDIR}/vim*/src/vim ${BINDIR}/
# Move the contents of the runtime directory to our install path.
mv ${SRCDIR}/vim*/runtime/* ${INSTALLDIR}/
## Post install clean-up.
sleep 2s
cd ${HOME} && clear
# Strip debug info out of the binary.
strip --strip-all ${BINDIR}/vim
rm -rf ${SRCDIR}
if [ ${DISTDEL} == "Yes" ]; then
rm -rf ${DISTDIR}
elif [ ${DISTDEL} == "No" ]; then
echo "Your DISTDIR will not be cleaned."
else
echo "Unknown DISTDEL option! Wiping the contents of your DISTDIR by default."
sleeps 1s
rm -rf ${DISTDIR}
fi
## End of install
echo "Installation completed!" `date +%r`
#EOF
Further information on what features you can use for the install script are available here:
http://vimdoc.sourceforge.net/htmldoc/eval.html#feature-list.
Now modify your .bash_profile to include your binary path directory (ie. /home/user/bin), the VIM Runtime [so it can find ftplugin], and the location of VIM:
umask 002 PS1='[\h]$ ' export EDITOR="~/bin/vim" export VIMRUNTIME="~/share/vim" PATH=~/bin:$PATH;
Done!
Customization
To change the default behavior of VIM, we need to create/edit .vimrc in our home directory.
Reasons you might wish to do this may be:
- Syntax Highlighting
- Cursor position display (to show which line you're on)
- Auto-Indexing
- Q Formating
- Smart Tab Sizes
- Spell-Checking
- etc...
.vimrc example:
set nocompatible " Use Vim defaults
set smarttab " Use smart tab sizes
set ttyfast " Indicates a fast terminal connection
set ignorecase " Ignore cases in search patterns
set tabstop=3 " Number of spaces that a <Tab> in the file counts for
set incsearch " Display the match for a search pattern halfway through typing it
set ruler " Show the cursor position all the time
set bs=2 " Allow backspacing over everything in insert mode
set ai " Always set auto-indexing on
set history=50 " keep 50 lines of command history
set nomodeline " Modeline is disabled due to bug #14088 and #73715
set viminfo='20,\"500 " Keep a .viminfo file.
" In case you want to use Vim's built-in spellchecker, uncomment the lines below:
" set spell
" set spelllang=en
" Enables/Disables syntax highlighting when the terminal has colors.
" Also switches on hightlighting the last used search pattern.
syntax on
set hlsearch
" Don't use Ex mode. Use Q for formatting.
map Q gq
" When displaying line numbers, don't use an annoyingly wide number column.
" This doesn't enable line numbers. The value given is a minmum width to use
" for the number column, not a fixed size.
if v:version >= 700
set numberwidth=3
endif
" Enable plugin-provided filetype settings, but only if the ftplugin
" directory exists.
if isdirectory(expand("$VIMRUNTIME/ftplugin"))
filetype plugin on
endif
" Fix &shell, see bug #101665
if "" == &shell
if executable("/bin/bash")
set shell=/bin/bash
elseif executable("/bin/sh")
set shell=/bin/sh
endif
endif
Additional .vimrc options can be found here:
http://vimdoc.sourceforge.net/htmldoc/options.html#options