begin  quoting Ralph Shumaker as of Wed, Jan 31, 2007 at 09:40:40PM -0800:
[snip]
> I found the :s/// command in help.  But I guess I needed help with 
> regular expressions since that's where I went way wrong.  That, and my 
> command lacked the "%".

Ah!

> You assumed "^" is "start of line".

Yes, I did. :)
 
>                                      It's not.  I'm assuming I need to 
> escape that too.  "\^"  But I'd like to verify each replacement.  With 
> the s:/// command in help, it says to use "[c]" after the final "/". 
> (It does not say whether or not the braces are needed.  It makes me 
> think that they are needed except that previously in the same command 
> they have "s[ubstitute]/".)

It's common to use brackets to indicate optional bits; I don't
know the origin, but it's been common practice for as long as
I've been looking at computer manuals, and it seemed an established
convention even then.

> Anyway, you gave me what I needed.

Yay!

>                                     I figured that if I try it and 
> something goes amiss, I can just abort without saving the file, then 
> just try again, which is what I did.

Yup.

> I had to make a few adjustments, but it finally worked.
> :%s/\^\([0-9]\)\([A-Z]\)/\^\1 \2/c

Yay!

> I appended the c.  I escaped the "^".  And finally, I inserted "\^" in 
> front of "\1".  I went through enough of them to be sure that all was 
> good, and then chose "a" (for "all").  That's 4,226 substitutions down 
> (after having done several hundred by hand).

Heh.

> Is "\1" and "\2" part of regular expressions?  Or is that something 
> native to vi?

Um, technically, no, as regular expressions are 'recognizers'. However,
for regular-expressions-used-as-transformations, it's pretty common
syntax.

> Is there something simple (like a pamphlet) to explain *just* the basics 
> of regular expressions?

There's a whole book: "Mastering Regular Expressions", and most
vi, sed, and perl books have a section on the basics of regular
expressions.

Wikipedia has a decent history with a section some of the basics:

http://en.wikipedia.org/wiki/Regular_expression

> (I just noticed the drift from my subject line which happened before I 
> even sent it.  It turns out that I started in "man vi", and very *very* 
> reluctantly started looking in "info vi".  But I never had the patience 
> to learn the /language/ (so to speak) of "info".  They should consider 
> setting up something like man or info in html.)
 
There are manpages in html.  All over the place.

See

http://unixhelp.ed.ac.uk/CGI/man-cgi

for one.

> Also, in vi, how do I make ":set mouse=a" permanent?

Put it in your .exrc (for vi, vim, and gvim), .vimrc (for vim and gvim),
or .gvimrc (for just gvim), sans leading colon.

-- 
Have the Vim book. Haven't read it yet.
Stewart Stremler


-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to