[Tutor] Productivity

Alan Gauld alan.gauld at blueyonder.co.uk
Wed Sep 10 23:52:45 EDT 2003


> I always hear that vim and emacs are wonderful editors, and that
when we
> know it they enhance productivity without explaining why. I've used
> emacs for some time, and I've tried without much succes to start
using vi.
>
> Could someone explain the features that make them enhance
productivity
> in such manner?

Its not so much the features, although there are many indeed, but
the way those features are accessed. The number of keystrokes
to achieve something is very few.

Another really powerful feature is the ability to repeat any
command seveal times. Thus if you want to substitute(aka replace)
a piece of text the next 5 times you just tell the substitute
command to repeat 5 times.

Or if you only want to peform the substitution within a particular
region you select it then execute the replace. It will only
replace within the region.

The ability to repeat a search using a single key (OK F3 often
works in Windows editors too) but a letter on the keyboard is
easier to type.

The abiliity to use a search string to operate on a bit of text:
For example say I want to delete from the current position
to the fist occurence of the word perambulate, in vi I type:

:.,/perambulate/d

And when you add the power if regular expressions to those search
strings it gets really powerful.

Macros are great too.

The joy of vi is the speed of navigation compared to other
editors, it started life as a line editor where navigation
speed and precision was paramount and that ability to quickly
find exactly the text you want is still there.

The ability to choose the scope of my editting operations
- do I want to operate on a whole line, a word or a character?
Or maybe a paragraph? Or a number of lines?

All of these are simply a character pre or postfix to my command:

cw - change word
cc - change line
5cw - change 5 words
5cc - change 5 lines

dw - delete word
dd = delete line
5dw - delete 5 words
5dd - delete 5 lines

yw - copy a word
yy - copy a line
5yw - copy 5 words
5yy - copy 5 lines

notice the consistency?

Also the t and f commands in vi are invaluable

dtg - delete up to but not including the next letter g
dfg - delete up to and including the letter g

I could go on, and many of these may not sound like
huge gains but once you get used to them all the
hints and suggestions offered by IDLE(*) etc are
no compensation when it comes to just cranking out code.

(*)I rarely need the hints in IDLE when doing Python because
I've been trying the code out at the prompt anyway. In Delphi
I love the hints feature...

Alan G.

PS The above is vi focussed but emacs offers similar types
of power editing tools and a bunch more besides (smart
grep is one I love)




More information about the Tutor mailing list