Tuesday, December 27, 2011

Vim Setup

Please install Dropbox before continuing.

Installation

Install vim with

$ sudo apt-get install vim

I like to have access to same vim configuration on every machine I use. I created the following structure in my DropBox folder (Note trailing slashes indicate folders):

Dropbox/
    config/
        vim/
            .vimrc
            .vim/

Next, I created symlinks from my home folder to my Dropbox vim files:

$ ln -s ~/Dropbox/config/vim/.vimrc .
$ ln -s ~/Dropbox/config/vim/.vim

When I make changes to my vim configuration, it immediately synchronizes to all of my other machines.

SnipMate

SnipMate is a plugin that provides sophisticated snippet capabilities in vim. It utilizes vim’s file type detection and wires the appropriate snippets in insert mode.

Download the plugin and follow the installation instructions:

$ unzip snipMate.zip -d ~/.vim

Be sure that set paste is not enabled in your .vimrc file.

Study the included snippets in $HOME/.vim/snippets. To add a new file type, open the file e.g. myfile.md and query vim

:set filetype?

It returns a type (in this case mkd). Create a new file called mkd.snippets in $HOME/.vim/snippets and add your file type specific snippets.

Since you’ve configured this with Dropbox, your snippets will be available everywhere.

No comments: