Remote unix text editing (Was: Why is there no or or and ?)
H. S. Teoh
hsteoh at quickfur.ath.cx
Sat Feb 18 10:33:13 PST 2012
On Sat, Feb 18, 2012 at 12:10:48PM -0500, Nick Sabalausky wrote:
> I've heard a lot of people say that about vi(m), but in my (admittedly
> somewhat limited) experience, I've never come across a (Li|U)n[ui]x
> system that didn't have nano or pico (neither of which are great, but
> they're good enough for editing Unix configuration files, and I'm
> actually capable of using them, unlike emacs or vim).
I used to swear by pico. Until my manager at my first job convinced me
to try vi. Ever since then, I've acquired this occasional twitching to
randomly hit the Escape key every few seconds. ;-)
> If I'm using a server that doesn't already have ssh set up (for
> instance, if I'm actually setting up ssh) *then* I'll either use
> nano/pico or, if I can, I'll install mcedit which is the closest I've
> seen to what I would consider a nice text-mode editor.
I used to hate vi and its variants because of modality, which I just
couldn't understand how anyone could consider as *not* a handicap.
But I have to say, after having actually used it for quite a number of
years now, I simply can't bear to go back to pico. Being able to move in
text by words or blocks or even matching parentheses/brackets/braces
with just a keystroke or two, or apply complex commands (like regexes)
to large blocks of text at a time (thus effecting a very large change
*reliably*), going back to pico is like going back to a 50-year-old
screwdriver with a loose handle after having used a power drill. It
makes me feel so crippled.
Part of what makes vi useful is that many of its commands can deal with
logical units greater than a single character. So you can, e.g.,
navigate by words or paragraphs or matching braces (extremely useful for
moving around in code) with just one or two keystrokes, replace a word
without needing to count how long it is, cut-n-paste n paragraphs (or
words, etc.) around without needing to actually traverse them. In pico
you'd have to select, then hit down X number of times per paragraph,
before you can actually cut. In vi, you just type "d5}" to delete 5
paragraphs, then use '/' (search) to find the reinsertion point, and
then 'p' to paste everything in there. You can also say, "cut to end of
file" with just two keystrokes: "dG". My favorite is "replace up to
closing parenthesis": "c/)<ESC>replacement_text<ESC>". Very useful for
editing code without needing to recount parentheses.
Furthermore, being able to tell the editor to repeat a (set of) commands
n times is very useful, instead of having to manually repeat it
yourself. Having logical units is useful here, e.g., you can repeatedly
replace words of different lengths with a replacement word without
needing to worry about mismatching lengths.
In many ways, using vi vs. pico to me is, in retrospect, like using C
arrays vs. D arrays. :) Everything you can do with D arrays and slices,
you can do in C, just in a much more tedious and error-prone way.
Similarly, pico can in principle do everything that vi does too, just
that vi gets you there with less pain.
Just my $0.02.
If you want to solve a problem, you need to address its root cause, not
just its symptoms. Otherwise it's like treating cancer with Tylenol...
More information about the Digitalmars-d