Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zk-phi/phi-rectangle

Another rectangle-mark command
https://github.com/zk-phi/phi-rectangle

emacs

Last synced: about 2 months ago
JSON representation

Another rectangle-mark command

Awesome Lists containing this project

README

        

* phi-rectangle.el

another rectangle-mark command (rewrite of rect-mark)

矩形選択コマンド

** Screencast

[[imgs/top.gif]]

** Background

There are several previous works such as "rect-mark", "cua-mode",
etc. The motivation to write this command is as follows:

- cua-mode has many functionalities such as "delete-selection",
"shift-region", and "rectangle-mark", but it seems too complex when
we just want to use "rectangle-mark".

- cua-mode has also "mark-multiple"-like feature as a part of
"rectangle-mark". But we'd better use multiple-cursors.

- rect-mark seems simple and clean, but too simple for me. For
example, to duplicate rectangle we must call following commands:

1. rm-set-mark [C-x r C-SPC]
2. rm-kill-ring-save [C-x r C-w]
3. yank-rectangle [C-x r y]

On the other hands, cua-mode can do it with:

1. cua-set-rectangle-mark [C-RET]
2. cua-copy-region [C-w]
3. cua-paste [C-y]

cua-mode unifies "copy" and "copy-rectangle", "paste" and
"paste-rectangle", etc. Very easy.

- "force" option in rect-mark is somewhat annoying, Because we need to
delete trailing whitespaces manually.

- rect-mark does not work perfectly with delete-selection-mode.

"phi-rectangle" is based on rect-mark, but as easy-to-use as cua, and
is also integrated with multiple-cursors.

** Usage

Require this script

: (require 'phi-rectangle)

and call function =phi-rectangle-mode=. Then following commands are
available

- [C-RET] phi-rectangle-set-mark-command

Activate the rectangle mark.

- phi-rectangle-kill-region (replaces "kill-region")

A dwim version of "kill-region". If the rectangle mark is active,
kill rectangle. If the normal mark is active, kill region as usual.
Otherwise, kill whole line.

- phi-rectangle-kill-ring-save (replaces "kill-ring-save")

A dwim version of "kill-ring-save" like "phi-rectangle-kill-region".

- phi-rectangle-yank (replaces "yank")

A dwim version of "yank". If the last killed object is a rectangle,
yank rectangle. Otherwise yank a kill-ring item as usual.

** multiple-cursors Integration

When multiple-cursors is installed in your system, phi-rectangle does
more.

- Convert killed-rectangle and fake cursors' kill-ring if proper.

[[imgs/mc1.gif]]

- Invoke multiple-cursors-mode on delete-selection-mode to edit
multiple lines.

[[imgs/mc2.gif]]