🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

6 total messages Started by Ilya Sun, 16 Feb 1997 00:00
A delete questions in vim
#3969
Author: Ilya
Date: Sun, 16 Feb 1997 00:00
15 lines
913 bytes
 In vim

 dfA

 will delete to and including "A" character on a line in the command
 mode. How do I do the same thing globally - to every line in the file? Is
 there a simpler solution in emacs or with sed?

 Thanks.

 Ilya

 
 
Re: A delete questions in vim
#3970
Author: Sven Guckes
Date: Sun, 16 Feb 1997 00:00
21 lines
1439 bytes
ibelooze@runet.edu (Ilya):
> In vim [the command] dfA will delete to and including "A" character on a
> line in the command mode. How do I do the same thing globally - to every
> line in the file?

The command deletes to the next 'A' - so it depends on the current position.
As this is not defined I assume that position in column 0 is wanted.

	:%s/^.*A//

Well, this will delete to the last  'A' in every line.
This one should delete to the first 'A' of every line:

	:%s/^.*A[^A]*$//

> Is there a simpler solution in emacs or with sed?

	sed -e "s/^.*A//" file > outfile

Sven
Re: A delete questions in vim
#3971
Author: Tad McClellan
Date: Sun, 16 Feb 1997 00:00
22 lines
1280 bytes
Ilya (ibelooze@runet.edu) wrote:

:  dfA

:  will delete to and including "A" character on a line in the command
:  mode. How do I do the same thing globally - to every line in the file? Is
:  there a simpler solution in emacs or with sed?


:%s/^[^A]*A//


pretty much the same with sed:

sed -e 's/^[^A]*A//' filename


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net
Re: A delete questions in vim
#3972
Author: Sitaram Chamarty
Date: Mon, 17 Feb 1997 00:00
25 lines
1615 bytes
guckes@banach.math.fu-berlin.de (Sven Guckes) wrote:

>ibelooze@runet.edu (Ilya):
>> In vim [the command] dfA will delete to and including "A" character on a
>> line in the command mode. How do I do the same thing globally - to every
>> line in the file?
>
>The command deletes to the next 'A' - so it depends on the current position.
>As this is not defined I assume that position in column 0 is wanted.
>
>	:%s/^.*A//
>
>Well, this will delete to the last  'A' in every line.
>This one should delete to the first 'A' of every line:
>
>	:%s/^.*A[^A]*$//

Never forget "normal" - makes life very simple very often!
        :g/A/ normal dfA
However, the screen flashes a heck of a lot - as vim hits all the lines that
have an "a" but not "A" (my settings are always "ic").  If that's a bother
":set noic" first.

Sitaram
Re: A delete questions in vim
#3973
Author: Kai Grossjohann
Date: Mon, 17 Feb 1997 00:00
18 lines
1481 bytes
>>>>> Ilya  writes:

  Ilya>  will delete to and including "A" character on a line in the
  Ilya>  command mode. How do I do the same thing globally - to every
  Ilya>  line in the file? Is there a simpler solution in emacs or
  Ilya>  with sed?

Emacs:

M-x query-replace-regexp RET ^[^A]*A RET RET

Then, hit "!" to skrip the yes/no questions.

kai
-- 
The arms should be held in a natural and unaffected way and never
be conspicuous. -- Revised Technique of Latin American Dancing
Re: A delete questions in vim
#3974
Author: RAK Dimitry
Date: Mon, 17 Feb 1997 00:00
32 lines
1734 bytes
Kai Grossjohann wrote:
> 
> >>>>> Ilya  writes:
> 
>   Ilya>  will delete to and including "A" character on a line in the
>   Ilya>  command mode. How do I do the same thing globally - to every
>   Ilya>  line in the file? Is there a simpler solution in emacs or
>   Ilya>  with sed?
> 
> Emacs:
> 
> M-x query-replace-regexp RET ^[^A]*A RET RET
[snip]

- it's wrong because every line like
bbbbacccc
  will be replaced by
cccc

  If you want to replace first 'A 'in every line (not 'a') then the
best way in Emacs is the following:
M-x  eval-expression RET
(let (case-fold-search)(replace-regexp "\\(^[^A\n]*\\)A" "\\1" nil)) RET

  To replace last 'A':
M-x  eval-expression RET
(let (case-fold-search)(replace-regexp "A\\([^A\n]*$\\)" "\\1" nil)) RET

  To replace all 'A':
M-x  eval-expression RET
(let (case-fold-search)(replace-string "A" "" nil)) RET
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads