An easy, quick vi tutorial...

Bill Campbell bill at celestial.com
Wed Oct 24 15:32:02 PDT 2007


On Wed, Oct 24, 2007, Fairlight wrote:
>On Wed, Oct 24, 2007 at 03:23:05PM -0400, Jay Ashworth may or may not have
>proven themselves an utter git by pronouncing:
>> On Wed, Oct 24, 2007 at 12:08:56PM -0400, Walter Vaughan wrote:
>> > I don't use the "o" command since it's "i" or "a" and the Return key, but I use 
>> > the "j" or join command a lot.
>
>But "j" is down a line.  "J" is join.
>
>Trust me, accidentally hitting capslock while in vi is guaranteed to screw
>things up royally, and heaven help you if you're doing heads-down data
>entry rather than heads-up when this happens.  The vim version is a bit
>more foregiving with undo, but standard vi has more limitations on how much
>you can undo.  At least that's been my experience.  I thought the original
>didn't have a redo, either, where vim does.

It took me a while to get used to vim's undo where repeated ``u''
undoes multiple ``do's'' whereas vi will alternate between the
undo and the last do.

As for redo, that's always been there with the ``.'' command to
repeat the last action.  I've gotten some amazed comments from
people who might see me hit ``/pattern/'' to find a pattern,
``cwtextESC'' to change a word, then `n.' to find the next
occurrence and repeat the change.  Let's see them do *THAT* with
Microsoft Word :-).

>A lot of people seem to bash vim for not being the original, but it has
>some nice enhancements.
>
>> But it's not: o works *no matter where you are on the line*.  I use it
>> almost exclusively.
>
>I use it ~50% exclusively, but also make use of "O" for the other half (the
>capital version) both in email and coding.  Just depends which way you
>wanna go.

Most of vi(m)'s letter commands have logical extensions with the
capital letter.  ``a'' appends after the current character while
``A'' appends to the end of the line.  ``i'' inserts before the
cursor while ``I'' inserts at the beginning of the line, etc.
The upper case version does a bit More than the lower case.

>It's funny...  I used to use emacs exclusively at university.  I -love-
>emacs, and all my shells use emacs-style bindings by default.  But I ended
>up working on so many SCO systems where emacs wasn't available that I
>learned vi.  It's not that I no longer like emacs, but that I really didn't
>want to be flipping between editors, so I switched to vi since it's pretty
>much guaranteed to be there in some form.  But our joke (amongst emacs
>fans) used to be that vi had two modes:  insert mode, and beep mode.  :)

I tell folks that if the don't know where they are in vi, to hit
the ESC key until it beeps, then they know they're in command mode.

>Funny thing about John's original comment about not being able to do much
>configuration of linux without vi.  You'd be surprised how many try.  Be it
>the vendor-supplied setup tools, or something horrid like webmin.
>Alternately, if they -must- edit, many go for pico, which is far simpler,
>but which tends to -break- config files with long lines that wrap.  You
>have no idea how many hosts.allow, smb.conf and other files of the like
>I've had to fix over the years, simply because someone was using the wrong
>editor for the job because they didn't want to learn and use vi.  Hopefully
>this tutorial will mitigate that for some folks.

I think that ``pico -t'' suppresses the word wrap on long lines.

I always have to do a ``:set wm=0'' when editing files with long
lines as I have ``wm'' set to automatically wrap when typing.

Bill
--
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

Microsoft IIS has more holes than a wheel of Swiss Cheese after a shotgun
blast -- John Dvorak


More information about the Filepro-list mailing list