---
title: "emacs duplicate line"
author: "jedy"
date: "2006-02-19T07:44:00Z"
tags: []
slug: "emacs-duplicate-line"
draft: false
lastmod: "2006-02-19T07:44:00Z"
id: 304745
url: "https://jedy.iteye.com/blog/304745"
---

找了半天都没有找到复制一行的函数，没办法，只有自己写一个了。  
前些日子看的Lisp又都忘记了，写了这么个简单的东西都要看半天  
书。

```

(defun wh-duplicate-line ()
"Duplicate current line"
(interactive)
(let (start end)
  (save-excursion
 (move-beginning-of-line 1)
 (setq start (point))
 (move-end-of-line 1)
 (setq end (point))
 (newline)
 (insert-buffer-substring (current-buffer) start end)
 )
  )
(next-line 1)
)

(global-set-key (kbd "C-<return>") 'wh-duplicate-line)
```