unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Repeat count for yanking
@ 2011-07-05  9:35 C K Kashyap
  2011-07-05 11:13 ` Peter Münster
  2011-07-05 11:46 ` Richard Riley
  0 siblings, 2 replies; 11+ messages in thread
From: C K Kashyap @ 2011-07-05  9:35 UTC (permalink / raw)
  To: help-gnu-emacs

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

Hi,
How can I provide a repeat count to yank -

I'd like to kill a line and then paste it 100 times - how can I achieve
this?

Regards,
Kashyap

[-- Attachment #2: Type: text/html, Size: 218 bytes --]

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

* Re: Repeat count for yanking
  2011-07-05  9:35 Repeat count for yanking C K Kashyap
@ 2011-07-05 11:13 ` Peter Münster
  2011-07-21 21:39   ` Steinar Bang
  2011-07-05 11:46 ` Richard Riley
  1 sibling, 1 reply; 11+ messages in thread
From: Peter Münster @ 2011-07-05 11:13 UTC (permalink / raw)
  To: help-gnu-emacs

On Tue, Jul 05 2011, C K Kashyap wrote:

> How can I provide a repeat count to yank - 
>
> I'd like to kill a line and then paste it 100 times - how can I achieve this?

You can put the yank into a keyboard macro and use the prefix argument
to call the macro 100 times.

-- 
           Peter




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

* Re: Repeat count for yanking
  2011-07-05  9:35 Repeat count for yanking C K Kashyap
  2011-07-05 11:13 ` Peter Münster
@ 2011-07-05 11:46 ` Richard Riley
  2011-07-05 12:38   ` Perry Smith
  1 sibling, 1 reply; 11+ messages in thread
From: Richard Riley @ 2011-07-05 11:46 UTC (permalink / raw)
  To: help-gnu-emacs

C K Kashyap <ckkashyap@gmail.com> writes:

> Hi,
> How can I provide a repeat count to yank - 
>
> I'd like to kill a line and then paste it 100 times - how can I
> achieve this?
>
> Regards,
> Kashyap
>
>

I was looking at this recently.

http://stackoverflow.com/questions/71985/emacs-equivalent-of-vims-yy10p

ulp!




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

* Re: Repeat count for yanking
  2011-07-05 11:46 ` Richard Riley
@ 2011-07-05 12:38   ` Perry Smith
  2011-07-05 12:44     ` Thierry Volpiatto
  0 siblings, 1 reply; 11+ messages in thread
From: Perry Smith @ 2011-07-05 12:38 UTC (permalink / raw)
  To: help-gnu-emacs

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


On Jul 5, 2011, at 6:46 AM, Richard Riley wrote:

> C K Kashyap <ckkashyap@gmail.com> writes:
> 
>> Hi,
>> How can I provide a repeat count to yank - 
>> 
>> I'd like to kill a line and then paste it 100 times - how can I
>> achieve this?
>> 
>> Regards,
>> Kashyap
>> 
>> 
> 
> I was looking at this recently.
> 
> http://stackoverflow.com/questions/71985/emacs-equivalent-of-vims-yy10p

If it is a one time thing, I usually do it in powers of two.  e.g. yank it maybe 4 times, then kill that and yank 4 times.  Now you have 16 lines.  ...

Remember that M-< sets the mark.  So if you narrow the region you can paste a lot of lines rather quickly.

If I was going to do this moderately frequently, I would toy around and learn how to do it via M-; (eval).  Seems like one line of lisp could do this.



[-- Attachment #2: Type: text/html, Size: 1777 bytes --]

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

* Re: Repeat count for yanking
  2011-07-05 12:38   ` Perry Smith
@ 2011-07-05 12:44     ` Thierry Volpiatto
  2011-07-05 13:42       ` Teemu Likonen
                         ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Thierry Volpiatto @ 2011-07-05 12:44 UTC (permalink / raw)
  To: help-gnu-emacs

Perry Smith <pedzsan@gmail.com> writes:

> On Jul 5, 2011, at 6:46 AM, Richard Riley wrote:
>
>> C K Kashyap <ckkashyap@gmail.com> writes:
>> 
>>> Hi,
>>> How can I provide a repeat count to yank - 
>>> 
>>> I'd like to kill a line and then paste it 100 times - how can I
>>> achieve this?
>>> 
>>> Regards,
>>> Kashyap
>>> 
>>> 
>> 
>> I was looking at this recently.
>> 
>> http://stackoverflow.com/questions/71985/emacs-equivalent-of-vims-yy10p
>
> If it is a one time thing, I usually do it in powers of two.  e.g. yank it maybe 4 times, then kill that and yank 4 times.  Now you have 16 lines.  ...
>
> Remember that M-< sets the mark.  So if you narrow the region you can paste a lot of lines rather quickly.
>
> If I was going to do this moderately frequently, I would toy around and learn how to do it via M-; (eval).  Seems like one line of lisp could do this.
>
>
M-: (loop repeat 5 do (progn (yank) (insert "\n")))

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




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

* Re: Repeat count for yanking
  2011-07-05 12:44     ` Thierry Volpiatto
@ 2011-07-05 13:42       ` Teemu Likonen
  2011-07-06  6:26         ` C K Kashyap
  2011-07-05 17:09       ` Richard Riley
  2011-07-05 17:27       ` Andreas Röhler
  2 siblings, 1 reply; 11+ messages in thread
From: Teemu Likonen @ 2011-07-05 13:42 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: help-gnu-emacs

* 2011-07-05T14:44:43+02:00 * Thierry Volpiatto wrote:

> M-: (loop repeat 5 do (progn (yank) (insert "\n")))

Of course we include the newline in the last kill and do this:

    M-: (dotimes (i 4) (yank))

Or use this:

    (defun yank-repeatedly (n)
      (interactive "NHow many times: ")
      (dotimes (i n)
        (yank)))



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

* Re: Repeat count for yanking
  2011-07-05 12:44     ` Thierry Volpiatto
  2011-07-05 13:42       ` Teemu Likonen
@ 2011-07-05 17:09       ` Richard Riley
  2011-07-05 17:27       ` Andreas Röhler
  2 siblings, 0 replies; 11+ messages in thread
From: Richard Riley @ 2011-07-05 17:09 UTC (permalink / raw)
  To: help-gnu-emacs

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> Perry Smith <pedzsan@gmail.com> writes:
>
>> On Jul 5, 2011, at 6:46 AM, Richard Riley wrote:
>>
>>> C K Kashyap <ckkashyap@gmail.com> writes:
>>> 
>>>> Hi,
>>>> How can I provide a repeat count to yank - 
>>>> 
>>>> I'd like to kill a line and then paste it 100 times - how can I
>>>> achieve this?
>>>> 
>>>> Regards,
>>>> Kashyap
>>>> 
>>>> 
>>> 
>>> I was looking at this recently.
>>> 
>>> http://stackoverflow.com/questions/71985/emacs-equivalent-of-vims-yy10p
>>
>> If it is a one time thing, I usually do it in powers of two.  e.g. yank it maybe 4 times, then kill that and yank 4 times.  Now you have 16 lines.  ...
>>
>> Remember that M-< sets the mark.  So if you narrow the region you can paste a lot of lines rather quickly.
>>
>> If I was going to do this moderately frequently, I would toy around and learn how to do it via M-; (eval).  Seems like one line of lisp could do this.
>>
>>
> M-: (loop repeat 5 do (progn (yank) (insert "\n")))

Or press C-y a few times ;)




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

* Re: Repeat count for yanking
  2011-07-05 12:44     ` Thierry Volpiatto
  2011-07-05 13:42       ` Teemu Likonen
  2011-07-05 17:09       ` Richard Riley
@ 2011-07-05 17:27       ` Andreas Röhler
  2 siblings, 0 replies; 11+ messages in thread
From: Andreas Röhler @ 2011-07-05 17:27 UTC (permalink / raw)
  To: help-gnu-emacs

Am 05.07.2011 14:44, schrieb Thierry Volpiatto:
> Perry Smith<pedzsan@gmail.com>  writes:
>
>> On Jul 5, 2011, at 6:46 AM, Richard Riley wrote:
>>
>>> C K Kashyap<ckkashyap@gmail.com>  writes:
>>>
>>>> Hi,
>>>> How can I provide a repeat count to yank -
>>>>
>>>> I'd like to kill a line and then paste it 100 times - how can I
>>>> achieve this?
>>>>
>>>> Regards,
>>>> Kashyap
>>>>
>>>>
>>>
>>> I was looking at this recently.
>>>
>>> http://stackoverflow.com/questions/71985/emacs-equivalent-of-vims-yy10p
>>
>> If it is a one time thing, I usually do it in powers of two.  e.g. yank it maybe 4 times, then kill that and yank 4 times.  Now you have 16 lines.  ...
>>
>> Remember that M-<  sets the mark.  So if you narrow the region you can paste a lot of lines rather quickly.
>>
>> If I was going to do this moderately frequently, I would toy around and learn how to do it via M-; (eval).  Seems like one line of lisp could do this.
>>
>>
> M-: (loop repeat 5 do (progn (yank) (insert "\n")))
>

nice, and what about that:

(defun yank-repeat (&optional arg)
   (interactive "p")
   (dotimes (i arg)
     (insert (car kill-ring))))






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

* Re: Repeat count for yanking
  2011-07-05 13:42       ` Teemu Likonen
@ 2011-07-06  6:26         ` C K Kashyap
  0 siblings, 0 replies; 11+ messages in thread
From: C K Kashyap @ 2011-07-06  6:26 UTC (permalink / raw)
  To: Teemu Likonen; +Cc: help-gnu-emacs, Thierry Volpiatto

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

>
> * 2011-07-05T14:44:43+02:00 * Thierry Volpiatto wrote:
>
> > M-: (loop repeat 5 do (progn (yank) (insert "\n")))
>
> Of course we include the newline in the last kill and do this:
>
>    M-: (dotimes (i 4) (yank))
>
> Or use this:
>
>    (defun yank-repeatedly (n)
>      (interactive "NHow many times: ")
>      (dotimes (i n)
>        (yank)))
>
>

Thanks for all the lisp solutions - this is exactly why I have picked up
emacs....

Regards,
Kashyap

[-- Attachment #2: Type: text/html, Size: 764 bytes --]

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

* Re: Repeat count for yanking
  2011-07-05 11:13 ` Peter Münster
@ 2011-07-21 21:39   ` Steinar Bang
  2011-07-21 21:41     ` Deniz Dogan
  0 siblings, 1 reply; 11+ messages in thread
From: Steinar Bang @ 2011-07-21 21:39 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> pmlists@free.fr (Peter Münster):

> You can put the yank into a keyboard macro and use the prefix argument
> to call the macro 100 times.

That would be `C-x ( C-y C-x )' to define the macro (and as a side
effect do a single yank), and then `C-u 99 C-x e' to execute the macro
99 times (to get the remaining 99 yanks).

It's less effort than you might think, since creating a keyboard macro
for a repetitive task, is something you do frequently once you've
discovered it (at least I did).





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

* Re: Repeat count for yanking
  2011-07-21 21:39   ` Steinar Bang
@ 2011-07-21 21:41     ` Deniz Dogan
  0 siblings, 0 replies; 11+ messages in thread
From: Deniz Dogan @ 2011-07-21 21:41 UTC (permalink / raw)
  To: help-gnu-emacs

On 2011-07-21 23:39, Steinar Bang wrote:
>>>>>> pmlists@free.fr (Peter Münster):
>
>> You can put the yank into a keyboard macro and use the prefix argument
>> to call the macro 100 times.
>
> That would be `C-x ( C-y C-x )' to define the macro (and as a side
> effect do a single yank), and then `C-u 99 C-x e' to execute the macro
> 99 times (to get the remaining 99 yanks).
>
> It's less effort than you might think, since creating a keyboard macro
> for a repetitive task, is something you do frequently once you've
> discovered it (at least I did).
>

I advised `yank' so that C-u 100 C-y yanks 100 times instead (which is 
much more useful in my opinion):

(defadvice yank (around damd-yank first nil activate)
   "If ARG is neither nil nor \\[universal-argument], yank ARG times.
Otherwise, use the original definition of `yank'."
   (if (or (not arg)
           (consp arg))
       ad-do-it
     (dotimes (i arg)
       (yank))))

Deniz



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

end of thread, other threads:[~2011-07-21 21:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-05  9:35 Repeat count for yanking C K Kashyap
2011-07-05 11:13 ` Peter Münster
2011-07-21 21:39   ` Steinar Bang
2011-07-21 21:41     ` Deniz Dogan
2011-07-05 11:46 ` Richard Riley
2011-07-05 12:38   ` Perry Smith
2011-07-05 12:44     ` Thierry Volpiatto
2011-07-05 13:42       ` Teemu Likonen
2011-07-06  6:26         ` C K Kashyap
2011-07-05 17:09       ` Richard Riley
2011-07-05 17:27       ` Andreas Röhler

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