5

This question already has an answer here:

The title says it all.

I'm looking for a C- or M- built-in way to select non-consecutive lines and blocks of text, like usual consecutive lines with Shift or C-SPC.

I.e. I need a switch that turn selecting off and back on, but previous selections stay.

marked as duplicate by Drew, Stefan, DoMiNeLa10 Dec 2 '18 at 15:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

Not built in but another package for this is called objed (I'm the author). You can mark any text object with m the point is moved to the next object of current type automatically. Unmark any object by navigating to it and press m again. Here is an example screencast:

enter image description here

0

There is currently no such functionality in Emacs. The infrastructure to make it possible is pretty much there, but the UI for it is missing.

More specifically, there is one form of "non-consecutive region" which is supported: rectangular regions. The underlying hooks (such as region-extract-function) can be used for non-rectangular non-consecutive regions, but I don't know yet of any package which implements this.

0

Emacs does not offer this currently. (And the so-called "non-consecutive region" is at best only a very partial substitute, IMHO.)

You can, however, use library zones.el (see Zones and Multiple Narrowings) to act on multiple, non-contiguous buffer zones, either together or separately.

You can put the region on any zone, and then use commands that act on the region. And you can write commands that act on multiple zones.

But Emacs itself does not currently have a notion of multiple-zone region, that is, a region whose parts are truly non-contiguous.


In particular, if you try to Isearch the rectangular region (so-called "non-consecutive region") the search is actually performed against the whole buffer, and search hits that are not entirely within the rectangle are filtered out. This can have the effect of missing some legitimate search hits that are within the rectangle. See Emacs bugs #27896 and #27926.

Not the answer you're looking for? Browse other questions tagged or ask your own question.