February 17, 2005
The Power of Vim
A few months ago I owned up to the fact that, whilst I appreciated it's usefulness, Vim was a tool that I had in no way mastered. Brian agreed with me that Vim is not intuitive but advised that it is worth learning because of it's extreme power.
This morning I was faced with the essentially simple task of changing all 7,064 lines of a text file so that, where there were 16 lots of a particular field, there were now 60 of them. This is where the power of Vim, and a recent tip from Alan, came to my aid.
By using Vim's substitute command, in it's :%s form, the task was a piece of cake! This may seem trivial to those who already feel well and truly at home with Vim and it's commands. But for me the experience was a powerful example of how useful Vim is.
So now I am further encouraged to progress along the path towards becoming a Vim Master. As Steve Oualline says from the outset in his book, Vi IMproved - Vim(PDF):
The Vim editor is one of the most powerful text editors around. It is also extremely efficient, enabling the user to edit files with a minimum of keystrokes. This power and functionality comes at a cost, however: When getting started, users face a steep learning curve.For me, it's onwards up the curve... Posted to Software Development by Keith Pitty
Keep on climbing, the view from the top is quite spectacular.
Posted by: Andy Todd at February 17, 2005 3:19 PMEmacs has that but also macros, which lets you do incredible stuff. Regexp search/replace is a goood start but is not always sufficient.
The magic words: \C-x(, \C-x) and \C-xe.
Look them up.
Vim has macros as well, albiet not as clean as Emacs. With severe tweaking and knowlege, vim can be made pretty powerful. You're not going to build JDEE with it, but you can do a lot of stuff.
I'm a longtime sysadmin who lived, died, and swore by vim (or vi, depending on platform). I found myself intrigued by emacs as a concept, and after about 4-5 seperate attempts finally spent enough time with it to get the basic commands into muscle memory (the trick to learning a new editor BTW is immersion; I set my mail editor to emacs, and turned on emacs keys for anything I could).
What's finally turned me on to emacs is that it's not modal. Not that I have a problem per-se with the modal interface of vim, but it makes it basically impossible to customize most programs to use vim keys. They just are built to be modal. Emacs ctrl-everything works much better, so you can reprogram keys in any customizeable editor to work with emacs keys. I even managed to come across a program called XKeymacs that does a disturbingly good job of making basic emacs keys work across the whole OS on windows; every program, including outlook, word, notepad, etc. gets emacs keys now for me. I never have to touch the arrow keys and life is sweet.
Pre-emacs, I'd always end up trying to move the cursor with hjkl in outlook and have to do a lot of backspacing. Using a unified set of keys everywhere makes an amazing difference to the transparency of things (and on my linux box, basically everything is emacs keys as well).
Just something to think about if you haven't followed vim too far yet. Although if you ever have to deal with Unix, vi knowledge is a requirement, period. I no longer allow anyone who doesn't know vi root on anything.
Posted by: Rob Meyer at February 17, 2005 7:50 PMWhoops, that should be "they are just -not- built to be modal."
Posted by: Rob Meyer at February 17, 2005 7:53 PMI posted a challenge on my blog...
http://beust.com/weblog/archives/000246.html
Rob, Cedric: Thanks for your comments about emacs.
I think I'll stick with improving my mastery of vim for the time being but, you never know, one day I may strive to become an emacs master!
Posted by: Keith Pitty at February 18, 2005 9:38 AM
