unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: Replace whole words?
       [not found] <Xns93E7BCA3B6E3Fljxilsjfdiaujiosdfua@130.133.1.4>
@ 2003-08-31  1:43 ` Johan Bockgård
  2003-09-01 13:19   ` Rob Thorpe
  2003-08-31  1:50 ` Jesper Harder
  2003-08-31  9:19 ` Thien-Thi Nguyen
  2 siblings, 1 reply; 5+ messages in thread
From: Johan Bockgård @ 2003-08-31  1:43 UTC (permalink / raw)


dum dee dee dum <xjkljasdfi@yahoo.org> writes:

> I have written a fairly long program, but I now want to find and
> replace all the 'int' s in the program to double as easily as
> possible. But I don't want the other words, variable names, etc. in
> the program that have 'int' in them (internationalization, for
> example) to change. Any ideas? M-% is an option

C-u M-%

    [...]
    Third arg DELIMITED (prefix arg if interactive), if non-nil, means
    replace only matches surrounded by word boundaries.

-- 
Johan Bockgård

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

* Re: Replace whole words?
       [not found] <Xns93E7BCA3B6E3Fljxilsjfdiaujiosdfua@130.133.1.4>
  2003-08-31  1:43 ` Replace whole words? Johan Bockgård
@ 2003-08-31  1:50 ` Jesper Harder
  2003-08-31  9:19 ` Thien-Thi Nguyen
  2 siblings, 0 replies; 5+ messages in thread
From: Jesper Harder @ 2003-08-31  1:50 UTC (permalink / raw)


dum dee dee dum <xjkljasdfi@yahoo.org> writes:

> I have written a fairly long program, but I now want to find and
> replace all the 'int' s in the program to double as easily as
> possible. But I don't want the other words, variable names, etc. in
> the program that have 'int' in them (internationalization, for
> example) to change. Any ideas? M-% is an option, but I have to say
> yes or no for each word it finds to make sure that parts of words
> don't get replaced - I want to do this in just one command if
> possible.

You can replace by using a regular expression -- use `C-M-%'. 

"\<" matches the beginning of a word, and "\>" matches the end of a
word.  So "\<int\>" is the string you want to search for.

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

* Re: Replace whole words?
       [not found] <Xns93E7BCA3B6E3Fljxilsjfdiaujiosdfua@130.133.1.4>
  2003-08-31  1:43 ` Replace whole words? Johan Bockgård
  2003-08-31  1:50 ` Jesper Harder
@ 2003-08-31  9:19 ` Thien-Thi Nguyen
  2 siblings, 0 replies; 5+ messages in thread
From: Thien-Thi Nguyen @ 2003-08-31  9:19 UTC (permalink / raw)


dum dee dee dum <xjkljasdfi@yahoo.org> writes:

> I want to do this in just one 
> command if possible.

hee hee answer:

     #define int double

sometimes i wish there were a C-M-% for days of the week...

thi

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

* Re: Replace whole words?
       [not found] <E19tLWW-0000ph-Tp@monty-python.gnu.org>
@ 2003-08-31 16:28 ` Joe Corneli
  0 siblings, 0 replies; 5+ messages in thread
From: Joe Corneli @ 2003-08-31 16:28 UTC (permalink / raw)


You could alternatively M-% " int " RET " double " RET !  [no quotes]
(or maybe M-% "(int " RET "(double " RET !) though this in't the elegant
way.

Joe

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

* Re: Replace whole words?
  2003-08-31  1:43 ` Replace whole words? Johan Bockgård
@ 2003-09-01 13:19   ` Rob Thorpe
  0 siblings, 0 replies; 5+ messages in thread
From: Rob Thorpe @ 2003-09-01 13:19 UTC (permalink / raw)


bojohan+news@dd.chalmers.se (Johan Bockgård) wrote in message news:<yoij3cfiha9c.fsf@frealaf.dd.chalmers.se>...
> dum dee dee dum <xjkljasdfi@yahoo.org> writes:
> 
> > I have written a fairly long program, but I now want to find and
> > replace all the 'int' s in the program to double as easily as
> > possible. But I don't want the other words, variable names, etc. in
> > the program that have 'int' in them (internationalization, for
> > example) to change. Any ideas? M-% is an option
> 
> C-u M-%
> 
>     [...]
>     Third arg DELIMITED (prefix arg if interactive), if non-nil, means
>     replace only matches surrounded by word boundaries.

If I were you I would do it the way Jesper suggests, but I would
replace it with another term, say num_type.  Then put at the top
something like ttn suggests :-

#define  num_type int;
/* #define num_type double; */

(Or use typedef.)

This allows you to change things easily.  I've often done this in the
past to allow me to experiment with using doubles and floats.

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

end of thread, other threads:[~2003-09-01 13:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Xns93E7BCA3B6E3Fljxilsjfdiaujiosdfua@130.133.1.4>
2003-08-31  1:43 ` Replace whole words? Johan Bockgård
2003-09-01 13:19   ` Rob Thorpe
2003-08-31  1:50 ` Jesper Harder
2003-08-31  9:19 ` Thien-Thi Nguyen
     [not found] <E19tLWW-0000ph-Tp@monty-python.gnu.org>
2003-08-31 16:28 ` Joe Corneli

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