Emacs で矩形選択と 連番挿入 - sakito - Emacsがすきすぎる - Emacsグループより
cua-modeをオンにしておくと連番の挿入が便利かも.あと,矩形選択した前後にタグを挿入したりするのに便利(C-xrtで代用できそうやけど)
この動画をみてわかったことを書いておく.
変なキーバインドを無効か
- (setq cua-enable-cua-keys nil)
- これをしとかないとC-xでkill-regionとかになって変な感じ
cua-enable-cua-keys is a variable defined in `cua-base.el'. Its value is t Documentation: *Enable using C-z, C-x, C-c, and C-v for undo, cut, copy, and paste. If the value is t, these mappings are always enabled. If the value is `shift', these keys are only enabled if the last region was marked with a shifted movement key. If the value is nil, these keys are never enabled. You can customize this variable.
矩形に対する挿入
- M-x cua-mode
- でcua-modeをenabledにして,C-enterで矩形の頭(左上)をマーク
- 矩形のお尻(右下)に移動してenterを押すとカーソルが頭に戻る
- その状態で
- とかタイプすると矩形の左側全ての行に
- が挿入される
- enterを押すと矩形の右上にカーソルが移動する とか入力すると矩形の右側全ての行に挿入される
class=...などを挿入する(C-xrt相当の動き)
- C-enterで左上をマークして,カーソルを下に移動して,class=を挿入したい位置まで移動(1文字×複数行をマークする)
- そのまま入力を始めるとマークされている範囲の左側に挿入される
- enterを押してから入力するとカーソルが一番上に動いて範囲の右側に挿入される
連番の挿入
- C-enterで左上をマークして,カーソルを下に移動して,連番を挿入したい位置まで移動(1文字×複数行をマークする)
- esc-nで数字入力のためのミニバッファにうつる
- 初期値,増加量(1行ごとに増える量),書式(-%d-とかすると-1- -2- ...となる)
- マークしている範囲が上書きされるので,空白を作っておく必要がある
他の機能
cua-modeをenableにして,describe-bindingsとか実行してキーバインドから調べてみようかな