Wednesday, December 9, 2009

All about the editors

All about the Editors, baby.

I have been writing code and pseudo code for several years now and my journey is riddled with the remains of many text editors. I, like many others, started writing HTML markup. I was writing it in MS notepad. Thinking back on that time I am amazed that I did not go crazy. Especially considering that I also started to learn javascript at the same time. I think that a lot of my distaste for javascript has as much to do with the fact that I did not have syntax highlighting in notepad as with the fact that javascript has some of the weirdest implementations of any language ever. Since notepad I have used a number of IDEs, wysiwyg editors, and text editors. The one of the most recent editors I used was Textmate in OS X. The difference between notepad and Textmate is dramatic to say the least. The difference between Textmate and the two editors I have been using recently is just as dramatic - Vim and Emacs.

I like both emacs and vim for different reasons. Emacs is all about - well, everything. It is so flexible that some people are known to have called it "An editor that thinks it's an operating system." The amount of customization that you can have with emacs is astounding - and confusing. If you can overcome the Mount Everest that is it's learning curve there is little that you can not do. Vim is not everything, it is an editor that is designed to edit documents from the keyboard's home row - anything else you can customize it to do is gravy. Both approaches appeal to me but since I have OSs that I love (OS X and Ubuntu) and software on those systems that I love as well I don't need all the power that emacs offers. I do need a kick ass text editor though and that means Vim for me.

Like I said before, Vim is a text editor and that means that it's main focus is on "editing" documents. This is key to understanding how and why Vim works the way that it does. Emacs and other text editors like Textmate and Notepad are very easy to open and begin entering text. Vim is not. Vim is not focused on entering text it is focused on editing documents. Ofcourse that means that you have to enter text but Vim does not assume that is the first thing that you want to do when opening a document. It assumes that you want to "edit" the document. So, it opens up in "normal" mode... wait, what?

Vim has a "normal mode" and an "insert mode". Normal mode is for entering commands and Insert mode is for inserting text. This threw me for a loop the first time that I encountered it but it is easier to understand if you think about the fact that Vim is *primarily* for editing documents and not for entering text. If you know that 99% of your time will be spent entering new text into a new document then Vim is definatly not for you. If you know that you have to enter text often but most of the time you will be editing your code then Vim is awesome.

Since I am a web developer I spend alot of time editing text not entering new text into a new document. This is especially true because I love Ruby on Rails. Rails and other frameworks like Django or CakePHP all do a crap load of code generation for you and all you have to do is customize it. Sometimes there are 4000 lines of cusomization (or so it seems) and sometimes it is just a method or two. For me Vim fills this function beter than any other text editor that I have used.

Of course, learning Vim is not easy. Especially for someone who touch types as poorly as I do. There is a lot to learn about customizing it and getting used to it's modes. Fortunatly there are tons of resources on and other websites. There are even a few videos. I really like the screencast learning method. (Shout out to PeepCode and RailsCasts!) The videos for vim (and emacs) have been lacking in the past and I am not sure why. Recently, PeepCode released a screencast for using emacs. It was very very good and I wondered if there was something similar for Vim. I have searched and not found anything that was quite up to that level. I think that is a testament to the level of care that PeepCode puts into it's work but does leave a hole in the screen cast world that needs to be filled.

I do not know much about screencasting as well as they do but I would like to give it a shot. I have a copy of SnapzPro and some editing software so I may give it a shot. Check back here and we can see if I can create a screencast worthy of the almighty Vim.

1 comment:

justinlilly said...

Hey wickedtribe.

First, don't sell emacs short. Having used both, I find that emacs offers quite a few methods for preforming text-surgery (which is what I call "document editing"). The biggest of these are the f/t commands of vim, which will jump to the next letter specified, ie: ft will jump to the next t in the document.

On the front of screencasts, I recorded a few a year or so ago when I was using vim more heavily. Hope they are a help to you.