Vim is teh awesombe!

photo by lilit
I recently started using vim as my primary text editor. I’m no expert with it (yet) I’m just posting with some advice to other people who also want to do the same. But first, I’m going to tell you why vim is good.
- Fast in terms of loading
- Fast in terms of usage
- Customisability
- Expandability
- Portability
- Makes you feel all tingly when you do something in just a few keystrokes
Lots of people reject the idea of heavily keyboard and (human) memory reliant editors such as Emacs or vim because they have a steep learning curve. However, I’ve found vim’s learning curve to be pretty reasonable, and if you code professionally or even as a regular hobby then it’s worth taking the time to learn an editor that will speed you up.

photo by hulksjedi
There’s a nice little vim configuration thing called Cream. From what I understand this comes in two components:
- A number of configurations and macros for normal vim
- Cream itself (still vim underneath, but even milder, vim on tranquillisers)
I find this quite useful in that it makes normal vim behave a little bit more with its macros. However, Cream itself is too mild, it’s like using a normal text editor.
So, in conclusion, Cream is good. Download it and install it, but use vim configured by cream. Don’t use just cream itself. Well, actually you can – in fact it’s a nice gentle introduction to vim. If you just want a normal text editor then I recommend you use cream itself. I used cream itself for a while in “expert mode” before trying to customise it and failing. One thing that annoyed me in particular while coding python was that “expand tabs” worked for a single document, then claimed it was on but had to be turned off and on before it would start working again. I also wanted to be able to have the exact same configuration everywhere. This includes stuff like SSHing into Dreamhost and doing a hot-fix on a website or messing around on my old computer underneath the deskTM that does odd jobs like backups, svn, trac and an IRC bot. I had trouble doing configuration for Cream itself and I didn’t feel in control. So really, Cream configured or not (g)vim itself was the only option for me.

photo by phitar
Anyway, let’s rewind a bit. If you want to learn vim use the tutor. Invoke the tutor by opening a terminal or a dos prompt or whatever and entering vimtutor in it (this assumes vim is in your path). Do the entire tutor, then do it again. This is the only way. You probably won’t find it difficult but you may very well find yourself thinking “this is pointless, weird and archaic” every now and then. I know I did. However, your brain will know when to use various keystrokes magically1. Apart from the tutor I found this charming IRC style tutorial quite useful for a bit of light revision later on. On top of that there’s always the official vim tips repository which is useful for specific pieces of insight. This tip is particularly useful in a general sense as it is a compilation.

photo by tojosan
Ok, so now that you know this little editor that is fast in all senses of the word you’re probably wondering about one of its most loved features, its customisability. Firstly there is the .vimrc (or _vimrc on windows). This is something that I did mostly by example, there are a number of heavily commented .vimrc files out there so it’s fairly easy to just read through them until an option catches your eye. Here are two of my favourites. Obviously if you want to customise something in particular then you can search through help or fall back to teh interwabs.
Here’s mine:
" Kill all the tabs.
set ts=4
set sw=4
set et
set nu
set sr
" use
nnoremap
nnoremap
" autoindenting
set ai
" smartindenting
set si
" a
set smarttab
" if non-zero, number of spaces to insert for a
set softtabstop=4
" no real wrap during insert
set tw=0
" have the h and l cursor keys wrap between lines (like
" by default), and ~ covert case over line breaks
set whichwrap=h,l,~,[,]
" allow
" insertion, and over indentations:
set backspace=eol,start,indent
" have
" indentation:
inoremap
inoremap
" [
" map 'F12' to change the pwd of vim to the cwd of the current file
noremap
" pyLint the python 'compiler'
autocmd FileType python compiler pylint
" Purdy color scheme
colorscheme inkpot

photo by jm3
Plugins are the next thing. This is pretty obvious, just get some from the official vim plugin repository and shove them in ~/.vim/plugin/ (or C:\Program Files\Vim\vimfiles\plugin\ on windows) and shove colour schemes in ~/.vim/colors/. My favourite plugins at the moment are (keep in mind that some of these are geared toward python/html stuff):
- Colours Sample Pack – brings variety to the editing experience. Although I am quite settled on inkpot although matrix is good if someone else is in the room.
- Subversion (svn) Integration Plugin, update with stupid star trek name – Means I don’t have to switch into a terminal as often. (Well I’d probably use :!svn … if I didn’t use this)
- python.vim – Some python related menu commands. You need to shove the following in your ~/.vimrc
au FileType python source ~/.vim/plugin/python.vim - runscript.vim – Again, saves me doing a terminal or !python moo.py …
- Vim Taglist – Turns vim into a source code browser. Endlessly useful for large files.

photo by akash_k
Finally, I said at the beginning that one of my requirements was to have the same configuration across several machines. What I’ve done is made a vim repository in svn (I use version control for everything) which I check out on all the machines I want to have configured then svn co and ln -s bits of it it to various directories (on windows I just check out bits of the tree directly). I have the plugin and color directories in the repository. I also have a directory called common. When I said I was showing you my .vimrc I was actually showing a file called /common/vimrc in the vim repository. I then source it from all of my .vimrc files. On Ubuntu on my laptop my .vimrc looks like2:
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
source $HOME/.vim/common/common.vim
set guifont=ProFontWindows\ 9
(Yes, I use windows shortcuts on linux)

photo by tengis
In conclusion, I’m very happy with vim. It has replace notepad++ on Windows and a different editor every month on Linux. I like controlling everything with the keyboard, a keyboard is ordered. A mouse is chaotic and can easily just wander off into Firefox onto a Wikipedia article about conspiracy theories, or something similarly stupid. Also I’ve never quite been satisfied with using dialogs to do stuff (e.g. open files, change font), gvim provides this option, but I can just as easily do this by typing if I already know what I want3. Also being able to execute terminal/dos commands directly from an editor is unspeakably convenient. If you’re learning vim and want advice or have a question, or if you are a vimmer already and want to correct me on anything I’ve said, then scratch the itch and leave a comment.
- No, seriously.
- I’m not lying this time.
- I think using dialogs are like window shopping. Prompts are like entering a number into the computer thing in Argos4.
- Nation specfic references and corporate endorsement all in one. I must be turning into an evil.
>>A mouse is chaotic and can easily just wander off into Firefox onto a Wikipedia article about conspiracy theories, or something similarly stupid.
This is just too true, you are really an awesomeness.
Here what I do to Vim lovers:
(defun religious-sacrifice ()(interactive)
(mapc (lambda (x)
(shell-command (concat "rm " x))
(message "All hail emacs!!!"))
(cdr
(split-string
(shell-command-to-string "whereis vim")))))
Now get a better editor.
#!/bin/shsudo apt-get install vim
sudo apt-get install emacs
update-alternatives --all
Or is this one of those situations where everyone acts ignorant and throws insults at each other? In that case eMACS GIEVS U REPATITIVE STRIAN SYNDOORME AND HGOS ALL TEH SYS RESORUSES! WOT A LOAD OF BLAODT.
Really though, there are a few reasons I’ve opted for vim:
Heh, that what everyone says about Emacs. Obviously, you are not well informed about Emacs:
import os
import sys
import getopt
import re
import urllib
With emacs: M-x sort-lines
With vi: :.,+4!sort
Anyway, both editors are fine. Just use the one that fits your brain better. But remember, use a single editor well. If you feel like trying Emacs again, here my configuration. It will certainly
ease the process of your conversionhelp you.P.S Forcing people to use HTML in the comments is evil. There is certainly better alternatives. And fix the CSS (#commentform textarea) of your comment box.
or :!4Gsort
- Jim
- Bob
- Mary
will be made into valid xhtml.What editor should I use to write Python code?
The answer may surprise you.
Mark Pilgrim is the man. However, I don’t think that what he’s saying is necessarily:
I think what he’s saying is more along the lines of:
(Although I am obviously speculating)
Invoking Pilgrim myself:
Well I’ve tried GNU Emacs and it doesn’t fit my brain. Modal editing makes sense to me. A few tools to aid with python coding exist for it. That’s enough for me. My brain is a different shape for Pilgrim’s.
By the way, I was just joking. So don’t take any of my comments too seriously.
That’s what you get when you post your own blog entries on Digg.
I don’t generally take editor wars too seriously. Something that was once real has turned into a tradition that is brought back sometimes in a somewhat tongue in cheek way. Still, we, the cult of vi, will overcome our
ChristianEmacsian oppressors.Posting myself on digg was me keeping the whole egotism thing going. I have to meet my quarterly targets for self-indulgence. I’m sure you understand.
Maybe it’s just me, I think you don’t really understand what a blog is for. A blog is a way to criticize your own ideas. Writing down what you think, allows you to build a new perspective on those ideas.
A blog is certainly not a way to become famous, or incidentally to make money.
Just do it for yourself and the fun of it. Don’t do it just to put some stuff on your website. If you do so, then you’re losing your time.
If you really want to write a blog, then do it offline. It will force you to do it for you, and only for you. Then, when you start to feel comfortable with this idea, you can to think about sharing it with the rest of the interwebs.
Maybe it’s just me …
P.S.: You got some broken Javascript.
<script type="text/javascript">
_uacct = "UA-270185-3";
urchinTracker();
</script>
I am just bouncing thoughts around and making sure I keep writing. I’m keeping myself occupied as well. Writing entries does help me think about what I’m writing about. It finalizes it in my brain. Those ads are there because Project Wonderful seemed cool. I’m obviously not going to make money from them but I don’t really care. This site is just a dumping ground and a place for me to reference back to anyway. I keep a lot of stuff in a personal whikey but stuff I think might be useful to others I finalise into an entry. I probably won’t become
notoriousfamous. It is big a shame that that the masses won’t be able to appreciate my amazing genius, however, it’s not a big deal for me. Thanks for showing concern though.Also that script works for me. (That is, firebug doesn’t throw up anything).
A while ago, I came across the following picture.
So true, so true.
But, at the end, we are both winners.
Heh, so emacs allows you to travel back in time and then centre in on a certain point of time and difficulty? That’s pretty weird. So emacs users get to live forever? I can see the appeal but immortality isn’t my thing. Also vi is more difficult than gvim in that you can’t fall back on traditional gui editing techniques when you need to (for example, until I learnt the key for it I would use the menus for spell check). What is it saying about Visual Studio? That it suddenly becomes very easy? Anyway, interesting method of comparison. I’m not sure if it inspires conclusions though
.