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

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

Re: copy-word-from-line-above


From: Nikos Apostolakis
Subject: Re: copy-word-from-line-above
Date: Thu, 18 Jan 2007 19:36:26 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux)

Marc Tfardy <m-t-o@web.de> writes:

> HS wrote:
>> Hello!
>> Does anyone have a function that copies words from the line above, word
>> after word ?
>> I'd like this function so I could have something like this:
>>
>> double int xxx;
>>
>> Then I'd just put the cursor under that line, press <f2> (for example)
>> twice and would be in this state:
>>
>> double int xxx;
>> double int
>>
>> then I would continue adding the new variable.
>
> Not exactly what you looking for, but a simple macro do a similar job:
>

[...]

>
> This macro duplcates whole previous line. The point is on the
> end of the line. Now you can press (one or more times ) M-DEL
> and continue editing.

Here is a slightly better keyboard macro to record.  Go underneath
the line that you want to incrementally copy and do (spaces inseted
for readability)

C-x( C-e C-p C-M-s \< C-<space> C-M-s C-s M-w C-n C-y C-x)

IOW, go to the end of line, go to the line above, search for
beginning of word, set the mark, find the next beginning of word,
copy region, go to next line, yank.  Now hit C-xe to copy the word
above and (in emacs22 at least) keep hiting "e" to repeat as many
times as desired.  Haven't thoroughly checked it but it should work.

Shouldn't be hard to write this in lisp, either.

HTH
Nikos





reply via email to

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