17
16

More than 5 years have passed since last update.

現在行をそのまま上下に連続移動させる

Last updated at Posted at 2013-06-19

行を保ったまま上下に連続して移動できます。
行の順番を変えたいとき、前後の行を入れ替えたいときに非常に役に立ちます。

Key Direction
Alt+Shift+p 現在行を上へ
Alt+Shift+n 現在行を下へ

設定ファイルに以下を貼り付け。

.emacs.d/init.el
(defun move-line-down ()
  (interactive)
  (let ((col (current-column)))
    (unless (eq col 0)
      (move-to-column 0))
    (save-excursion
      (forward-line)
      (transpose-lines 1))
    (forward-line)))

(defun move-line-up ()
  (interactive)
  (let ((col (current-column)))
    (unless (eq col 0)
      (move-to-column 0))
    (save-excursion
      (forward-line)
      (transpose-lines -1))
    (forward-line -1)))

(global-set-key (kbd "M-P") 'move-line-up)
(global-set-key (kbd "M-N") 'move-line-down)

キーバインドはご自由に

参照: What the .emacs.d!?

17
16
2

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
17
16