Questions tagged [region]

The text between the point and mark in a buffer.

Filter by
Sorted by
Tagged with
7
votes
3answers
874 views

Sum numbers in region

How can I sum a set of numbers interspersed with text in the region (not a rectangular region). For example, if the region contains this text: Widgets 234 Sprockets 44 Nubbins 12 Fork handles 4 4 ...
8
votes
2answers
3k views

Remove parentheses around region

Is there a better alternative to this function I use to remove parens around a region? I'm looking for an Emacs builtin, or something better written, something that will remove any pairs around the ...
5
votes
3answers
1k views

select text to end of line, without moving point

I often want to quickly mark everything from point to the end of line, leaving point at the same place. I tried to write simple function for that purpose: (defun mark-from-point-to-end-of-line () "...
8
votes
2answers
212 views

Narrow to previous restriction

Is there a convenient way to restore the previous restriction? So after the following sequence of events: Mark a region Call narrow-to-region and do some work. Call widen to jump around and look for ...
1
vote
1answer
244 views

Use multiple cursor if region is active, otherwise use CUA, how?

I’m trying to implement this when I press C-return: If there’s an active region, it activates multiple cursors by calling mc/edit-lines If there’s no active region, it initiates rectangular selection ...
9
votes
3answers
196 views

Set region to include enclosing parentheses

Starting with the point or active region, how do I quickly (in one keystroke / command) 'expand' to include the next set of enclosing parentheses? If I start with: (| means point) (defn foo [x] (+ x ...
12
votes
3answers
895 views

Fontify a region of a buffer with another major mode

I have a buffer that shows documentation for Ansible modules. This buffer has its own major mode which provides all the standard stuff. Notably, it fontifies the buffer to highlight inline markup, ...
1
vote
1answer
296 views

How to avoid losing selection with Helm

Whenever I select a region and execute an extended command (M-x), Helm opens and I immediately lose the ring selection highlighting. Is there a way of stopping Helm from doing so? My Helm ...
5
votes
1answer
191 views

How to make sure currently selected text gets deleted when typing new text?

When editing text, editors' usual behaviour is to replace selected text with the next text. In Emacs, when text is selected and you enter new characters, the new text gets inserted at point, leaving ...
15
votes
2answers
4k views

Shift+Up isn't recognized by Emacs in a terminal

Very often I use Shift+Up/Down to select a region in Emacs. It works fine in GUI mode, but when emacs is invoked with -nw option I can select lines only with Shift+Down. The Shift+Up doesn't work, I ...
8
votes
6answers
1k views

Selecting text without moving the cursor

I would like to grow a selection without moving point (the cursor) from its location. I know I can always use C-u C-spc to move to the previous location, but I would like to avoid that. More ...
8
votes
2answers
76 views

Why is my function not identifying the end of the region correctly?

I have the following function, adapted slightly from here: ;; Insert text around a region. In this case, it's ;; the LaTeX code environment from the listings package (defun wrap-code (start end) "...