This post is dedicated to vim, the greatest editor of all times (well, hum,
at least until the 90’s). I will comment some of the contents of my .vimrc
file and say a word about some interesting plugins. This is also a good
opportunity to showcase my programming font.
Base configuration
Nothing really fancy, just make vim usable.
Only a few settings make it go from old school crappy program to some modern
and good text editor. Notice that I use Pathogen to manage my plugins.
Some personal additions
Blogging made easy: spell checking and syntax highlighting
I am using vim right now to write this blog post, and what happens?
My fongers ripp, I mke mistqkes. Fortunately, a few presses on <F11>
immediately highlights my errors, whatever language I am using. Plus my
markdown and HTML files, mixed with Liquid syntax, are perfectly highlighted.
School-related stuff
The Ensimag’s first language is Ada. Here are two shortcuts that make one-file
exercises easier: press <F5> and it compiles, <F6> and it runs. Then came
the Software Engineering Project. A quite large code base to work
on, and never-seen-before file types, such as the homemade .deca, our subset
of Java. Ctrl-P or Command-T solves the navigation
problem, and some auto-commands enable syntax highlighting. And finally a small
TeX setting to prevent vim from replacing TeX commands with fancy characters.
Plugins
I already mentioned Command-T, which I used heavily for big school
projects. However, for other smaller projects, for which I know very well the
directory structure, I prefer to rely on NERDTree, which I keep
hidden on the side.
Indentline is a plugin that displays a subtle line for every
level of indentation. I found it very useful while doing Ada or Javascript with
small indentations like 2 or 3 spaces. But it is definitely less useful with
full-width tabulations (and anyway it wont work in this case, it needs spaces).
So this plugin too has a toggle shortcut.
Bonus: a curated set of line drawing characters. Where do you
find a font which has all of them? Hint: Fantasque Sans does.
Other plugins that do not need configuration include surround, supertab,
syntastic, multiple-cursors (I really miss the <C-N> shortcut when I’m in
another editor), and the awesome Fugitive (that I most often launch directly
from the terminal, not too much from inside of vim — more about that in
another post).
Look and feel
Not-that-much-entertaining stuff
Some shortcuts for tab and window switching, and precise configuration of how I
want long lines to be cut in a civilized manner.
Cool stuff
The next block comes straight from spf13’ vim configuration and is
really great: persistent undo. I can OD on green tea, make a mess somewhere,
and when I come back to this file years later, simply pressing u will restore
it to a saner state. How cool is that?
More practical example: imagine you delete a piece of code some day, and you
happen to need it the day after. I do all the time. Sure, git can be useful
for that, BUT it is so much cooler to press u frantically until the desired
work comes back from the dead, yank what you need, rewind back to the present
using <C-R> and paste. It makes me feel like the Doctor Who of text files.
Gold stuff
You have already done it. Wander through /etc/ to find out why insert
application name does not work. Look at configuration files, find the right
one, modify it, think you solved the problem, try to save changes… and be
told that you don’t have the rights to write there. One solution: :w!!,
enter your password and you’re done.
Style
I always use two color schemes, Molokai for terminal vim and Solarized
for GVim. I also find Airline to be a good looking (if not useful) addition.
That’s about it.
In fact my real .vimrc has a ton of other configuration options for plugins
that I never use, and other commented out snippets which purpose has long since
been forgotten. Maybe someday I will clean it up a bit and publish it.