* Yet another rookie question replace-regexp
@ 2006-03-07 15:09 billy
2006-03-07 16:07 ` Albert Reiner
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: billy @ 2006-03-07 15:09 UTC (permalink / raw)
I know how to use this on a whole file. but how can I make this work on
a region?
If I want to comment out a 50 lines of 10k I don't want to comment out
each line one at a time. I would like to do C-space bar them move
below the last line I want to effect, the do the replace-regexp. But
his does the whole file. I pass it ^ / #
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Yet another rookie question replace-regexp
2006-03-07 15:09 Yet another rookie question replace-regexp billy
@ 2006-03-07 16:07 ` Albert Reiner
2006-03-07 16:33 ` Hans-Christoph Wirth
2006-03-08 10:40 ` Michael Cadilhac
2 siblings, 0 replies; 6+ messages in thread
From: Albert Reiner @ 2006-03-07 16:07 UTC (permalink / raw)
["billy" <bp1497@att.com>, 7 Mar 2006 07:09:46 -0800]:
> I know how to use this on a whole file. but how can I make this work on
> a region?
You can always narrow to the region (C-x n n), do the replacement, and
then widen again (C-x n w).
Albert.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Yet another rookie question replace-regexp
2006-03-07 15:09 Yet another rookie question replace-regexp billy
2006-03-07 16:07 ` Albert Reiner
@ 2006-03-07 16:33 ` Hans-Christoph Wirth
2006-03-08 22:56 ` kgold
2006-03-08 10:40 ` Michael Cadilhac
2 siblings, 1 reply; 6+ messages in thread
From: Hans-Christoph Wirth @ 2006-03-07 16:33 UTC (permalink / raw)
billy <bp1497@att.com> wrote:
> If I want to comment out a 50 lines of 10k I don't want to comment out
> each line one at a time. I would like to do C-space bar them move
> below the last line I want to effect, the do
M-x comment-region
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Yet another rookie question replace-regexp
2006-03-07 16:33 ` Hans-Christoph Wirth
@ 2006-03-08 22:56 ` kgold
2006-03-11 17:10 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: kgold @ 2006-03-08 22:56 UTC (permalink / raw)
The general problem with M-x comment-region is that it doesn't handle
lines with comments. You get something like:
/* int i; /* comment */*/
Personally, I like #if 0 for commenting out large chunks, using this
function.
; function to comment a region using #if 0
(defun if0-region (p1 p2)
(interactive "r")
(let* ()
(goto-char p1)
(beginning-of-line)
(insert "#if 0\n")
(goto-char (+ p2 +9))
(beginning-of-line)
(insert "#endif\n")))
Hans-Christoph Wirth wrote:
> billy <bp1497@att.com> wrote:
>
>
>> If I want to comment out a 50 lines of 10k I don't want to comment out
>> each line one at a time. I would like to do C-space bar them move
>> below the last line I want to effect, the do
>
>
> M-x comment-region
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Yet another rookie question replace-regexp
2006-03-07 15:09 Yet another rookie question replace-regexp billy
2006-03-07 16:07 ` Albert Reiner
2006-03-07 16:33 ` Hans-Christoph Wirth
@ 2006-03-08 10:40 ` Michael Cadilhac
2 siblings, 0 replies; 6+ messages in thread
From: Michael Cadilhac @ 2006-03-08 10:40 UTC (permalink / raw)
Cc: help-gnu-emacs
"billy" <bp1497@att.com> writes:
> I know how to use this on a whole file. but how can I make this work on
> a region?
> If I want to comment out a 50 lines of 10k I don't want to comment out
> each line one at a time. I would like to do C-space bar them move
> below the last line I want to effect, the do the replace-regexp. But
> his does the whole file. I pass it ^ / #
,----[ C-h f replace-string RET ]
| replace-string is an interactive compiled Lisp function in `replace.el'.
| (replace-string from-string to-string &optional delimited start end)
|
| Replace occurrences of from-string with to-string.
| [...]
| In Transient Mark mode, if the mark is active, operate on the contents
| of the region. Otherwise, operate from point to the end of the buffer.
| [...]
|
| [back]
`----
In other words, you just have to activate the Transient Mark while
selecting your region.
In Emacs CVS it's done temporarily by hitting C-space twice.
--
Michael Cadilhac, a.k.a. Micha [mika] |
Epita/LRDE promo 2007 | )\._.,--....,'``.
123 av. de Fontainebleau | 08.70.65.13.14 | /. _.. \ _\ (` ._,.
94270 Le Kremlin Bicetre | 06.23.20.31.30 | '._.-(,_..'--(,_...`-..'
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-03-11 17:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-07 15:09 Yet another rookie question replace-regexp billy
2006-03-07 16:07 ` Albert Reiner
2006-03-07 16:33 ` Hans-Christoph Wirth
2006-03-08 22:56 ` kgold
2006-03-11 17:10 ` Stefan Monnier
2006-03-08 10:40 ` Michael Cadilhac
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.