Skip to content

Instantly share code, notes, and snippets.

@georgi
Created June 2, 2011 19:49
Show Gist options
  • Save georgi/1005148 to your computer and use it in GitHub Desktop.
Save georgi/1005148 to your computer and use it in GitHub Desktop.
(defun copy-line (n)
(let ((column (current-column))
(line (buffer-substring (line-beginning-position) (+ (line-end-position) 1))))
(beginning-of-line)
(forward-line n)
(insert line)
(forward-line -1)
(forward-char column)))
(defun copy-line-up ()
"Copy the current line up"
(interactive)
(copy-line 0))
(defun copy-line-down ()
"Copy the current line down"
(interactive)
(copy-line 1))
(defun move-line (n)
(let ((column (current-column))
(line (delete-and-extract-region (line-beginning-position) (+ (line-end-position) 1))))
(forward-line n)
(insert line)
(forward-line -1)
(forward-char column)))
(defun move-line-up ()
"Move the current line up"
(interactive)
(move-line -1))
(defun move-line-down ()
"Move the current line down"
(interactive)
(move-line 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment