For years now I’ve used IDEs like Visual Studio and Eclipse occasionally falling back to plain text editors like GEdit or Notepad2 when making quick changes. I’ve been running Linux for almost three years now and, as you do when dealing with remote servers, have sometimes had to edit text files via the console using VIM.
VIM has been around for 18 years and is an extended version of VI which has in turn been around for 33 years. VIM = VImproved. It’s a console-based text editor designed on the assumption that you will only ever be using your keyboard (kiss your mouse goodbye) which means that much of the most common functions are based around the home keys (‘asdf’ and ‘jkl;’) and it’s packed with great programming features.
But the learning curve is about the steepest I’ve ever come across.
I decided a couple of months ago to make an effort to get to grips with it and it took a good four weeks before I was matching the programming speed I was used to with Eclipse. But now I’m finding that my speed is continuing to increase and there is no way I can go back now. It’s not the be-all-and-end-all though; if you are writing a document from scratch (like this blog entry) then VIM doesn’t really have much to offer but if you are editing an existing document (as you often are when programming) it’s streets ahead of IDEs and text editors.
One of the hardest things to get your head around is the fact that VIM is modal which means that you switch between typing stuff and doing stuff to existing text. By default you are not in ‘typing stuff’ mode and so when you type the letter w it’ll skip to the next word. If you want to add text you have to press i and then press Esc after you’ve finished to go back to ‘doing stuff’ mode. For example, to copy an entire line, paste it below, move to the new line, skip three words along, delete the remaining text on the line and start typing, in VIM you would type yy, p, 3w, c$ but the equivalent in a text editor would be to press Shift-End, Ctrl-C, End, Return, Ctrl-V, Home, Ctrl-Right, Ctrl-Right, Ctrl-Right, Shift-End, Delete and then start typing. Those key combinations may seem strange but, once you are used to them, they make a lot more sense than having to constantly move your hands away from the home keys. Especially on a laptop!
VIM is free, open source and is available for AmigaOS, Atari MiNT, BeOS, DOS, MacOS, NextStep, OS/2, OSF, RiscOS, SGI, UNIX, VMS, Windows, FreeBSD and Linux. If you are a programmer or edit plain text on a regular basis I recommend you give it a go but be aware that the curve is about as steep as curves get. If you decide to try it out I can also recommend this website to get you on your feet.