I have been baking, in the back of my mind, a way to make multiple cursors more powerful. What I wanted was a way to move through a buffer, and mark certain places where I want to place my multiple cursors, and then make my changes. I think this idea is basically baked enough to reveal that… it is not actually necessary to modify the multiple-cursors library to achieve this goal.
If you want to do this, you can simply insert a sequence of characters that is
unique at each point that you wish to place a cursor (something that you would
never use, like some crazy Unicode character, say "ಠಠ", you just have to find
an easy way to insert it into the buffer). Then, select that tagging sequence
and use mc/mark-all-like-this
and edit away. This actually works in a pinch.
For instance, you can do things like this:
However, I guess that this is slightly more hackish than I like, so I came up
with a new, better method. What I decided would be pretty awesome is to have
multiple-cursors be able to mark spots off the top of the mark ring (either via
popping or just walking the mark ring). I defined a function mc/mark-pop
that
will just this. I use the suggested multiple cursors and expand region key
bindings and bound mc/mark-pop
to "C-S-p" (which makes sense on a Dvorak
keyboard layout, if you use Qwerty, you might use "C-?"). This means that you
can do some pretty awesome stuff like this:
I have submitted a pull request to Magnars which has been accepted. This is still a bit inconvenient to use, but it has promise for being an excellent building block for future multiple cursor editing tricks.
No comments :
Post a Comment