unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* (newbie) search & replace (—match case) all at once without confirmation automation
@ 2022-11-02 12:26 jindam, vani
  2022-11-02 17:35 ` tomas
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: jindam, vani @ 2022-11-02 12:26 UTC (permalink / raw)
  To: help-gnu-emacs

hello emacs users,

after trying several gui text editors, i 
hesistantly installed & familiarising emacs.
so far, good. i have decided to use as default 
text editor.

my search contains characters such as { or - or = 
and alphabets. in other cli/gui editors, i choose 
"match case" and "replace all".
for example: "{{cite", "agree=yes"

straight to point:
* where can i find examples for "search & replace 
(—match case) all at once without confirmation"?
* is it possible to use more than one for 
search & replace? i mean, i want to replace 
"{{cite", "agree=yes" at once?
* if i cant use more than one, how do i automate?

regards,
jindam, vani

toots: @jindam_vani@c.im
others: en.wikipedia.org/wiki/User:Jindam_vani



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

* (newbie) search & replace (—match case) all at once without confirmation automation
@ 2022-11-02 14:48 jindam, vani
  0 siblings, 0 replies; 8+ messages in thread
From: jindam, vani @ 2022-11-02 14:48 UTC (permalink / raw)
  To: help-gnu-emacs

hello emacs users,

after trying several gui text editors, i 
hesistantly installed & familiarising emacs.
so far, good. i have decided to use as default 
text editor.

my search contains characters such as { or - or = 
and alphabets. in other cli/gui editors, i choose 
"match case" and "replace all".
for example: "{{cite", "agree=yes"

straight to point:
* where can i find examples for "search & replace 
(—match case) all at once without confirmation"?
* is it possible to use more than one for 
search & replace? i mean, i want to replace 
"{{cite", "agree=yes" at once?
* if i cant use more than one, how do i automate?

regards,
jindam, vani

toots: @jindam_vani@c.im
others: en.wikipedia.org/wiki/User:Jindam_vani



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

* Re: (newbie) search & replace (—match case) all at once without confirmation automation
  2022-11-02 12:26 (newbie) search & replace (—match case) all at once without confirmation automation jindam, vani
@ 2022-11-02 17:35 ` tomas
  2022-11-02 22:48 ` Emanuel Berg
  2022-11-03  4:15 ` jindam, vani
  2 siblings, 0 replies; 8+ messages in thread
From: tomas @ 2022-11-02 17:35 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1973 bytes --]

On Wed, Nov 02, 2022 at 12:26:20PM +0000, jindam, vani wrote:
> hello emacs users,
> 
> after trying several gui text editors, i 
> hesistantly installed & familiarising emacs.
> so far, good. i have decided to use as default 
> text editor.
> 
> my search contains characters such as { or - or = 
> and alphabets. in other cli/gui editors, i choose 
> "match case" and "replace all".
> for example: "{{cite", "agree=yes"

By default, search is case insensitive (unless your search
string has mixed case).

To change that, you change the value of the variable `case-fold-search'
(try: M-x customize-variable, then `case-fold-search': you get a buffer
with a button where you can switch it on or off).

There are multiple other ways to achieve that, of course.

> straight to point:
> * where can i find examples for "search & replace 
> (—match case) all at once without confirmation"?
> * is it possible to use more than one for 
> search & replace? i mean, i want to replace 
> "{{cite", "agree=yes" at once?
> * if i cant use more than one, how do i automate?

Once you get your search-and-replace running, it will stop at the first
match. There you can type 'y' or just SPACE to effect the replacement,
'n' to skip to the next match. If you want to do "all the rest", you
just type '!'. There is a little message at the bottom of your edit
window which tells you that (and the other options you have).

That said, I'd recommend that you walk the extra mile and learn
"incremental search". For one you get immediate feedback while
you are entering your search string; then, you can pick up parts
of your buffer text to complete your search string. You can change
case sensitivity on the fly, change between regular expression and
literal string on the fly, too, and lastly, upgrade your search
to a search-and-replace.

Sounds complicated, but you don't have to learn everything at once.
It's woth it :)

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: (newbie) search & replace (—match case) all at once without confirmation automation
  2022-11-02 12:26 (newbie) search & replace (—match case) all at once without confirmation automation jindam, vani
  2022-11-02 17:35 ` tomas
@ 2022-11-02 22:48 ` Emanuel Berg
  2022-11-03  4:15 ` jindam, vani
  2 siblings, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2022-11-02 22:48 UTC (permalink / raw)
  To: help-gnu-emacs

jindam, vani wrote:

> where can i find examples for "search & replace (—match
> case) all at once without confirmation"?

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/regexp.el

(defun replace-regexp-1 (re rep &optional beg end)
  (interactive
   `(,(read-string "regexp: ")
     ,(read-string "replace: ")
     ,@(when (use-region-p)
         (list (region-beginning) (region-end)) )))
  (or beg (setq beg (point-min)))
  (or end (setq end (point-max)))
  (save-excursion
    (goto-char end)
    (while (re-search-backward re beg t)
      (replace-match rep) )))

(defalias 'rr #'replace-regexp-1)

(provide 'regexp)

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: (newbie) search & replace (—match case) all at once without confirmation automation
  2022-11-02 12:26 (newbie) search & replace (—match case) all at once without confirmation automation jindam, vani
  2022-11-02 17:35 ` tomas
  2022-11-02 22:48 ` Emanuel Berg
@ 2022-11-03  4:15 ` jindam, vani
  2022-11-03  4:19   ` Emanuel Berg
  2022-11-03  5:45   ` tomas
  2 siblings, 2 replies; 8+ messages in thread
From: jindam, vani @ 2022-11-03  4:15 UTC (permalink / raw)
  To: help-gnu-emacs

November 2, 2022 at 5:36 PM, tomas@tuxteam.de wrote:


> 
> On Wed, Nov 02, 2022 at 12:26:20PM +0000, jindam, vani wrote:
> 
> > 
> > hello emacs users,
> >  
> >  after trying several gui text editors, i 
> >  hesistantly installed & familiarising emacs.
> >  so far, good. i have decided to use as default 
> >  text editor.
> >  
> >  my search contains characters such as { or - or = 
> >  and alphabets. in other cli/gui editors, i choose 
> >  "match case" and "replace all".
> >  for example: "{{cite", "agree=yes"
> > 
> 
> By default, search is case insensitive (unless your search
> string has mixed case).
> 
> To change that, you change the value of the variable `case-fold-search'
> (try: M-x customize-variable, then `case-fold-search': you get a buffer
> with a button where you can switch it on or off).
> 
> There are multiple other ways to achieve that, of course.
> 
> > 
> > straight to point:
> >  * where can i find examples for "search & replace 
> >  (—match case) all at once without confirmation"?
> >  * is it possible to use more than one for 
> >  search & replace? i mean, i want to replace 
> >  "{{cite", "agree=yes" at once?
> >  * if i cant use more than one, how do i automate?
> > 
> 
> Once you get your search-and-replace running, it will stop at the first
> match. There you can type 'y' or just SPACE to effect the replacement,
> 'n' to skip to the next match. If you want to do "all the rest", you
> just type '!'. There is a little message at the bottom of your edit
> window which tells you that (and the other options you have).
> 
> That said, I'd recommend that you walk the extra mile and learn
> "incremental search". For one you get immediate feedback while
> you are entering your search string; then, you can pick up parts
> of your buffer text to complete your search string. You can change
> case sensitivity on the fly, change between regular expression and
> literal string on the fly, too, and lastly, upgrade your search
> to a search-and-replace.
> 
> Sounds complicated, but you don't have to learn everything at once.
> It's woth it :)


i always assumed emacs as pure cli, but i was wrong.
my immediate priority is to find one click solution.
i have noted your tips, thank you. i will try today 
and if i have any issues, i will ask here.

regards,
jindam, vani

toots: @jindam_vani@c.im
others: en.wikipedia.org/wiki/User:Jindam_vani


> Cheers
> -- 
> t
>



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

* Re: (newbie) search & replace (—match case) all at once without confirmation automation
  2022-11-03  4:15 ` jindam, vani
@ 2022-11-03  4:19   ` Emanuel Berg
  2022-11-03  5:45   ` tomas
  1 sibling, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2022-11-03  4:19 UTC (permalink / raw)
  To: help-gnu-emacs

jindam, vani wrote:

> i always assumed emacs as pure cli

It can be a GUI but to most people it is a TUI ...

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: (newbie) search & replace (—match case) all at once without confirmation automation
  2022-11-03  4:15 ` jindam, vani
  2022-11-03  4:19   ` Emanuel Berg
@ 2022-11-03  5:45   ` tomas
  2022-11-03  5:55     ` Emanuel Berg
  1 sibling, 1 reply; 8+ messages in thread
From: tomas @ 2022-11-03  5:45 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 555 bytes --]

On Thu, Nov 03, 2022 at 04:15:40AM +0000, jindam, vani wrote:

[...]

> i always assumed emacs as pure cli, but i was wrong.

It can, but it won't force you. Actually, I do use the menus
from time to time -- on things I don't do very frequently.

When I find myself repeating something, I look up the command
key sequence.

> my immediate priority is to find one click solution.
> i have noted your tips, thank you. i will try today 
> and if i have any issues, i will ask here.

I hope they were helpful & enjoyable :)

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: (newbie) search & replace (—match case) all at once without confirmation automation
  2022-11-03  5:45   ` tomas
@ 2022-11-03  5:55     ` Emanuel Berg
  0 siblings, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2022-11-03  5:55 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

> When I find myself repeating something, I look up the
> command key sequence.

... if it cannot be automated ...

-- 
underground experts united
https://dataswamp.org/~incal




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

end of thread, other threads:[~2022-11-03  5:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02 12:26 (newbie) search & replace (—match case) all at once without confirmation automation jindam, vani
2022-11-02 17:35 ` tomas
2022-11-02 22:48 ` Emanuel Berg
2022-11-03  4:15 ` jindam, vani
2022-11-03  4:19   ` Emanuel Berg
2022-11-03  5:45   ` tomas
2022-11-03  5:55     ` Emanuel Berg
  -- strict thread matches above, loose matches on Subject: below --
2022-11-02 14:48 jindam, vani

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).