From DreamHost
Revision as of 10:29, 5 October 2007 by Mousee (Talk | contribs)

Jump to: navigation, search

Vim, which stands for Vi IMproved, is an open source, multiplatform text editor extended from vi.

Custom Installation

The instructions provided in this article or section are considered advanced.

You are expected to be knowledgeable in the UNIX shell.
Support for these instructions is not available from DreamHost tech support.
Server changes performed by DreamHost may break your modifications. You, as the user, are responsible for troubleshooting and resolving issues with your customizations.

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:

This is the latest version of VIM.
Older versions of the script will be preserved on the discussion page for now.

set -e

# Version 1.2c, 2007-10-05
# - Updated 2007-05-30 by Chris Shymanik (
#   - 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.


# Where do you want all this stuff built?
# ***Don't pick a directory that already exists!***
# We clean up after ourselves at the end!
# And where should it be installed?
# Set DISTDIR to somewhere persistent.
# Delete contents of DISTDIR after installation? (Default: Yes)
# Set BINDIR to wherever you keep your binaries.
# The default is, ~/bin (/home/username/bin).
# Set whatever nice value you wish here.
# Higher values indicate lower priority,
# Lower values indicate higher priority.
# Range: -20 to 20
# Name of the VIM install package
# (without any extension, ie: .tar.bz2)

# 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 \

########## DO NOT MODIFY BELOW ##########
sleep 1s

# Push the install dir's bin directory into the 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}/*
		  echo "Creating source directory..."
		  mkdir -p ${SRCDIR}

# 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}/*
		  echo "Creating installation directory..."
		  mkdir -p ${INSTALLDIR}
if [ -d ${BINDIR} ]; then
		  echo "Deleting vim binary if it exists..."
		  rm ${BINDIR}/vim >/dev/null 2>&1
		  echo "Creating BINDIR if it doesn't exist..."
		  mkdir -p ${BINDIR} >/dev/null 2>&1

## Grab the required source archives.
set +e
# 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"
	wget $WGETOPT${VIM}.tar.bz2
	# If primary mirror fails, use the alternative mirror.
	if [ -a ${DISTDIR}/${VIM}.tar.bz2 ]; then
		echo "Got ${VIM}.tar.bz2"
		wget $WGETOPT${VIM}.tar.bz2
		# Check to make sure the alternative mirror worked.
		if [ -a ${DISTDIR}/${VIM}.tar.gz ]; then
			echo "Got ${VIM}.tar.gz"
			echo "Failed to get ${VIM}.tar.bz2. Aborting install!"
			exit 0

## 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."
	echo "Unknown DISTDEL option! Wiping the contents of your DISTDIR by default."
	sleeps 1s
	rm -rf ${DISTDIR}

## End of install
echo "Installation completed!" `date +%r`


Further information on what features you can use for the install script are available here:

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"



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

" Enable plugin-provided filetype settings, but only if the ftplugin
" directory exists.
if isdirectory(expand("$VIMRUNTIME/ftplugin"))
		  filetype plugin on

" Fix &shell, see bug #101665
if "" == &shell
		  if executable("/bin/bash")
					 set shell=/bin/bash
		  elseif executable("/bin/sh")
					 set shell=/bin/sh

Additional .vimrc options can be found here:

External links