5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Emacsで1行複製

Last updated at Posted at 2013-03-04

Emacsを使っている時「この行を複製してちょっと改変」ということが多いので、こんな関数を作って使っている。

emacs.d/init.el
(defun duplicate-line (&optional p)
  "カーソルのある行を二重化します。
前置引数や引数があると、カーソル行以下n行を二重化します。"
  (interactive "p")
  (let ((orgp (point))(kill-whole-line t))
    (beginning-of-line)
    (if p
        (kill-line p) (kill-line))
    (yank)
    (yank)
    (goto-char orgp)))

(if window-system
    (global-set-key "\C-z" 'duplicate-line))

C-zで当該行をすぐ下に複製する。C-u C-zで4行複製する。
killバッファを潰してしまうのがちょっと難点である。windowsシステムでない時にC-zを押してsuspendさせるのはご愛嬌ということで。

5
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?