all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Column replace
@ 2007-06-12  8:48 Enchanter
  2007-06-12  9:55 ` Juanma Barranquero
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Enchanter @ 2007-06-12  8:48 UTC (permalink / raw
  To: help-gnu-emacs

How to replace this?

From:

text ts
text ts
text ts
text ts
text ts
text ts
text ts

to:
text ts0
text ts1
text ts2
text ts3
text ts4
text ts5
text ts6

Thanks

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

* Re: Column replace
  2007-06-12  8:48 Column replace Enchanter
@ 2007-06-12  9:55 ` Juanma Barranquero
  2007-06-12 10:39 ` Peter Dyballa
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Juanma Barranquero @ 2007-06-12  9:55 UTC (permalink / raw
  To: Enchanter; +Cc: help-gnu-emacs

On 6/12/07, Enchanter <ensoul.magazine@gmail.com> wrote:
> How to replace this?
>
> From:
>
> text ts
> text ts
> text ts
> text ts
> text ts
> text ts
> text ts
>
> to:
> text ts0
> text ts1
> text ts2
> text ts3
> text ts4
> text ts5
> text ts6

Put the cursor after the first line, i.e.:

text ts[]

and type F3 F3 down F4 Ctrl-5 F4

Afterwards, I'd recommend reading the docs for kmacro.

             Juanma

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

* Re: Column replace
  2007-06-12  8:48 Column replace Enchanter
  2007-06-12  9:55 ` Juanma Barranquero
@ 2007-06-12 10:39 ` Peter Dyballa
  2007-06-12 10:54   ` Juanma Barranquero
  2007-06-12 17:37 ` deprecated
  2007-06-12 21:38 ` Colin S. Miller
  3 siblings, 1 reply; 16+ messages in thread
From: Peter Dyballa @ 2007-06-12 10:39 UTC (permalink / raw
  To: Enchanter; +Cc: help-gnu-emacs


Am 12.06.2007 um 10:48 schrieb Enchanter:

> How to replace this?


M-x replace-regexp RET ^.*$ RET \&\# RET

--
Mit friedvollen Grüßen

   Pete

Without vi there is only GNU Emacs

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

* Re: Column replace
  2007-06-12 10:39 ` Peter Dyballa
@ 2007-06-12 10:54   ` Juanma Barranquero
  2007-06-12 11:11     ` Peter Dyballa
  0 siblings, 1 reply; 16+ messages in thread
From: Juanma Barranquero @ 2007-06-12 10:54 UTC (permalink / raw
  To: Peter Dyballa; +Cc: help-gnu-emacs, Enchanter

On 6/12/07, Peter Dyballa <Peter_Dyballa@web.de> wrote:

> M-x replace-regexp RET ^.*$ RET \&\# RET

Very cool.

But what if the result shoud be

text ts100
text ts101
...

?

             Juanma

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

* Re: Column replace
  2007-06-12 10:54   ` Juanma Barranquero
@ 2007-06-12 11:11     ` Peter Dyballa
  2007-06-12 11:16       ` Juanma Barranquero
       [not found]       ` <mailman.1999.1181646983.32220.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 16+ messages in thread
From: Peter Dyballa @ 2007-06-12 11:11 UTC (permalink / raw
  To: Juanma Barranquero; +Cc: help-gnu-emacs, Enchanter


Am 12.06.2007 um 12:54 schrieb Juanma Barranquero:

> But what if the result shoud be
>
> text ts100
> text ts101
> ...

M-x replace-regexp RET ^.*$ RET \&\,(+ 100 \#) RET

\# stands for replace-count. The TO expression can contain in GNU  
Emacs 22 a function, with formats or such.

--
Greetings

   Pete     === -Q
              ==<__/% >>
_____________(_)____@_____________________________

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

* Re: Column replace
  2007-06-12 11:11     ` Peter Dyballa
@ 2007-06-12 11:16       ` Juanma Barranquero
       [not found]       ` <mailman.1999.1181646983.32220.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 16+ messages in thread
From: Juanma Barranquero @ 2007-06-12 11:16 UTC (permalink / raw
  To: Peter Dyballa; +Cc: help-gnu-emacs, Enchanter

On 6/12/07, Peter Dyballa <Peter_Dyballa@web.de> wrote:

> M-x replace-regexp RET ^.*$ RET \&\,(+ 100 \#) RET

Nice, and obviously quite powerful.

For simple cases like the one the OP asked for, I'd suggest kmacro though.

             Juanma

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

* Re: Column replace
       [not found]       ` <mailman.1999.1181646983.32220.help-gnu-emacs@gnu.org>
@ 2007-06-12 12:49         ` weber
  2007-06-12 13:43           ` Juanma Barranquero
       [not found]           ` <mailman.2008.1181655831.32220.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 16+ messages in thread
From: weber @ 2007-06-12 12:49 UTC (permalink / raw
  To: help-gnu-emacs

On 12 jun, 08:16, "Juanma Barranquero" <lek...@gmail.com> wrote:
> On 6/12/07, Peter Dyballa <Peter_Dyba...@web.de> wrote:
>
> > M-x replace-regexp RET ^.*$ RET \&\,(+ 100 \#) RET
>
> Nice, and obviously quite powerful.
>
> For simple cases like the one the OP asked for, I'd suggest kmacro though.
>
>              Juanma

I didn't get the macro solution... I guess you're assuming some
special shortcuts?
Can you please tell me which commands are  you running on each of
them ?
Thanks
weber

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

* Re: Column replace
  2007-06-12 12:49         ` weber
@ 2007-06-12 13:43           ` Juanma Barranquero
       [not found]           ` <mailman.2008.1181655831.32220.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 16+ messages in thread
From: Juanma Barranquero @ 2007-06-12 13:43 UTC (permalink / raw
  To: weber; +Cc: help-gnu-emacs

On 6/12/07, weber <hugows@gmail.com> wrote:

> I didn't get the macro solution... I guess you're assuming some
> special shortcuts?
> Can you please tell me which commands are  you running on each of
> them ?

No special shortcuts. In Emacs 22.1, F3 is
`kmacro-start-macro-or-insert-counter' and F4 is
`kmacro-end-or-call-macro'. See the file kmacro.el in the Emacs lisp
source directory, and the "Keyboard Macros" node in the info docs.

             Juanma

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

* Re: Column replace
       [not found]           ` <mailman.2008.1181655831.32220.help-gnu-emacs@gnu.org>
@ 2007-06-12 14:14             ` weber
  2007-06-12 14:59               ` Juanma Barranquero
       [not found]               ` <mailman.2022.1181660385.32220.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 16+ messages in thread
From: weber @ 2007-06-12 14:14 UTC (permalink / raw
  To: help-gnu-emacs

On 12 jun, 10:43, "Juanma Barranquero" <lek...@gmail.com> wrote:
> On 6/12/07, weber <hug...@gmail.com> wrote:
>
> > I didn't get the macro solution... I guess you're assuming some
> > special shortcuts?
> > Can you please tell me which commands are  you running on each of
> > them ?
>
> No special shortcuts. In Emacs 22.1, F3 is
> `kmacro-start-macro-or-insert-counter' and F4 is
> `kmacro-end-or-call-macro'. See the file kmacro.el in the Emacs lisp
> source directory, and the "Keyboard Macros" node in the info docs.
>
>              Juanma

That is very cool!
Is there an easy way to start in 100, for example? What about
decreasing? Or counting at 2 increments?
TIA
weber

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

* Re: Column replace
  2007-06-12 14:14             ` weber
@ 2007-06-12 14:59               ` Juanma Barranquero
       [not found]               ` <mailman.2022.1181660385.32220.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 16+ messages in thread
From: Juanma Barranquero @ 2007-06-12 14:59 UTC (permalink / raw
  To: weber; +Cc: help-gnu-emacs

On 6/12/07, weber <hugows@gmail.com> wrote:

> Is there an easy way to start in 100, for example?

C-100 F3 ...

> What about decreasing?

C-100 F3 C-- C-5 F3 ...

> Or counting at 2 increments?

C-100 F3 C-2 F3 ...

I'd really recommend reading the docs.

             Juanma

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

* Re: Column replace
       [not found]               ` <mailman.2022.1181660385.32220.help-gnu-emacs@gnu.org>
@ 2007-06-12 16:11                 ` weber
  2007-06-12 17:00                   ` weber
  2007-06-12 18:02                   ` Juanma Barranquero
  0 siblings, 2 replies; 16+ messages in thread
From: weber @ 2007-06-12 16:11 UTC (permalink / raw
  To: help-gnu-emacs

On 12 jun, 11:59, "Juanma Barranquero" <lek...@gmail.com> wrote:
> On 6/12/07, weber <hug...@gmail.com> wrote:
>
> > Is there an easy way to start in 100, for example?
>
> C-100 F3 ...
>
> > What about decreasing?
>
> C-100 F3 C-- C-5 F3 ...
>
> > Or counting at 2 increments?
>
> C-100 F3 C-2 F3 ...
>
> I'd really recommend reading the docs.
>
>              Juanma

Ok, i read the docs.. but there is still one thing i'm not able to do:
siga(0) <= siga(0);
siga(1) <= siga(1);
siga(2) <= siga(2);
...

Is there a way to insert the current counter value without
incrementing it?
(I know I could just yank and paste the value inside the macro, but
that would be less elegant)

TIA,
weber

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

* Re: Column replace
  2007-06-12 16:11                 ` weber
@ 2007-06-12 17:00                   ` weber
  2007-06-12 18:02                   ` Juanma Barranquero
  1 sibling, 0 replies; 16+ messages in thread
From: weber @ 2007-06-12 17:00 UTC (permalink / raw
  To: help-gnu-emacs

On 12 jun, 13:11, weber <hug...@gmail.com> wrote:
> On 12 jun, 11:59, "Juanma Barranquero" <lek...@gmail.com> wrote:
>
>
>
> > On 6/12/07, weber <hug...@gmail.com> wrote:
>
> > > Is there an easy way to start in 100, for example?
>
> > C-100 F3 ...
>
> > > What about decreasing?
>
> > C-100 F3 C-- C-5 F3 ...
>
> > > Or counting at 2 increments?
>
> > C-100 F3 C-2 F3 ...
>
> > I'd really recommend reading the docs.
>
> >              Juanma
>
> Ok, i read the docs.. but there is still one thing i'm not able to do:
> siga(0) <= siga(0);
> siga(1) <= siga(1);
> siga(2) <= siga(2);
> ...
>
> Is there a way to insert the current counter value without
> incrementing it?
> (I know I could just yank and paste the value inside the macro, but
> that would be less elegant)
>
> TIA,
> weber

Errata: I meant something like
signalA(0) <= signalB(0);
signalA(1) <= signalB(1);
signalA(2) <= signalB(2);
Not siga(0) <= siga(0) :)

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

* Re: Column replace
  2007-06-12  8:48 Column replace Enchanter
  2007-06-12  9:55 ` Juanma Barranquero
  2007-06-12 10:39 ` Peter Dyballa
@ 2007-06-12 17:37 ` deprecated
  2007-06-13 21:01   ` Peter Lee
  2007-06-12 21:38 ` Colin S. Miller
  3 siblings, 1 reply; 16+ messages in thread
From: deprecated @ 2007-06-12 17:37 UTC (permalink / raw
  To: help-gnu-emacs

Just in case anyone was worried that emacs has only two solutions to
this problem, there is a third way ..... :)

On Jun 12, 3:48 am, Enchanter <ensoul.magaz...@gmail.com> wrote:
> How to replace this?
>
> From:
>
> text ts
> text ts
> text ts
> text ts
> text ts
> text ts
> text ts
>
> to:
> text ts0
> text ts1
> text ts2
> text ts3
> text ts4
> text ts5
> text ts6
>

Turn on CUA mode (M-x cua-mode)

Move to the end of the first line and type C-return (cua-set-rectangle-
mark).

Now move to the end of the last line and type M-n (cua-sequence-
rectangle). You will be prompted for a starting value, an increment
and a format string.

[Only tested in emacs 22]

Cheers

Will

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

* Re: Column replace
  2007-06-12 16:11                 ` weber
  2007-06-12 17:00                   ` weber
@ 2007-06-12 18:02                   ` Juanma Barranquero
  1 sibling, 0 replies; 16+ messages in thread
From: Juanma Barranquero @ 2007-06-12 18:02 UTC (permalink / raw
  To: weber; +Cc: help-gnu-emacs

On 6/12/07, weber <hugows@gmail.com> wrote:

> Ok, i read the docs.. but there is still one thing i'm not able to do:
> siga(0) <= siga(0);
> siga(1) <= siga(1);
> siga(2) <= siga(2);
> ...
>
> Is there a way to insert the current counter value without
> incrementing it?

F3 "signalA(" F3 ") <= signalB(" C-u F3 ")" RET F4
F4 F4...

I'd *really* recommend reading the docs. That's clearly described in
the docstring for `kmacro-start-macro-or-insert-counter', which you
can access with C-h k f3.



             Juanma

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

* Re: Column replace
  2007-06-12  8:48 Column replace Enchanter
                   ` (2 preceding siblings ...)
  2007-06-12 17:37 ` deprecated
@ 2007-06-12 21:38 ` Colin S. Miller
  3 siblings, 0 replies; 16+ messages in thread
From: Colin S. Miller @ 2007-06-12 21:38 UTC (permalink / raw
  To: help-gnu-emacs

Enchanter wrote:
> How to replace this?
> 
> From:
> 
> text ts
> text ts
> text ts
> text ts
> text ts
> text ts
> text ts
> 
> to:
> text ts0
> text ts1
> text ts2
> text ts3
> text ts4
> text ts5
> text ts6
> 
> Thanks
> 
Enchanter,

there's more than one way to skin the cat,
this is how you do it using registers.

Key binding are for XEmacs;
YMMV on Emacs.

Move to the first line and enter

C-u 10 C-x r n a
C-x ( END C-x r i a C-x r + a HOME DOWN C-x )
C-u 5 C-x e


The bindings are
C-x r n    number-to-register
C-x r i    insert-register
C-x r +    increment-register

increment-register defaults to 1; it can take
an integer prefix for decrementing or incrementing
by other values.



HTH,
Colin S. Miller

-- 
Replace the obvious in my email address with the first three letters of the hostname to reply.

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

* Re: Column replace
  2007-06-12 17:37 ` deprecated
@ 2007-06-13 21:01   ` Peter Lee
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Lee @ 2007-06-13 21:01 UTC (permalink / raw
  To: help-gnu-emacs

>>>> deprecated  writes:

    > Just in case anyone was worried that emacs has only two solutions to
    > this problem, there is a third way ..... :)

Don't know where I got this, but this is what I use:

(defun another-line (num-lines)
  "Copies line, preserving cursor column, and increments any numbers found.
Copies a block of optional NUM-LINES lines.  If no optional argument is given,
then only one line is copied."
  (interactive "p")
  (if (not num-lines) (setq num-lines 0) (setq num-lines (1- num-lines)))
  (let* ((col (current-column))
         (bol (save-excursion (forward-line (- num-lines)) (beginning-of-line) (point)))
         (eol (progn (end-of-line) (point)))
         (line (buffer-substring bol eol)))
    (goto-char bol)
    (while (re-search-forward "[0-9]+" eol 1)
      (let ((num (string-to-number (buffer-substring
                                 (match-beginning 0) (match-end 0)))))
        (replace-match (int-to-string (1+ num))))
      (setq eol (save-excursion (goto-char eol) (end-of-line) (point))))
    (goto-char bol)
    (insert line "\n")
    (move-to-column col)))
(global-set-key (kbd "M-O") 'another-line)

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

end of thread, other threads:[~2007-06-13 21:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-12  8:48 Column replace Enchanter
2007-06-12  9:55 ` Juanma Barranquero
2007-06-12 10:39 ` Peter Dyballa
2007-06-12 10:54   ` Juanma Barranquero
2007-06-12 11:11     ` Peter Dyballa
2007-06-12 11:16       ` Juanma Barranquero
     [not found]       ` <mailman.1999.1181646983.32220.help-gnu-emacs@gnu.org>
2007-06-12 12:49         ` weber
2007-06-12 13:43           ` Juanma Barranquero
     [not found]           ` <mailman.2008.1181655831.32220.help-gnu-emacs@gnu.org>
2007-06-12 14:14             ` weber
2007-06-12 14:59               ` Juanma Barranquero
     [not found]               ` <mailman.2022.1181660385.32220.help-gnu-emacs@gnu.org>
2007-06-12 16:11                 ` weber
2007-06-12 17:00                   ` weber
2007-06-12 18:02                   ` Juanma Barranquero
2007-06-12 17:37 ` deprecated
2007-06-13 21:01   ` Peter Lee
2007-06-12 21:38 ` Colin S. Miller

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.