help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: #1: How to do vi's 'g/foo/s/x/y/' #2: + with a Q-R "yes/no?"


From: Sam Peterson
Subject: Re: #1: How to do vi's 'g/foo/s/x/y/' #2: + with a Q-R "yes/no?"
Date: 08 Apr 2007 03:28:54 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/22.0.50

dkcombs@panix.com (David Combs) on 7 Apr 2007 13:51:52 -0400 didst step forth
and proclaim thus:

> (1) How to do, in gnu-emacs,  vi's 'g/foo/s/x/y/':
> 
> That is, "on all lines that contain regexp "foo", change x to y.
> 
> And maybe also with option: only the first one on that line, or all of them? 

Good question.  There's no quick equivalent to my knowledge.  Though there are
probably a few ways to implement it.  The best method would be to write some
lisp code as I thought about how to do it with a macro and it started getting
too complicated.

M-x occur <RET> is definitely worth looking into.

> (2) Same as above, BUT WITH A QUERY-REPLACE-LIKE "YES|NO|!|etc" prompt.
> 
> (No, I believe that vi-emulator .el-package does NOT implement
> vi's "g/pat/<vi-command>/"  
> 
>   (Sure would be nice if it did!)

What are you talking about?  There's three different vi emulators in Emacs.  I
tried the above command in both vip and viper and it worked perfectly.

-- 
Sam Peterson
skpeterson At nospam ucdavis.edu
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown



reply via email to

[Prev in Thread] Current Thread [Next in Thread]