LoginSignup
43
45

More than 5 years have passed since last update.

multiple-cursor.elの設定を調整してみた

Last updated at Posted at 2013-06-29

SublimeText2の複数カーソルに相当するmultiple-cursors.elはとても便利なのですが、キーバインドを自分で考えて設定しないといけないのが敷居を高くしています。

そこで基本的な操作に困らないようにキーバインドを設定してみました。multiple-cursors.elのキーバインドを少しだけ改善 - 備忘録のsmartrepを使うアイデアをを参考にしています。

インストール

どちらもpackage.elからインストール出来ます。

M-x package-install multiple-cursors
M-x package-install smartrep

.emacs.d/init.el

.emacs.d/init.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)))

よくあるパターン


  • キーワード選択→C-t連打でキーワードを選択
  • C-tを押した後にsを押すとキーワードをスキップ, uで一つ前に戻る、*で全て選択、dでバッファ内をいい感じで全選択
  • 範囲を選択してC-M-cで全ての行にカーソルを作成
  • 範囲を選択してC-M-rで対話的にキーワードを入力してカーソルを作成

リンク

43
45
4

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
43
45