728x90
반응형
Emacs에서는 기본적으로 다른 에디터에서 많이 사용되는 기능 중에 하나인 한 줄을 위아래로 옮길 수 없다.
이를 사용하기 위해서 init.el에 다음을 추가하면 된다.
(defun move-line (n)
"Move the current line up or down by N lines."
(interactive "p")
(setq col (current-column))
(beginning-of-line) (setq start (point))
(end-of-line) (forward-char) (setq end (point))
(let ((line-text (delete-and-extract-region start end)))
(forward-line n)
(insert line-text)
;; restore point to original column in moved line
(forward-line -1)
(forward-char col)))
(defun move-line-up (n)
"Move the current line up by N lines."
(interactive "p")
(move-line (if (null n) -1 (- n))))
(defun move-line-down (n)
"Move the current line down by N lines."
(interactive "p")
(move-line (if (null n) 1 n)))
(global-set-key (kbd "M-<up>") 'move-line-up)
(global-set-key (kbd "M-<down>") 'move-line-down)
참고 문헌
반응형
'Emacs' 카테고리의 다른 글
[Emacs] macOS Catalina 업그레이드 문제 (0) | 2020.01.25 |
---|---|
[Emacs] helm 방향키로 디렉토리 탐색이 안되는 경우 해결 (0) | 2020.01.25 |
[Emacs] Window Move (0) | 2020.01.25 |
[Emacs] Python 개발 환경 구축 (0) | 2020.01.25 |
[Emacs] org-mode 한글 테이블 (0) | 2020.01.25 |