unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to kill line beginning with specific string
@ 2009-11-18 18:51 brooklynwhite
  2009-11-19  6:43 ` Dirk-Jan C. Binnema
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: brooklynwhite @ 2009-11-18 18:51 UTC (permalink / raw)
  To: Help-gnu-emacs


I need to figure out how to kill a series of lines in a text file that all
begin with the same string.  The format of the lines is:
2000 001 00        AIR TEMP     354

The second and third expressions in the line change with subsequent lines,
e.g.:

2000 002 01        AIR TEMP     354

Is there a simple way for me to search for and kill all of these lines
without having to repeatedly enter the search mode and type ctrl-k when the
line is found?  I realize this may be a silly question so thanks for your
patience and help.
-- 
View this message in context: http://old.nabble.com/How-to-kill-line-beginning-with-specific-string-tp26413518p26413518.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to kill line beginning with specific string
  2009-11-18 18:51 How to kill line beginning with specific string brooklynwhite
@ 2009-11-19  6:43 ` Dirk-Jan C. Binnema
  2009-11-19 17:12   ` brooklynwhite
  2009-11-19 10:14 ` Peter Dyballa
       [not found] ` <mailman.11032.1258625728.2239.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 6+ messages in thread
From: Dirk-Jan C. Binnema @ 2009-11-19  6:43 UTC (permalink / raw)
  To: brooklynwhite; +Cc: Help-gnu-emacs


>>>>> brooklynwhite  <white805@umn.edu> writes:

    > I need to figure out how to kill a series of lines in a text file that all
    > begin with the same string.  The format of the lines is:
    > 2000 001 00        AIR TEMP     354

    > The second and third expressions in the line change with subsequent lines,
    > e.g.:

    > 2000 002 01        AIR TEMP     354

    > Is there a simple way for me to search for and kill all of these lines
    > without having to repeatedly enter the search mode and type ctrl-k when the
    > line is found?  I realize this may be a silly question so thanks for your
    > patience and help.

M-x flush-lines

Best wishes,
Dirk.

-- 
Dirk-Jan C. Binnema                  Helsinki, Finland
e:djcb@djcbsoftware.nl           w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to kill line beginning with specific string
       [not found] <mailman.11014.1258611938.2239.help-gnu-emacs@gnu.org>
@ 2009-11-19  8:47 ` Giorgos Keramidas
  0 siblings, 0 replies; 6+ messages in thread
From: Giorgos Keramidas @ 2009-11-19  8:47 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, 18 Nov 2009 10:51:29 -0800 (PST), brooklynwhite <white805@umn.edu> wrote:
> I need to figure out how to kill a series of lines in a text file that all
> begin with the same string.  The format of the lines is:
>
> 2000 001 00        AIR TEMP     354
>
> The second and third expressions in the line change with subsequent
> lines, e.g.:
>
> 2000 002 01        AIR TEMP     354
>
> Is there a simple way for me to search for and kill all of these lines
> without having to repeatedly enter the search mode and type ctrl-k
> when the line is found?  I realize this may be a silly question so
> thanks for your patience and help.

You can use `M-x flush-lines RET'.  Note that the `flush-lines' argument
is a regular expression, but it should work fine for simple string
matching too.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to kill line beginning with specific string
  2009-11-18 18:51 How to kill line beginning with specific string brooklynwhite
  2009-11-19  6:43 ` Dirk-Jan C. Binnema
@ 2009-11-19 10:14 ` Peter Dyballa
       [not found] ` <mailman.11032.1258625728.2239.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 6+ messages in thread
From: Peter Dyballa @ 2009-11-19 10:14 UTC (permalink / raw)
  To: brooklynwhite; +Cc: Help-gnu-emacs


Am 18.11.2009 um 19:51 schrieb brooklynwhite:

> Is there a simple way for me to search for and kill all of these lines
> without having to repeatedly enter the search mode and type ctrl-k  
> when the
> line is found?


You can check with C-M-s ^2000 .*C-qC-j – it will high-light the  
matching lines. Once you're content you can use replace-regexp to  
replace all that matches the regular expression with nothing.

--
Greetings

   Pete

"Indentation?! I will show you how to indent when I indent your skull!"





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to kill line beginning with specific string
       [not found] ` <mailman.11032.1258625728.2239.help-gnu-emacs@gnu.org>
@ 2009-11-19 10:45   ` Miles Bader
  0 siblings, 0 replies; 6+ messages in thread
From: Miles Bader @ 2009-11-19 10:45 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Dyballa <Peter_Dyballa@Web.DE> writes:
>> Is there a simple way for me to search for and kill all of these lines
>> without having to repeatedly enter the search mode and type ctrl-k 
>> when the
>> line is found?
>
> You can check with C-M-s ^2000 .*C-qC-j – it will high-light the
> matching lines. Once you're content you can use replace-regexp to
> replace all that matches the regular expression with nothing.

Perhaps more easily, use the `flush-lines' command, and give it a regexp
of "^" + your string:

E.g., to kill lines beginning with "my prefix":

   M-x flush-lines RET ^my prefix RET

[Note that flush-lines operates on all lines _following point_, so you
might want to move to the beginning of the buffer first.]

-Miles

-- 
Cynic, n. A blackguard whose faulty vision sees things as they are, not as
they ought to be. Hence the custom among the Scythians of plucking out a
cynic's eyes to improve his vision.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to kill line beginning with specific string
  2009-11-19  6:43 ` Dirk-Jan C. Binnema
@ 2009-11-19 17:12   ` brooklynwhite
  0 siblings, 0 replies; 6+ messages in thread
From: brooklynwhite @ 2009-11-19 17:12 UTC (permalink / raw)
  To: Help-gnu-emacs


Your help is much appreciated!!!


djcb wrote:
> 
> 
>>>>>> brooklynwhite  <white805@umn.edu> writes:
> 
>     > I need to figure out how to kill a series of lines in a text file
> that all
>     > begin with the same string.  The format of the lines is:
>     > 2000 001 00        AIR TEMP     354
> 
>     > The second and third expressions in the line change with subsequent
> lines,
>     > e.g.:
> 
>     > 2000 002 01        AIR TEMP     354
> 
>     > Is there a simple way for me to search for and kill all of these
> lines
>     > without having to repeatedly enter the search mode and type ctrl-k
> when the
>     > line is found?  I realize this may be a silly question so thanks for
> your
>     > patience and help.
> 
> M-x flush-lines
> 
> Best wishes,
> Dirk.
> 
> -- 
> Dirk-Jan C. Binnema                  Helsinki, Finland
> e:djcb@djcbsoftware.nl           w:www.djcbsoftware.nl
> pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C
> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-kill-line-beginning-with-specific-string-tp26413518p26421398.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-11-19 17:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-18 18:51 How to kill line beginning with specific string brooklynwhite
2009-11-19  6:43 ` Dirk-Jan C. Binnema
2009-11-19 17:12   ` brooklynwhite
2009-11-19 10:14 ` Peter Dyballa
     [not found] ` <mailman.11032.1258625728.2239.help-gnu-emacs@gnu.org>
2009-11-19 10:45   ` Miles Bader
     [not found] <mailman.11014.1258611938.2239.help-gnu-emacs@gnu.org>
2009-11-19  8:47 ` Giorgos Keramidas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).