Presenting VIM plugins

Vim

Instead of the usual self presentation for a first post, I’ll present you my favorite text editor.

I use VIM. Mainly because it meets my needs. However, I understand other people may like different editors (if you happen to have twelve fingers and prefer Emacs).

A text editor is a tool that we use a lot of time in your day (at least, in mine). Think about a normal text editing activities, when you need to:

  • edit configuration files
  • write LaTeX articles (because, you know, the deadline for this conference is tomorrow)
  • code Python script that check your mails
You could either decide to fire up:
  1. Different specific tools: kate/gedit/nano, then kile/lyx, and then Eclipse/Netbeans, one tool for each task.
  2. Vim (well, you don’t really fire it up, because it is already started, right ?)
I personally go for the second choice. Because my philosophy is to spend my time learning only one tool but learning it well.

So, VIM is really powerful. However, I will not explain you how to use it, because a lot of people already wrote really good documentations on how to use it. Instead, I will present you the different plugins that make life easier and make us productive.

Let’s start with the “simple but effective” category:

  • If you are to work with XML files, Devin Weaver’s xml filetype plugin offers a tag auto-close feature and more. Which renders XML editing almost a pleasant job.
  • Supertab gives a purpose to your « Tabulation » key. You can then use it for the omni-completion (or configure it for other kind of completion). It saves you from finger yoga.
  • Need a small Wiki, that can be converted to pdf/html, Viki is there for you.
  • You code in Python and want to know if you comply to Pylint’s strict rules. Then give a try to the Pylint module. Simply code in python as usual and Pylint will be called to evaluate your code when saving. It then indicates on the status bar the « mark » it gives to your code and also indicates you where you loose points. Just like in school, try to get 10 out of 10 (if you can).
  • Your are using ctags on any of the supported languages, ensure that you didn’t missed the taglist plugin. Once you start the :TlistToggle (I personally map this to <F2>), you will see a vertical window on the left of your vim, listing all the different tags for your file. Navigating in your code is even easier.
  • You are reading C code, and often have to switch between the .c file and the .h file ? Here, the a.vim proposes a handy binding to the :A command that allows you to toggle between the .c file and the .h file.
Wait, what, you read C code ? C/C++ IDE is probably what you are looking for. You have auto bracket/parenthesis closing , thumb saving quick replacement commands (say tapping «/sife » replaces « /sife » by an if/then block). No need to cram everything in your memory, there is a cheat sheet for that. Still not satisfied, you want something stronger than ctags to explore C code to no end: use cscope and discover its vim plugin !

Similarly, if you are writing a lot in LaTeX, the LaTeX-Suite plugin is life-changing. Small keywords in the insert mode are replaced with pre-filed structure (just as the C/C++ IDE). For example, typing « EFI » gives you the skeleton of a figure inclusions. Auto-folding for section, subsection, etc. is also available. And because there is to many keyword to remember, here is Michael Goerz’s wonderful cheat sheet. Did I also told you that taglist is compatible with LaTeX syntax ?

And there is more, you can customize almost everything:

  • You can quickly change the color scheme for the syntax coloration. Try :color proton for example.
  • You can easily add new shortcuts (for your plugins or whatever), try typing :map <F8> :set spell<CR> to get a on demand spellchecker.
  • Finally, Vim can remember all of this, try adding the previous command in your $HOME/.vimrc file!
This is it!

I’m sure there is many more useful plugins I have never heard off, please drop a comment and share the one your are using!