Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Book Reviews Books Media

Hacking VIM 308

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.
This discussion has been archived. No new comments can be posted.

Hacking VIM

Comments Filter:
  • by deweycheetham ( 1124655 ) on Monday December 10, 2007 @03:51PM (#21646305)
    Most don't take the time to read the documentation http://www.eandem.co.uk/mrw/vim/usr_doc/index.html [eandem.co.uk] . One of the great thing about VI(M) is the ability to execute this in Batch Mode (i.e. Ex ). For that matter in these days of Microsoft Glory and GUI's that don't work so well, its nice to know that GNU Tools http://gnuwin32.sourceforge.net/ [sourceforge.net] are around for all those pesky OS's that fall short of Batch Processing abilities of any sort to speak of. VI(M) also operates in this area quite well.

    Nice to know it's not forgotten.
  • by css-hack ( 1038154 ) on Monday December 10, 2007 @04:00PM (#21646451)
    When I first started using *nix, I used nano too. It's got simple key combinations to do simple actions. I used it for years.

    I didn't start to use Vim until I started work at a software shop where the lead developers used it almost exclusively. I couldn't figure out why... but then they showed me how to customize parts of it. To add syntax highlighting and tabs, and to record macros (for doing the same operation on a bunch of different chunks of text). You can even enable mouse support when working in an XTERM (forget this GVIM thing).

    It was a steep learning curve that I probably wouldn't have endured if I hadn't been coding, but now I can edit any text more efficiently in vim than in any CLI or GUI program out there.
  • by Rhys ( 96510 ) on Monday December 10, 2007 @04:04PM (#21646499)
    vile = VI Like Emacs (http://invisible-island.net/vile/).

    Maybe vim has caught up. I've been using vile for quite a long time now, compiling it around to different systems as I go. Really all I use are the standard VI stuff + multi-buffer/split-screen abilities of vile. I should probably update myself to vim.
  • Re:Vim is painful. (Score:5, Informative)

    by morgan_greywolf ( 835522 ) on Monday December 10, 2007 @04:05PM (#21646511) Homepage Journal
    Nah. You can become competent with vi in a few days. Save yourself a lot of hassle. Print out one of these handy-dandy vi cheat sheets [uidaho.edu]. This one's not too bad [fprintf.net], but is poorly formatted, IMHO.

  • Re:Why I dislike VIM (Score:2, Informative)

    by Anonymous Coward on Monday December 10, 2007 @04:06PM (#21646513)
    to have a "No, I just want vi!" mode?

    Remove your .vimrc, or make "set compatible" the first line of it. Or use -C to force compatibility mode.
  • Used both... (Score:3, Informative)

    by Lodragandraoidh ( 639696 ) on Monday December 10, 2007 @04:27PM (#21646847) Journal
    RSM must have a time machine tucked away at the FSF. Emacs was ahead of its time - and in many respects still is. Its 20 MB footprint is slim in comparison to other tools on the market today.
    Vi, via vim, is getting more bloated - and at some point will look enough like Emacs to make the matter moot.
  • by Anonymous Coward on Monday December 10, 2007 @04:39PM (#21647049)
    Despite numerous complaints from vi users, vim still has broken p and P commands. p is paste, not paste and move the cursor for no reason. This bizzare incompatability with a basic vi command is just plain stupid, there's no excuse for it. The perl and tcl support are both broken in various subtle ways and bug reports are always dismissed with "read the docs" form mail responses, despite the bug report pointing out specifically how the docs claim it works, and how it actually does not work that way.
  • by Hatta ( 162192 ) on Monday December 10, 2007 @04:46PM (#21647147) Journal
    That's what 'ssh -X' is for.
  • coders vs. sysadmins (Score:5, Informative)

    by mungtor ( 306258 ) on Monday December 10, 2007 @04:47PM (#21647169)
    Coders like Emacs, sysadmins like VI. VI is small, fast, and almost always there on any system you can get to boot. Emacs is feature-packed and almost and entire development environment in itself, but it is rarely in /sbin or somewhere else that it can be useful on a crashed system.

    Whether VI is good at handling 2MB files is generally irrelevant when you need to correct a typo in /etc/vfstab that's keeping one of your systems from booting. It may not be prefect, but it's better than ed.
  • Re:Using vi (Score:5, Informative)

    by Hatta ( 162192 ) on Monday December 10, 2007 @04:56PM (#21647291) Journal
    LOL, best troll EVER.

    Not only is this a simple edit of the classic Mac troll [kottke.org](scroll to the bottom), but he gets modded insightful and 8 people take him seriously. Very good job sir.
  • Re:Using vi (Score:3, Informative)

    by just_another_sean ( 919159 ) on Monday December 10, 2007 @05:19PM (#21647635) Journal
    He's just recycling an old joke. I found a copy of it here: http://kottke.org/order/apple [kottke.org] - scroll to the bottom to see the original "I don't want to start a holy war..." troll. :-)

  • Re:Vim is painful. (Score:5, Informative)

    by jdgeorge ( 18767 ) on Monday December 10, 2007 @05:46PM (#21648021)
    You're not alone. For those who dig eclipse, there do appear to be efforts related to this, such as eclim [sourceforge.net], vimplugin [sourceforge.net], and viPlugin [satokar.com].

    May the source be with you.
  • Re:vimdiff (Score:5, Informative)

    by jmorris42 ( 1458 ) * <{jmorris} {at} {beau.org}> on Monday December 10, 2007 @07:00PM (#21648997)
    > the rest of us, who use more decent tools, can just snicker.

    I take it you are a code monkey developing mainstream apps, most of the more evolved ones are emacs folks. But admins and embedded folks are often working in diverse environments, many of which don't have emacs but any *NIX type environment will have vi. Busybox implements a vi clone. I seriously doubt you will find emacs on very many routers, access points, settop boxes, cell phones, etc.

    Since I use so many different machines it just makes sense to default to vi/vim and stick to assuming only the default behaviour. Emacs only makes sense if you mostly use a single home directory where you can have emacs customized.
  • by tempest69 ( 572798 ) on Monday December 10, 2007 @08:36PM (#21650069) Journal

    I for one would rather use emacs, but if key combinations like ctrl+alt+meta+% are beyond your manual dexterity, the best vi clone is vigor A few years ago, I modified all of the system test environments at my workplace so that vi was just an alias to vigor. All of the administrators were thrilled with vigor's responses, including everyone's favorite: 'You pressed the right arrow key. Push OK to continue'. No OS can be considered mature (or senile) if Vigor isn't installed by default.
    ok, this one got me.. Why sysadmins go for vim.. first it's everywhere, which has been covers an-nauseum here.. But it doesn't need jack except the escape key to get through a system. Alt tab on a windows box, and poof, youve gone to a new window.. and it didnt do jack to your emacs session. VIM just needs escape..

    yes, Emacs can be set up great, and windows to ignore alt tab, and a myriad of other things. But VIM is slick, migrating from VI acolyte to EMACS is just heresy

    Storm

  • Re:Vim is painful. (Score:3, Informative)

    by Thornkin ( 93548 ) on Monday December 10, 2007 @10:09PM (#21650689) Homepage
    http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html [viemu.com] is another good cheat sheet and a good tutorial.
  • Re:Vim is painful. (Score:3, Informative)

    by seanmeister ( 156224 ) on Monday December 10, 2007 @10:27PM (#21650815)

    I am a vim zealot. I'll put that right out there. I am extremely fast at coding in vim. That said, I also want some of the more advanced features that exist in modern IDEs.

    You might like PIDA [pida.co.uk] - it gives you a real, honest-to-gosh vim wrapped in fancy IDE features.

  • Re:Why I dislike VIM (Score:1, Informative)

    by Anonymous Coward on Monday December 10, 2007 @10:30PM (#21650833)
    The traditional vi is available here:
    http://ex-vi.sourceforge.net/ [sourceforge.net]
  • by Anonymous Coward on Tuesday December 11, 2007 @02:27AM (#21652291)
    You can fix that by typing

    :highlight LineNr ctermfg=white guifg=white


    in normal mode.

No man is an island if he's on at least one mailing list.

Working...