30 years ago, in 1976, Bill Joy (co-founder of Sun Microsystems) released vi — a visual text editor for an early version of BSD. 15 years ago, Bram Moolenaar released vim (vi improved). Today I finally decided to learn about vi(m).
vi(m) is the default text editor found on virtually every UNIX system in existance today. Even Mac OS X has vim installed by default. After using *nix systems for about 6 years now, I never really spent the time to learn about vi. Sure I could (poorly) use it to edit some text files in a pinch (I knew how to load a file, insert some text, save and quit) but for any console editing tasks, I found myself reaching for the much more user-friendly nano (hey, it has the few commands listed at the bottom of the screen!). However, there is very few software applications that are still being used (and preferred) for over 30 years. At the time vi was released, Microsoft was being run out of a dorm room and Apple had yet to exist.
For many years, I simply disregarded vi(m) as a unix relic that had no (major) significance to newcomers. However, curiousity got the best of me. Every once in a while, a debate about text editors occurs that brings up vi(m). LinuxQuestions.org is currently during its annual poll and once again, vi(m) is included on the list. Others have stirred up the vi(m) vs emacs debate. Needless to say, given the re-occurance of vi(m) and its standard place as the editor-of-choice for default UNIX installs, I figured I’d spend some time learning it.
I ended up installing vim on my FreeBSD system. I headed over to the vim website and was happy to find the vim book available in PDF format. I was shocked when I opened it and noticed it was 572 pages! Yikes! 572 pages for a text editor??!? Even my tome on the FreeBSD operating system was only 565 pages. Anyways, needless to say, I have yet to read all 572 pages, but after reading ~50 pages (the pages are not very text heavy so its not THAT bad.) I can say that I am impressed.
What is cool about vim? Well for starters, it is very keyboard centric. As a result, I am able to control the application without a mouse, which is nice. In addition, it is not menu driven (read: use of control key combinations, extensive use of arrow keys, etc..) and many of the commands are one or two characters (ie press d for delete, i for insert, v for visual mode, w to move to the next word, etc..). Infact, it even assigns hjkl to left/down/up/right for cursor movement so moving your hands from home row are not necessary (focus on efficiency
In addition to this, it provides easy access to search functions. I can simply hit a forward slash (/) and type in a search term and it will highlight the search term throughout my document. I can also do a search/replace without the need to open a dialog box and enter text in different text fields (ie: :%s/cat/dog/g to change all “cat” to “dog”). In addition to this, it has full support for regular expressions so its possible to do complex search and replace operations (regular expressions also has its own equally impressive tome).
It also allows me to tap into many of the command line tools available in Unix. For example, I can mark a section of my document and run it through the Unix “sort” command. Or perhaps I am reviewing a log file.. I could do a search in vim, find the entries I need and simply mark and filter it to the “sendmail” command to email it directly (compared to cutting and pasting, opening up an email client, creating a new email, pasting it in, etc..).
conclusion.. text is one of those things that we deal with on a daily basis. Unfortunately, as I am learning, the tools available make working with text much more cumbersome than it needs to be. vi(m), with its 30 year focus on text editing seems to have been refined to doing the task particularly well. No wonder those who have spent the time learning about the power of vi(m) have grown to prefer it even to the latest and “greatest” text editors available. Here’s to the next 520 pages of the vim manual