Skip to main content

Questions tagged [rectangle]

refers to the shape of the selected text area; it can be any arbitrary rectangular area of the text buffer extending multiple lines and need not include the entire line.

Filter by
Sorted by
Tagged with
2 votes
1 answer
44 views

Right-pad a series of lines to give them common length n

I often find myself wanting to take a number of consecutive lines with different lengths, and right-pad them with space so they have the same length, say n. What's a good way to do this painlessly? If ...
Eric Auld's user avatar
  • 145
0 votes
1 answer
25 views

delete-rectangle fails when called in a program

I want to remove timestamps from a server log: 2023-11-22T11:36:28: # error! 2023-11-22T16:11:36: ... 2023-11-22T16:11:36: # new error! Manually, I select the region at the buffer start, go to the ...
emonigma's user avatar
  • 1,967
0 votes
2 answers
90 views

How to select a noncontiguous region of arbitrary rows in a rectangle?

I can use Rectangle commands (https://www.gnu.org/software/emacs/manual/html_node/emacs/Rectangles.html) to operate over a text region. What if I want to select text from columns COL to COL+4 over ...
solr's user avatar
  • 152
0 votes
1 answer
69 views

Creating Bindings for Rectangle Mark Mode Doesn't Work

I want to create bindings for rectangle-mark-mode though the methods described above haven't worked for me. I've tried using an alist that I thought it possessed, but Emacs returned a bug saying its ...
The Programming M16A4's user avatar
0 votes
1 answer
81 views

Combine two commands

To create a list from sentences in org mode, I use following command string-insert-rectangle replace-regexp ^ with - How can I combine these two to form a single keyboard short-cut?
Vaibhav's user avatar
  • 593
0 votes
1 answer
274 views

To remove characters in the beginnings of lines

To add // in the beginnings of multiple lines I can use either string-insert-rectangle or string-rectangle (C-x r t). But how is it possible to remove these characters instead? This question is not ...
john c. j.'s user avatar
12 votes
3 answers
4k views

How to select and delete a column of text in emacs?

I have this text 1 A 2 B 3 C I want to remove the first column to make it A B C Ok so I need to make a rectangle. Reading about rectangles I see "To specify a rectangle for a command to work on,...
BigBoy1337's user avatar
2 votes
3 answers
104 views

Count Words in a Rectangle

When I select a rectangle and count the words (M =) in the selection it counts as if I had used the normal selection method. Is there a way to count only in the rectangle?
jake9wi's user avatar
  • 181
5 votes
1 answer
295 views

Highlight rectangle and non-rectangle selection at the same time

By default, Emacs highlights the non-rectangular selection; alternatively, you can use (rectangle-mark-mode) to show the rectangular selection. Instead, I'd like to always show both, by highlighting ...
Cactus's user avatar
  • 175
1 vote
0 answers
33 views

How to write functions that only operate on characters within a rectangular-region?

I've found emacs has support for rectangular selection, however I didn't see references to API's for only operating on contents within the rectangle mark. How would this be acomplished? Take this ...
ideasman42's user avatar
  • 9,157
1 vote
1 answer
138 views

kill-ring-save rectangle and paste transposed?

Suppose I have some code written like: a_to_b = self.tversky(a, b) b_to_c = self.tversky(b, c) d_to_e = self.tversky(d, e) e_to_f = self.tversky(e, f) g_to_h = self.tversky(g, h) I would like to ...
dylanjm's user avatar
  • 333
1 vote
3 answers
3k views

Replace string in rectangular region?

When you select a region normally, you can do a replace-string on only that region. It would be very useful to select a rectangular region (via C-x SPC), and be able to replace-string on only that ...
gilbereth's user avatar
1 vote
1 answer
183 views

kill rectangle not working on Mac (missing file/library)

I just upgraded to emacs 26.2 using homebrew on my MAC (update: I had actually done a global "brew update" and assumed it had also updated emacs) and now kill-rectangle with C-x r k no longer works, ...
ClimateUnboxed's user avatar
0 votes
0 answers
65 views

How to postfix with a string each line of a multiline selection?

Reminder:C-x r t string <RET> replaces rectangle contents with string on each line (string-rectangle). https://www.gnu.org/software/emacs/manual/html_node/emacs/Rectangles.html Can I use this, ...
user avatar
0 votes
2 answers
76 views

Prepend to block of text, but ignore blank lines

How to add the string 'export ' to the beginning of each line of this text, with emacs: RBENV_VERSION="2.n.0" AUTHORIZE_NET_API_LOGIN_ID=example AUTHORIZE_NET_TRANSACTION_KEY=example # Google ...
american-ninja-warrior's user avatar
1 vote
0 answers
32 views

completion-kill-region breaks rectangle-mark-mode

When using dynamic completion, rectangle-mark-mode is broken, in so far as C-w no longer respects just killing the rectangle but instead kills the usual full (non-rectangular) region. M-w on the ...
jtl's user avatar
  • 11
1 vote
1 answer
365 views

Search within column or rectangle

Is there a simple way to search within the current column or within a rectangle? I am navigating a CSV file and would like to find the value "10" in a particular column. Searching the entire file is ...
Lorem Ipsum's user avatar
  • 4,577
0 votes
1 answer
335 views

How can I apply a keyboard macro to every line that starts with rectangle mark region

Lets suppose I would like to edit my text and to add comments to the column in the text. This is my text: something-text1 foobar1 something-text1 something-text2 foobar2 something-text2 --- ...
Pfedj's user avatar
  • 338
0 votes
0 answers
43 views

Pasting rectangle indents text to the right

Copying and pasting a rectangle from the following table with C-x SPC C-x r M-w C-x r y shifts the beginning of the line to the right as shown below: |----+----------+------+------+--------| | | ...
Sati's user avatar
  • 835
1 vote
1 answer
125 views

untabify within a rectangular region?

How may I call untabify against a rectangular region? This screenshot illustrates what I am trying to accomplish. I have a messy mixture of tabs and spaces in the region I have circled. untabify ...
daveloyall's user avatar
  • 1,300
1 vote
1 answer
27 views

Lines vanish when using string rectangle with line-wrap

I paste this text, copied from IBM's social responsibility, into an Emacs buffer where the frame is 80 characters, or is small enough to cause a line-wrap: 02 Education and skills We are ...
emonigma's user avatar
  • 1,967
0 votes
1 answer
267 views

how add vertical column to vertical column

I have column of text like this: Abba Foo Boo M and I want to transform it to: Abba = Abba Foo = Foo Boo = Boo M = M I can add " = " to end column of text via C-x space and M-x string-insert-...
user1244932's user avatar
3 votes
0 answers
48 views

string-rectangle command pollutes kill-ring after upgrade to Emacs 25

In Emacs 24 I used to have a workflow for inserting a string into multiple lines at once: Go to the desired position in the first line. Press C-Space to place the mark. Go to the last line (while ...
Zoltan's user avatar
  • 251
2 votes
0 answers
317 views

Aligning (ditaa) rectangles with variable string width in yasnippet

To quickly add simple diagrams to notes, I've created yasnippets for ditaa boxes. The text inside each box is a $x - and therefore has a length I do not know at snippet design time. As a consequence, ...
Werner's user avatar
  • 355
4 votes
4 answers
364 views

immediately invoke string-rectangle upon rectangle-mark-mode selection

A common use-case that I have is to add a string to the same position of each line of text. For example, I might start with expect(one).toEqual(true); expect(two).toEqual(false); which I want to ...
mark's user avatar
  • 293
1 vote
2 answers
373 views

Transposing rectangular region

I have a piece of code like this in yaml. security_group_sig_egress_ipv6: "allowed_remote_sig_egress_ipv6" security_group_sig_ingress_ipv6: "allowed_remote_sig_ingress_ipv6" ...
Black_Zero's user avatar
1 vote
1 answer
106 views

non-character input-event when using rectangular commands since version 24.4

Since version 24.4 and till 25.1 when I want to make a rectangular copy C-x r r RET I got the following message: non-character-input-event It appears that this problem happens only for rectangular ...
giordano's user avatar
  • 113
2 votes
4 answers
469 views

Search/replace inside a rectangular region, without CUA mode

I want to use search/replace (string or regexp) inside a rectangular region (aka column selection?). Consider this question: Search and replace inside a rectangle in emacs That's what I want, except ...
daveloyall's user avatar
  • 1,300
3 votes
2 answers
1k views

Copying a rectangular selection to system clipboard

Does anyone know a command or somtething to copy an rectangular selection (as with C-x r M-w / copy-rectange-as-kill) and put the killed rectangle into the system clipboard like with the kill-ring-...
Pierre Téchoueyres's user avatar
6 votes
2 answers
2k views

Copy text as rectangle

This is the block of text that I intend to copy as rectangle (without the line numbers). 1. ALM_KRmet_DCDO_RPMP_START 2. ALM_KRmet_DCDO_RPMP_STOP 3. ALM_KRmet_DIDC_RPMP_TRIP 4. ...
Prasanna's user avatar
  • 1,590
0 votes
1 answer
140 views

Inserting line break into a rectangle

I have a list that looks like 1.530 2.895 4.362 50.14 3.14 2.7 And I want it to look like 1.530 2.895 4.362 50.14 3.14 2.7 I suspect there is a clever way to use a rectangle to do this but I ...
Jaime Arturo Gomez's user avatar
9 votes
3 answers
6k views

How to select (and copy) a column of an org table *without* rectangle selection?

It seems to me that the normal way to copy a column of an org table is by rectangle selection (see here). That is, first the column is selected by marking all of it by hand, and then it is copied with ...
Timm's user avatar
  • 1,619
2 votes
1 answer
1k views

Virtual space for rectangular selections (at least)

In Vim there is the virtualedit variable which can be set so that Vim allows the cursor to move past the end of the line always or only when in visual block mode. Is it possible to configure Emacs to ...
Arch Stanton's user avatar
  • 1,777
0 votes
1 answer
179 views

Copy rectangle text into org-table

I have 5 rows of text: 1 0% 2 от 1% до 20% 3 от 21% до 50% 4 от 51% до 100% 5 100% And I would like to copy everything after digits (1..5) to a table column PRC | N | PRC| | | | | |...
Maxim Kim's user avatar
  • 1,806
4 votes
3 answers
340 views

Copy a column of uneven width that ends with a specific character

I have a data file that looks as follows ALGO = Fast EDIFF = 6.7e-05 ENCUT = 520 IBRION = 2 ICHARG = 1 ISIF = 2 ISMEAR = 0 ISPIN = 2 I'm interested in copying the first column of uneven width but ...
rambalachandran's user avatar
9 votes
2 answers
610 views

Insert lines when yanking rectangle rather than inserting among following lines?

Having copied the 3x3 rectangular region containing a's, how can I yank/paste that content at the desired point without slicing into the following text? The following is the behavior for: M-w (kill-...
ebpa's user avatar
  • 7,579
8 votes
2 answers
809 views

Yank a column of text copied from the clipboard

I often seem to want to copy paste multiple columns, for example, I paste one column line one line two line three Now I'd like to be able to yank another column behind it. Assuming my kill buffer ...
hbogert's user avatar
  • 191
6 votes
4 answers
1k views

How to find and replace regex within a rectangle selection block

I have the following text: | Row # | Facility | Recycled Off-site | |-------+--------------------------+-------------------+ | 1 | 1234, 12th st, jamestown | 216,574 | | ...
modulitos's user avatar
  • 2,532
1 vote
1 answer
450 views

AUCTeX: toggle sub- and superscript-fontification

Or: How to put face changes in a defun? I use AUCTeX to edit my LaTeX files and I like the way AUCTeX displays the sub- and superscripts (not only in formulas). Not only it shifts the sub- or ...
Kurt Hesselbart's user avatar
1 vote
2 answers
841 views

Kill rectangle with cua-mode support

There are many nice column editing features in CUA mode. After hitting Ctrl+RETURN, binded to cua-set-rectangle-mark, you get some help in the minibuffer: But I can't find the shortcut to cut/kill ...
nephewtom's user avatar
  • 2,281
2 votes
1 answer
69 views

How to control width of rectangular selection in Emacs 25?

There is a cool new feature in Emacs 25: visual support for rectangular selection. However, I would like to set its width to one pixel when it's “logical” width is zero columns of text. By default it'...
Mark Karpov's user avatar
  • 4,993
4 votes
1 answer
801 views

evil rectangles with point past EOL

When visually selecting rectangles with C-v in evil, the point is not allowed to pass the end of line. This is in contrast with: rectangle-mark-mode cua-rectangle-mark-mode Both of which allow the ...
PythonNut's user avatar
  • 10.5k
4 votes
1 answer
203 views

Find rectangular selection

Is there an easy way to search for other occurences of a selected rectangle, regardless of the column at which the pattern starts? As an example, when searching for the 4x2 text block in lines 1+2 in ...
Evgeniy Berezovsky's user avatar
12 votes
2 answers
598 views

How do i get rid of "default" (last used) string in some emacs functions?

I have the following problem : when i use 'C-x r t' (string-rectangle), i am prompted to enter some string, to replace the selected rectangle. Lets say i type ";;" (to comment out the rectangle). This ...
mation's user avatar
  • 121
1 vote
3 answers
218 views

string-rectangle: how to make input vary?

How can string-rectangle or C-xrt convert aRandomText_-1 aRandomText_-1 aRandomText_-1 aRandomText_-1 aRandomText_-1 aRandomText_-1 aRandomText_-1 aRandomText_-1 aRandomText_-1 aRandomText_-1 ...
Blaz's user avatar
  • 209
2 votes
1 answer
420 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 ...
MetroWind's user avatar
  • 187
2 votes
1 answer
60 views

Bug in downcase-region when using cua-set-rectangle-mark?

Is the following a bug or a feature? If the former, how do I file? If the latter, can someone explain the logic? On the following content in my buffer (*scratch*), upon marking the inner rectangle ...
John Kemeny's user avatar
4 votes
1 answer
2k views

rectangle-insert in Emacs 24.4

Emacs 24.3 had a nice way of inserting text into rectangles: Select rectangle. C-x r t <string-to-be-inserted> RET This doesn't seem to work in Emacs 24.4. I tried rectangle-mark-mode using C-...
deejay's user avatar
  • 313
5 votes
4 answers
675 views

Add a constant decimal value to a column of numbers

Suppose I have a file containing the following: ATOM 10 H5 LIG 1 -0.684 2.034 0.000 1.00 0.00 ATOM 11 C1 LIG 1 0.974 0.686 0.000 1.00 0.00 ATOM 12 H1 ...
holocronweaver's user avatar
7 votes
1 answer
2k views

Enable Emacs column selection using mouse

How to use mouse to select column in Emacs? How to enable it? The emacs wiki RectangleMark says, there is mouse support for rectangle highlighting by dragging the mouse while holding down the ...
xpt's user avatar
  • 497