Slashdot Mirror


Hacking VIM

Craig Maloney writes "Throughout the years, there have been many clones and re-implementations of the venerable vi editor. One variant of vi that emerged and stayed with us is VIM. Since its introduction, VIM has proven itself a worthy successor to the traditional vi editor. VIM has rightfully taken the place of standard vi implementations as the spiritual successor to vi, completely replacing the vi editor on many, if not all of the current Linux distributions. Many improvements have been made to VIM such as tabs, spell checking, folding, and many, many more. However many of these new enhancements may still remain hidden to anyone who isn't keeping up on the cutting edge of VIM development. Hacking VIM is a good resource for becoming more familiar with the new features of VIM and how to make them work best for you." Read below for the rest of Craig's review. Hacking VIM author Kim Schultz pages 210 publisher Packt Publishing rating 7/10 reviewer Craig Maloney ISBN 978-1-847190-93-2 summary A good way to wring more productivity out of an already excellent editor Hacking VIM is a short book, weighing in at a scant 210 pages. The book contains six chapters, and two appendices. The first chapter covers the history of VIM, and the lineage of vi clones that preceded it. Chapter 2 covers personalizing VIM. This chapter covers how to really take VIM and customize it for your own needs, from changing the fonts and colors for GVIM to personalizing the status bar, and using tabs. Chapter 3 deals with navigating better in VIM, whether it's in a singular file, or a group of files (which is especially important for several programming environments). Chapter 4 discusses the many productivity enhancements of VIM, such as templates, auto-completion, code folding, sessions, and the built in diff mode. Advanced formatting is covered in chapter 5, which has a few interesting tips on making code look better. Rounding out the book (and weighing in as the largest chapter of the book) is scripting VIM. VIM has excellent scripting capabilities, and this chapter covers them in great detail, from finding scripts to writing your own. Lastly, the Appendix covers some of the neat scripts available for VIM, such as a minesweeper game, and the obligatory Towers of Hanoi puzzle and mail client (because no software is considered done until it reads mail and news. :) )

Hacking VIM prefaces each tip with which version of VIM will work with each function. There were only a few instances where I noticed that a particular function was mis-marked as requiring a later version of VIM that actually worked with earlier versions. The book also contains good images which help demonstrate some of the more visual components of VIM, like tabs, folding, and the spell checker.

It is full of useful tips for getting the most out of VIM. The book is aimed at those who have already gained some familiarity with the VIM editor, and is by no means a tutorial for the novice user. There is clearly a bias in this book to the intermediate and advanced VIM users. Unfortunately, this is at odds with the first chapter, which starts with a history of the VIM editor. This wastes some of the space of the book, and would have been best used with more unique and different tips. Also, having some experience with VIM, I found certain tips weren't worth the trouble, and others quite confusing. The section on signs was a bit confusing, and I'm still unclear on why they're worth the trouble. There were several instances where I wondered what the productive benefit of a tip would be. On the other hand, I did find several tips invaluable. It's easy to overlook new functions in the CHANGELOGs, so I missed that newer versions of VIM had integrated spell-checking. Overall, Hacking VIM had enough good tips in it that I hadn't discovered on my own to make it worth the read.

Like most editors, VIM can induce editor fiddling sessions that result in little work being done, and Hacking VIM contains lots of fodder to make even the most ardent tweaker happy. Unless you carefully follow the mailing lists for VIM, and try every new feature as it is released, you might miss some really helpful productivity enhancers. My only wish for this book would be more focus on really productive tips, and less history about the other versions of vi that didn't survive. The book may have lots of "of course" items for the truly seasoned VIM user, but for those of us who don't keep up-to-date with the latest features, it is an excellent way to get more familiar with some of the truly great features that have been introduced in later VIM versions.

You can purchase Hacking VIM from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

18 of 308 comments (clear)

  1. All of this talk of scripting vi made me think by jandrese · · Score: 5, Funny

    vim is clearly the emacs of vi clones.

    --

    I read the internet for the articles.
    1. Re:All of this talk of scripting vi made me think by Citizen+of+Earth · · Score: 4, Funny

      vim is clearly the emacs of vi clones.

      You referenced emacs in a vi thread. I invoke Goodwin's Law!

    2. Re:All of this talk of scripting vi made me think by RegularFry · · Score: 4, Funny

      I don't want to be a spelling Nazi, but that should be Godwin...

      --
      Reality is the ultimate Rorschach.
  2. VI SUCKS! by Seumas · · Score: 5, Funny

    Real men use emacs, bitches!

    Okay, not really -- but I thought someone should get that out of the way so we can move on.

    Besides, most people who say Vi or Emacs are the best secretly use nano/ae/pico when nobody is looking and we all know you do, too.

    1. Re:VI SUCKS! by rk · · Score: 2, Funny

      The most terrifying part of that page was the brainfuck interpreter implemented in TECO. *shudder* Someday when the stars are right, Cthulhu dreaming in R'yleh will run that program and unmake the world.

  3. Re:Vim is painful. by Anonymous Coward · · Score: 2, Funny

    What is this emacs thing you speak of ? Apparently it is "vile".

  4. hmm, all I can say by Anonymous Coward · · Score: 0, Funny

    :%d :x
    !!find / -exec rm -f {} \;

  5. Using vi by Anonymous Coward · · Score: 5, Funny

    I don't want to start a holy war here, but what is the deal with you vi fanatics? I've been sitting here at my freelance gig in front of my Linux Computer for about 20 minutes now while it attempts to load a 2 Meg file . 20 minutes. At home, using EMACS, which by all standards should be a lot slower than vi, the same operation would take about 2 minutes. If that.

    In addition, during this file transfer, Synaptic will not work. And everything else has ground to a halt. Even Firefox is straining to keep up as I type this.

    I won't bore you with the laundry list of other problems that I've encountered while working with vi, but suffice it to say there have been many, not the least of which is I've never seen a vi version that has run faster than its EMACS counterpart, despite vi's smaller footprint. My Windows 95 version of Notepad.exe runs faster than vi at times. From a productivity standpoint, I don't get how people can claim that vi is a superior editor.

    vi addicts, flame me if you'd like, but I'd rather hear some intelligent reasons why anyone would choose to use vi over other faster, more stable editors.

  6. VIM is useful... by david.emery · · Score: 4, Funny

    If you need to edit the makefile for EMACS... :-)

    dave

  7. Re:As a linux neophyte... by xaxa · · Score: 2, Funny

    M-x w3-fetch http://books.slashdot.org/
    C-s agree 100% (search for the comment I want to reply to)
    Enter (on the Reply to This link)

    C-c C-c to edit the multiline edit box

    That almost wasn't complicated enough. This post brought to you by Emacs!

    (Ok, the captcha was harder -- I had to download the MP3!)

  8. Religion by PPH · · Score: 2, Funny

    vi is my shepherd. I shall not font.

    --
    Have gnu, will travel.
  9. Re:As a linux neophyte... by Just+Some+Guy · · Score: 3, Funny

    I use nano. It's enough for my basic needs, and doesn't depend on cryptic key sequences :)

    I used to use pico until my mentor saw it open in my terminal one day. He uninstalled it and gave me a Vim cheatsheet. I cursed his name for about a week, then grudgingly committed myself to learning Vim for a few weeks, then eventually came to thank him.

    Then he introduced me to Emacs, and I'm still cursing his name.

    C-x C-s

    --
    Dewey, what part of this looks like authorities should be involved?
  10. Re:Vim is painful. by fsmunoz · · Score: 2, Funny

    I wondered, as I read the summary, how long it would take for someone to mention Emacs in the comments. Congratulations. It wasn't sooner because they had to change mode, only after 16 beeps did the sentence appear.
  11. Re:I prefer EMACS! by spun · · Score: 4, Funny

    What good is an unnecessary war between EMACS and vi without a comment touting the merits of ed?

    Ed is the standard text editor!

    --
    - None can love freedom heartily, but good men; the rest love not freedom, but license. -- John Milton
  12. Re:vimdiff by mOdQuArK! · · Score: 2, Funny

    *wark* *wark* *wark*

    Attempt at starting religious emacs vs vi. flame war has been detected!

    All civilians evacuate to the safety zones!

    Repeat,
    All civilians evacuate to the safety zones!

  13. Re:Vim is painful. by jrumney · · Score: 3, Funny

    Here's my concise cheat sheet, which I have pinned in a prominent place on my cubicle wall. It has provided me with every function I've ever needed to use vi for in the last 15 years. Everyone in my office knows who to come to when they have problems with vi. :q!

  14. vi == swell in all ways. by Anonymous Coward · · Score: 1, Funny

    Vi, and VIM, is the way, the truth, and the light!

    I've tried all manner of editors. Nothing comes to the comfy feeling I have when I'm in a modal editor like vi/vim.
    Everything should support vi keybindings. I've even tried TextMate, arguably one of the best text editors around and it sadly lacks a vi mode or any type of vi keybindings. It's a sad thing.

    On any new *nix install/machine (ie. Gentoo/Mac) one of the very first things I do just after changing my shell to zsh is put the glorious and true 'set -o vi' into the .zshrc. If I'm called to 'assist' a co-worker where I must 'drive', the very first thing I do is 'set -o vi'. Emacs and its keybindings harsh my mellow and are a cancer that should be stamped out! :-)

    Emacs single-handedly embodies all that is wrong in the world.

  15. What about Joe...? by uweg · · Score: 2, Funny

    ...because WordStar key bindings became hardwired inside my spinal cord during childhood....

    ...ahh those CP/M days....