help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: repeating input with different outputs


From: Eric Abrahamsen
Subject: Re: repeating input with different outputs
Date: Sat, 15 Oct 2011 12:46:20 +0800
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux)

On Fri, Oct 14 2011, ishi soichi wrote:

> I have a question about typing (or programming, or maybe a macro).
>
> Say, I'm writing a text (which can be in any mode, html-mode,
> cpp-mode, or whatever)
>
> I would like to input like 
>
> chapter 4.1
> chapter 4.2
> chapter 4.3
> ...
>
> chapter 4.46
>
> So, it is very tedious. I would rather set up a program or a command
> that can do this job instantaneously.
>
> Could Emacs do this?

Not that you really need another solution, but keyboard macros come with
a counter that can be (de|in)cremented. To learn keyboard macros, I once
made one that sang the "100 Bottles of Beer on the Wall" song all the
way down to zero. Well, didn't actually "sing" it (I didn't have that
package installed).

So:

C-x C-k C-c (kmacro-set-counter) '1'
<f3> (start the macro)
'chapter 4.' then hit <f3> again (this time it runs kmacro-insert-counter)
newline, then <f4> to finish recording, and you're done.

The counter automatically increments by one for each pass. If you want a
different value you can use C-x C-k C-a in the macro to add a (possibly
negative) value to the default value of 1.

Just one more option…

Eric

-- 
GNU Emacs 24.0.90.1 (i686-pc-linux-gnu, GTK+ Version 2.24.4)
 of 2011-10-06 on pellet




reply via email to

[Prev in Thread] Current Thread [Next in Thread]