FASTA syntax in Vim editor

FASTA is one of the most commonly used formats for storing and accessing protein and nucleic acid sequences. So, if you are a bioinformaticist, you are very likely to handle this kind of files several times every day.

Vim is also one of the most common editor applications in present-day Linux distributions. This actually includes by default many scripts for detecting file content syntax, so they are more straightforward to be reviewed and modified. But sadly, at least on my Ubuntu 8.10 computer, there does not seem to be any support for detecting FASTA syntax. There is one script for enabling it, Syntax for Fasta. But, how do you install it?

Out-of-the-box scripts are stored in /usr/share/vim/vim71/syntax (or a similar location such as /usr/share/vim/syntax), but supposing you might not have admin permissions, you should create a .vim folder in your home directory ($HOME), and inside it a syntax folder, where you will place your custom scripts. Afterwards, copy /usr/share/vim/filetype.vim file in $HOME/.vim, and add the following line

" FASTA format au BufNewFile,BufRead *.fasta,*.fa call s:StarSetf('fasta')

after the last file extension definition, in my case, Z-Shell script. If necessary, you can add other typical extensions which could contain FASTA data, such as *.faa. In order to enable automatic syntax detection when opening files, you should have syntax on command enabled in your own customised .vimrc file at $HOME.

Commenting on this Blog entry is closed.