LoginSignup
16
15

More than 5 years have passed since last update.

multiple-cursors.elとsmartrep.elでまとめて一気に編集

Posted at

コーディングしていると、複数の行に文字列を一括編集したり、
複数行の先頭、末尾に対して追加/削除したいケースが多々。
そんな時に、タイトルの2つを組合せて一気にやっつけることが出来る。

使い始めたばかりなので、特にキーバインドなど自分向け最適化の余地はありそうだが、
勢いで投稿してから、ゆっくりと馴染ませて行こうかと。

multiple-cursors.el

magnars / multiple-cursors.el

複数行編集のためのpackage。
リンク先のVideoを見ると一発丸分かり。

smartrep.el

連続操作を素敵にするsmartrep.el作った

連続操作を楽にするためのpackage。
複数行編集に限らず、使い方によっては色々と幸せになれるはず。

設定

主に↓を参考にさせていただいた。

multiple-cursors.elのキーバインドを少しだけ改善

のだったと思うが、かなりキーバインドが違う...な。

(require 'multiple-cursors)
(require 'smartrep)
(declare-function smartrep-define-key "smartrep")
(global-set-key (kbd "C-M-c") 'mc/edit-lines)
(global-set-key (kbd "C-M-r") 'mc/mark-all-in-region)
(global-unset-key "\C-t")
(smartrep-define-key global-map "C-t"
  '(("C-t"      . 'mc/mark-next-like-this)
    ("n"        . 'mc/mark-next-like-this)
    ("p"        . 'mc/mark-previous-like-this)
    ("m"        . 'mc/mark-more-like-this-extended)
    ("u"        . 'mc/unmark-next-like-this)
    ("U"        . 'mc/unmark-previous-like-this)
    ("s"        . 'mc/skip-to-next-like-this)
    ("S"        . 'mc/skip-to-previous-like-this)
    ("*"        . 'mc/mark-all-like-this)
    ("d"        . 'mc/mark-all-like-this-dwim)
    ("i"        . 'mc/insert-numbers)
    ("o"        . 'mc/sort-regions)
    ("O"        . 'mc/reverse-regions)))

今の所、
mc/edit-lines または mc/mark-all-in-regionmc/mark-(next|previous)-like-this
の組合せばかりしか使用していないが、それでも十分に重宝している。

使いこなすためにも、他も積極的に利用していきたい所。

16
15
0

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