From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: C K Kashyap Newsgroups: gmane.emacs.help Subject: Re: Emacs equivalent of the ":g" command in vi Date: Sat, 23 Jul 2011 08:32:03 +0530 Message-ID: References: <4E29DD40.80909@arlsoft.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=00151774183a7718cd04a8b3cef0 X-Trace: dough.gmane.org 1311390135 2161 80.91.229.12 (23 Jul 2011 03:02:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 23 Jul 2011 03:02:15 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: MBR Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jul 23 05:02:11 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QkSTi-0006Mo-Rm for geh-help-gnu-emacs@m.gmane.org; Sat, 23 Jul 2011 05:02:10 +0200 Original-Received: from localhost ([::1]:49009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QkSTi-0003Yi-Ax for geh-help-gnu-emacs@m.gmane.org; Fri, 22 Jul 2011 23:02:10 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:43586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QkSTd-0003Yd-A0 for help-gnu-emacs@gnu.org; Fri, 22 Jul 2011 23:02:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QkSTc-0001ya-9L for help-gnu-emacs@gnu.org; Fri, 22 Jul 2011 23:02:05 -0400 Original-Received: from mail-iy0-f169.google.com ([209.85.210.169]:34325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QkSTc-0001yW-1W for help-gnu-emacs@gnu.org; Fri, 22 Jul 2011 23:02:04 -0400 Original-Received: by iyb14 with SMTP id 14so2996331iyb.0 for ; Fri, 22 Jul 2011 20:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ayG6jxzX9aBpjHhFjI6766fHZ+EJub6A2/u1wD4dicU=; b=rAJZ3Yq4JcawaMmd0jLy2/HrEpzpwzT8FoopchZI8aV37UTHPaFquzcnZjTCwqqdmK qZhYph4HMENjSpNJ5QSvVR9IT6+mdI9aAGtXRMGOuAd9ONNtU+nxgIYBne1kJ4ggQ9PG fsRxzzY8U2JjYuqskvZoM/phC/hmYn9Gh0KWs= Original-Received: by 10.231.84.144 with SMTP id j16mr1969423ibl.145.1311390123366; Fri, 22 Jul 2011 20:02:03 -0700 (PDT) Original-Received: by 10.42.115.72 with HTTP; Fri, 22 Jul 2011 20:02:03 -0700 (PDT) In-Reply-To: <4E29DD40.80909@arlsoft.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.169 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81744 Archived-At: --00151774183a7718cd04a8b3cef0 Content-Type: text/plain; charset=ISO-8859-1 > > Save your .emacs file: C-x C-s > > Mark Rosenthal > mbr@arlsoft.com > > P.S. - Interesting side-note. Did you know that the ed command: > > g/regular expression/operation > > is where the name "grep" came from? In ed and ex, the "g" means do a > global search for the immediately following regular expression, and apply > the operation to every matching line. One such operation is "p" meaning > "print". Using "re" as shorthand for "regular expression", the ed command > to print every line that matches a particular regular expression is: > > g/re/p > > > Thank you very much Mark for the detailed explanation and the interesting side note :) I am inclined to the macro approach since the possibilities are endless. Regards, Kashyap --00151774183a7718cd04a8b3cef0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Save your .emacs file: C= -x C-s
Mark Rosenthal
mbr@arlsof= t.com
P.S. - Interesting side-note.=A0 Did you know that the ed command:

=A0=A0=A0 g/regular expression/operation

is where the name "grep" came from?=A0 In ed and ex, the &quo= t;g" means do a global search for the immediately following regular expression, and apply the operation to every matching line.=A0 One such operation is "p" meaning "print".=A0 Using "re" as = shorthand for "regular expression", the ed command to print every line that matches a particular regular expression is:

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 g/re/p



Thank you very much Mark for the detailed expla= nation and the interesting side note :) I am inclined to the macro approach= since the possibilities are endless.

Regards,
Kashyap
--00151774183a7718cd04a8b3cef0--