Vim is pre-installed on both Linux and OSX, but the version may not have the +clipboard option, which allows copy/pasting between Vim panes in tmux (see this post for an intro to tmux). Copy/pasting between panes is a really useful feature, so it is worth spending ten minutes to make sure this option is available.

This post describes how to install a version of Vim which has the +clipboard flag for OSX.

There is also another post describing how to enable this option in OSX.

Check if Vim is installed

First, in a terminal try:

vim --version

If it says something like The program "vim" can be found in the following packages:..., then it is not installed.

Or, if that produces too much output, try:

vim --version | grep VIM

and this should display the version number in the first line.

Installing Vim on Linux

Assuming you use Ubuntu, the following command will install Vim:

sudo apt-get install vim-gnome

(Enter your superuser password, and later type y and Enter when asked if you really want to install 30MB of files.)

Then check the version:

vim --version

The version should be something like 7.3 (you may need to scroll up to see the first line).

Vim and the system clipboard

Note that vim-gnome is used instead of simply vim; this is because this version will come with the clipboard option enabled. Even if you are using KDE, still use this command. Then, if (after installing) you enter the command:

vim --version | grep clipboard

you should then see the entries

+clipboard

and

+xterm_clipboard

The + means that the clipboard is enabled and using the Vim commands yy and p will copy/paste from the clipboard. If instead of seeing the +, you see:

-clipboard

then this means that the clipboard does not work.

I found this tip in this post.

Obtaining the vimrc

Step 1: Download the necessary files

Copy/paste the following into a terminal.

To copy, use Ctrl-C. To paste in the terminal, use Shift-Ctrl-V.

Note: When you highlight the following text, the $ symbols will not be included (and they should not be!) - they just indicate that the commands must be entered copy/pasted into the terminal.

#create and move to ~/build/vim dir
currentdir=$(pwd)
mkdir -p ~/build
mkdir -p ~/build/vim
cd ~/build/vim
 
#get necessary files
wget www.deanbodenham.com/downloads/vimrc.txt
wget www.deanbodenham.com/downloads/wombat16.vim
wget --content-disposition http://www.vim.org/scripts/download_script.php?src_id=22665
#move to ~/.vim dir - different to ~/build/vim!
mkdir -p ~/.vim
cd ~/.vim
 
#extract delimiteMate.vim
cp ~/build/vim/delimitMate-2.7.zip ./
unzip delimitMate-2.7.zip
rm *.zip
 
#include wombat colorscheme
cd ~/.vim
if [ -d "./colors" ]; then cd ./colors; else mkdir ./colors; cd ./colors; fi
cp ~/build/vim/wombat16.vim ./
 
#move back
cd ~/build/vim
 
#if there already exists vimrc file, then copy here to back it up
if [ -f "~/.vimrc" ]; then cp ~/.vimrc ./bak_vimrc; fi
 
#copy/overwrite ~./vimrc
cp vimrc.txt ~/.vimrc
 
#move back
cd "$currentdir"
 
#done

Setting the terminal colorscheme

The terminal might not display the colorscheme correctly. In order to use the wombat16 colorscheme, in the terminal window, select:

EditProfile preferencesColorsPalletteBuilt-in schemes

and then select Linux console or Xterm or White on Black. This is to make "greying" work between active/inactive panes on tmux.

If you' using KDE and Konsole, then go to: SettingsEdit Current ProfileAppearance and select Linux colors