🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.editors
Article #3974

Re: A delete questions in vim

#3974
From: 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
Technical Details
Message-ID: <33085C2F.794B@minsk.matra-dtv.fr>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <5e6c42$ou7@newslink.runet.edu> <vaflo8nbt8s.fsf@ls6.informatik.uni-dortmund.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f8c9b,99ce9c1deb2ced06
X-Google-Attributes: gidf8c9b,public
X-Google-Thread: 107393,99ce9c1deb2ced06
X-Google-Attributes: gid107393,public
X-Google-Thread: 102b9a,99ce9c1deb2ced06
X-Google-Attributes: gid102b9a,public
X-Google-Thread: 103b8b,99ce9c1deb2ced06
X-Google-Attributes: gid103b8b,public
From: RAK Dimitry <d-rak@minsk.matra-dtv.fr>
Subject: Re: A delete questions in vim
Date: 1997/02/17
Message-ID: <33085C2F.794B@minsk.matra-dtv.fr>
X-Deja-AN: 219370262
References: <5e6c42$ou7@newslink.runet.edu> <vaflo8nbt8s.fsf@ls6.informatik.uni-dortmund.de>
Content-Type: text/plain; charset=us-ascii
Organization: ECC Minsk
Mime-Version: 1.0
Newsgroups: comp.editors,comp.emacs,gnu.emacs.help,comp.unix.questions
X-Mailer: Mozilla 3.0 (X11; I; OSF1 V3.2 alpha)