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: rgb
Subject: Re: copy-word-from-line-above
Date: 19 Jan 2007 12:25:17 -0800
User-agent: G2/1.0

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
>

I use this because its a bit more flexable.
It allows you to copy exactly the parts you want even if not full
words.

(global-set-key [?\C-\M-z] 'insert-prior-line-char)

(defun insert-prior-line-char ()
  "Insert the same character as in the prior line. Space if none."
  (interactive)
  (let* ((cur (current-column))
         (char (save-excursion
                 (if (or (not (eq 0 (forward-line -1)))
                         (not (eq cur (move-to-column cur)) ))
                     32
                   (char-after)))))
    (insert char)))



reply via email to

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